optimized_cached_image 1.0.0 copy "optimized_cached_image: ^1.0.0" to clipboard
optimized_cached_image: ^1.0.0 copied to clipboard

outdated

A library for loading images from network, resizing as per container size and caching while being memory sensitive.

example/lib/main.dart

import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:optimized_cached_image/image_cache_manager.dart';
import 'package:optimized_cached_image/widgets.dart';
import 'package:path_provider/path_provider.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final urlPrefix = "https://i.picsum.photos/id/";
  final urlSuffix = "/1000/1000.jpg";

  @override
  void initState() {
    super.initState();

    /// Just a demo of the param(s) in ImageCacheManager,
    /// you don't need to do this unless you wish to customize stuff
    ImageCacheManager.init(
        ImageCacheConfig(storagePath: path(), enableLog: !kReleaseMode));
  }

  /// A debug path to inspect our cache files on android.
  /// Note this is purely for debugging and wouldn't work on ios since such a directory doesn't exist.
  /// You're better of not passing this value to [ImageCacheManager.init]
  Future<Directory> path() async => (await getExternalCacheDirectories())[0];

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Optimized Cached Image Example'),
        ),
        body: Container(
          child: GridView.builder(
            padding: const EdgeInsets.all(20),
            itemCount: 30,
            gridDelegate:
                SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3),
            itemBuilder: (BuildContext context, int index) {
              return OptimizedCacheImage(
                imageUrl: "https://picsum.photos/id/${(index + 100)}/600/600",
              );
            },
          ),
        ),
      ),
    );
  }
}
114
likes
40
pub points
91%
popularity

Publisher

verified publisheranvith.dev

A library for loading images from network, resizing as per container size and caching while being memory sensitive.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

flutter, flutter_blurhash, flutter_cache_manager, flutter_image_compress, http, octo_image, path, path_provider, pedantic, sprintf, uuid

More

Packages that depend on optimized_cached_image