smart_cached_network_lottie 1.0.0
smart_cached_network_lottie: ^1.0.0 copied to clipboard
A Flutter package for caching Lottie animations with smart update detection, automatic format handling (JSON and dotLottie), and ETag/Last-Modified based cache invalidation.
import 'package:smart_cached_network_lottie/smart_cached_network_lottie.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const CachedNetworkLottieExampleApp());
}
class CachedNetworkLottieExampleApp extends StatelessWidget {
const CachedNetworkLottieExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Smart Cached Network Lottie Example',
home: Scaffold(
appBar: AppBar(title: const Text('Smart Cached Lottie')),
body: Center(
child: SmartCachedNetworkLottie(
url: "https://assets10.lottiefiles.com/packages/lf20_nfbtru7n.json",
width: 220,
height: 220,
repeat: true,
autoCheckForUpdates: false,
onUpdate: () => print('Animation updated!'),
errorBuilder: (context, error, stackTrace) {
print('Error: $error');
print('StackTrace: $stackTrace');
return Text(
'Error: $error',
style: const TextStyle(color: Colors.red),
);
},
loadingBuilder: (context) => const CircularProgressIndicator(),
),
),
),
);
}
}