mirror of
https://github.com/xvrh/lottie-flutter.git
synced 2025-08-06 16:39:36 +08:00

- Fixed varying opacity stops across keyframes in the same gradient - Fixed rounded corners for non-closed curves - Allow to load Telegram Stickers (.tgs) ```dart Lottie.asset( 'sticker.tgs', decoder: LottieComposition.decodeGZip, ) ``` - Expose a hook to customize how to decode zip archives. This is useful for dotlottie (.lottie) archives when we want to specify a specific .json file inside the archive ```dart Lottie.asset( 'animation.lottie', decoder: customDecoder, ); Future<LottieComposition?> customDecoder(List<int> bytes) { return LottieComposition.decodeZip(bytes, filePicker: (files) { return files.firstWhere((f) => f.name == 'animations/cat.json'); }); } ``` - Remove name property from `LottieComposition` - `imageProviderFactory` is not used in .zip file by default anymore. To restore the old behaviour, use: ```dart Future<LottieComposition?> decoder(List<int> bytes) { return LottieComposition.decodeZip(bytes, imageProviderFactory: imageProviderFactory); } Lottie.asset('anim.json', imageProviderFactory: imageProviderFactory, decoder: decoder) ```
40 lines
861 B
Dart
40 lines
861 B
Dart
import 'package:collection/collection.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:lottie/lottie.dart';
|
|
|
|
void main() => runApp(const App());
|
|
|
|
class App extends StatelessWidget {
|
|
const App({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return const MaterialApp(
|
|
home: Scaffold(
|
|
body: Example(),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
//---- example
|
|
class Example extends StatelessWidget {
|
|
const Example({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Lottie.asset(
|
|
'assets/cat.lottie',
|
|
decoder: customDecoder,
|
|
);
|
|
}
|
|
}
|
|
|
|
Future<LottieComposition?> customDecoder(List<int> bytes) {
|
|
return LottieComposition.decodeZip(bytes, filePicker: (files) {
|
|
return files.firstWhereOrNull(
|
|
(f) => f.name.startsWith('animations/') && f.name.endsWith('.json'));
|
|
});
|
|
}
|
|
//----
|