cached_network_lottie 0.0.2
cached_network_lottie: ^0.0.2 copied to clipboard
Cached network Lottie to load and cache network .json and .lottie files.
import 'package:cached_network_lottie/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: 'Cached Network Lottie Example',
theme: ThemeData(
primarySwatch: Colors.blue,
useMaterial3: true,
),
home: Scaffold(
appBar: AppBar(
title: const Text('Cached Network Lottie'),
elevation: 2,
),
body: ListView(
padding: const EdgeInsets.all(16),
children: [
const Text(
'Examples',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
),
const SizedBox(height: 8),
const Text(
'The widget automatically detects the file format(.json, .lot, .lottie) and uses the appropriate renderer.',
style: TextStyle(color: Colors.grey),
),
const SizedBox(height: 24),
Card(
child: Padding(
padding: EdgeInsets.all(16),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text('Lottie JSON'),
CachedNetworkLottie(
'https://lottie.host/580f1627-4688-4032-b5d5-5827f53806fc/s0UIo43moM.json',
width: 200,
height: 200,
repeat: true,
),
],
),
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text('DotLottie'),
CachedNetworkLottie(
'https://lottie.host/95d9b5d7-505f-4582-95b8-0ac7564d9585/rjoHaSls9v.lottie',
width: 200,
height: 200,
repeat: true,
),
],
),
],
),
),
),
],
),
),
);
}
}