-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request #1
Comments
Yes, you can use cached_network_image for displaying locally stored images. Regarding implementing a local data source, you can consider using the ‘floor’ package. It provides a robust solution for database operations in Flutter. Maybe I will add local data source to this example project.. For instance to load images: class ImageWithFallback extends StatelessWidget {
final String imageUrl;
final String fallbackAssetPath;
ImageWithFallback({
required this.imageUrl,
required this.fallbackAssetPath,
});
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: Connectivity().checkConnectivity(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
// You can display a loading indicator here
return CircularProgressIndicator();
} else if (snapshot.hasError) {
// Handle any errors
return Text('Error: ${snapshot.error}');
} else if (snapshot.data == ConnectivityResult.none) {
// Display a locally stored image as a fallback
return Image.asset(fallbackAssetPath); // Use the fallback image asset
} else {
// There's a network connection, load the online image
return CachedNetworkImage(
imageUrl: imageUrl,
placeholder: (context, url) => CircularProgressIndicator(),
errorWidget: (context, url, error) => Icon(Icons.error),
);
}
},
);
}
}
|
I see, what im saying though is whether its possible to get the precise image that was first gotten from the internet, not a fallback asset path. Also please do add the local datasource to this example project 😁, I'm currently stuck trying to implement that side of my app I also don't want to download images, as the app has a lot of them (large in size as well) and can result in taking a lot of the users phone storage. thanks once again. |
It's up to you how you implement this, and if you want, you can set a cache size limit. |
okay alright but will you add the local datasource impl to this project? |
Wonderful job on the repo and the app architecture.
however, I'm curious as to how you want to implement the local datasource, for when there's no internet, especially with the image urls coming in as part of the fields in an entity class.
will cached network image still be able to load the imageurl if you just pass the locally stored entity when there's no internet? looking forward to that side of implementation.
cheers!
The text was updated successfully, but these errors were encountered: