Files
lottie-flutter/example/lib/examples/telegram_stickers.dart
Xavier H aef8ef7ee0 Fix bugs & support .tgs & .lottie (#314)
- 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)
```
2023-11-08 09:10:25 +01:00

40 lines
832 B
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(),
),
);
}
}
class Example extends StatelessWidget {
const Example({super.key});
@override
//--- example
Widget build(BuildContext context) {
return ListView(
children: [
Lottie.network(
'https://telegram.org/file/464001484/1/bzi7gr7XRGU.10147/815df2ef527132dd23',
decoder: LottieComposition.decodeGZip,
),
Lottie.asset(
'assets/LightningBug_file.tgs',
decoder: LottieComposition.decodeGZip,
),
],
);
}
//---
}