fast_cached_network_image 0.0.3 copy "fast_cached_network_image: ^0.0.3" to clipboard
fast_cached_network_image: ^0.0.3 copied to clipboard

A flutter package to cache network image fastly without native dependencies.

Fast Cached Network Image #

A flutter package to cache network image fastly without native dependencies.

MIT License pub dart

Screenshots #

App Screenshot

Usage #

Depent on it

import 'package:fast_cached_network_image/fast_cached_network_image.dart';

Use path_provider to set a storage location for the db of images.

String storageLocation = (await getApplicationDocumentsDirectory()).path;

Initialize the cache configuration

await FastCachedImageConfig.init(path: storageLocation, clearCacheAfter: const Duration(days: 15));

The clearCacheAfter property is used to set the Duration after with the cached image will be cleated. By default its set to 7 days, which means an image cached today will be deleted when you open the app after 7 days.

Use it as a Widget

child: FastCachedImage(url: url)

Properties #

errorBuilder: (context, param, e) {
          return Text(e.toString());
        },

errorBuilder property needs to return a widget. This widget will be displayed if there is any error while loading the provided iamge.


loadingBuilder: (context) {
          return Container(color: Colors.red, height: 100, width: 100);
        },

loadingBuilder property can be used to display a loading widget such as a shimmer. This widget will be displaed while the image is being downloaded and processed.

FastCachedImage have all other default properties such as height, width etc. provided by flutter.

Example #


import 'package:flutter/material.dart';
import 'package:path_provider/path_provider.dart';
import 'package:fast_cached_network_image/fast_cached_network_image.dart';


void main() async {
  WidgetsFlutterBinding.ensureInitialized();

   String storageLocation = (await getApplicationDocumentsDirectory()).path;
  await FastCachedImageConfig.init(path: storageLocation, clearCacheAfter: const Duration(days: 15));

  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String url = 'https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885__480.jpg';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
      body: FastCachedImage(
        url: url,
        errorBuilder: (context, param, e) {
          return Text(e.toString());
        },
        loadingBuilder: (context) {
          return Container(color: Colors.red, height: 100, width: 100);
        },
      ),
    ));
  }
}



154
likes
0
pub points
96%
popularity

Publisher

unverified uploader

A flutter package to cache network image fastly without native dependencies.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, hive

More

Packages that depend on fast_cached_network_image