disposable_cached_images 1.0.5 disposable_cached_images: ^1.0.5 copied to clipboard
A flutter package for displaying and releasing images from memory.
import 'package:disposable_cached_images/disposable_cached_images.dart';
import 'package:flutter/material.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
runAppWithDisposableCachedImage(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: GridView.builder(
// RepaintBoundaries is enabled by default in DisposableCachedImage widget
addRepaintBoundaries: false,
padding: const EdgeInsets.all(20),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
mainAxisSpacing: 20,
crossAxisSpacing: 20,
),
itemCount: images.length,
itemBuilder: (context, index) => DisposableCachedImage.network(imageUrl: images[index]),
),
),
);
}
static final images = List.generate(
500,
(final i) => 'https://picsum.photos/id/$i/200/300',
);
}