safe_image 0.1.4
safe_image: ^0.1.4 copied to clipboard
Safe image loading from URL with native downsampling. Prevents OOM crashes and UI jank with streaming download, disk caching, and concurrency control.
import 'package:flutter/material.dart';
import 'package:safe_image/safe_image.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return SafeImageScope(
config: const SafeImageConfig(targetMaxSide: 2048, quality: 80),
child: MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Safe Image Example')),
body: Center(
child: SafeImageWidget(
url: 'https://picsum.photos/4000/3000',
width: 300,
height: 200,
fit: BoxFit.cover,
placeholder: (_) => const SizedBox(
width: 300,
height: 200,
child: Center(child: CircularProgressIndicator()),
),
),
),
),
),
);
}
}