This maybe a stupid question given the name but does CachedNetworkImage works on local images?
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
class SigninPage extends StatelessWidget {
const SigninPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Welcome"),
),
body:
Center(
child: CachedNetworkImage(
imageUrl: 'assets/images/apple_cartoon.png',
imageBuilder: (context, imageProvider) {
return Container(
decoration: BoxDecoration(
image: DecorationImage(
image: imageProvider, fit: BoxFit.cover)));
},
placeholder: (context, url) =>
const CircularProgressIndicator(),
errorWidget: (context, url, error) => const Icon(Icons.error),
),
),
);
}
}
This returns the error icon
Using Image.asset instead works fine, so I assume that you cannot use local images with CachedNetworkImage but couldn't find any confirmation online and want to be sure this was the case.