Skip to content

Commit da1a9cf

Browse files
committed
Add support Telegram Sticker .tgs in Lottie Integration
1 parent 74b1d87 commit da1a9cf

File tree

10 files changed

+29
-8
lines changed

10 files changed

+29
-8
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,9 @@ Widget build(BuildContext context) {
408408
|---------------------------------------------------------|----------------------|-----------------------|-------------------------------------------|
409409
| [flutter_svg](https://pub.dev/packages/flutter_svg) | .svg | `flutter_svg: true` | Assets.images.icons.paint.**svg()** |
410410
| [rive](https://pub.dev/packages/rive) | .riv | `rive: true` | Assets.rive.vehicles.**rive()** |
411-
| [lottie](https://pub.dev/packages/lottie) | .json, .zip, .lottie | `lottie: true` | Assets.lottie.hamburgerArrow.**lottie()** |
411+
| [lottie](https://pub.dev/packages/lottie) | .json, .zip, .lottie, .tgs | `lottie: true` | Assets.lottie.hamburgerArrow.**lottie()** |
412412

413-
**Note:** For [lottie](https://pub.dev/packages/lottie) integration with `.lottie` files, you must add a custom decoder via `decoder` parameter to select the correct .json file from a dotlottie (.lottie) archive, see [lottie's document](https://pub.dev/packages/lottie#telegram-stickers-tgs-and-dotlottie-lottie) for more information.
413+
**Note:** For [lottie](https://pub.dev/packages/lottie) integration with `.lottie` and `.tgs` files, you must add a custom decoder via `decoder` parameter, see [lottie's document](https://pub.dev/packages/lottie#telegram-stickers-tgs-and-dotlottie-lottie) for more information.
414414

415415
In other cases, the asset is generated as String class.
416416

25.4 KB
Binary file not shown.

examples/example/lib/gen/assets.gen.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ class $AssetsLottieGen {
8282
LottieGenImage get alarmClockLottieV440 =>
8383
const LottieGenImage('assets/lottie/alarm-clock-lottie-v440.json');
8484

85+
/// File path: assets/lottie/cat.tgs
86+
LottieGenImage get cat => const LottieGenImage('assets/lottie/cat.tgs');
87+
8588
/// File path: assets/lottie/geometrical-animation.json
8689
LottieGenImage get geometricalAnimation =>
8790
const LottieGenImage('assets/lottie/geometrical-animation.json');
@@ -101,6 +104,7 @@ class $AssetsLottieGen {
101104
List<LottieGenImage> get values => [
102105
xuiIZ9X1Rf,
103106
alarmClockLottieV440,
107+
cat,
104108
geometricalAnimation,
105109
hamburgerArrow,
106110
spinningCarrousel,
@@ -171,7 +175,8 @@ class $AssetsImagesChip4Gen {
171175
const $AssetsImagesChip4Gen();
172176

173177
/// File path: assets/images/chip4/chip4.jpg
174-
AssetGenImage get chip4 => const AssetGenImage(
178+
AssetGenImage get chip4 =>
179+
const AssetGenImage(
175180
'assets/images/chip4/chip4.jpg',
176181
flavors: {'extern'},
177182
);

examples/example/lib/main.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:example/gen/colors.gen.dart';
33
import 'package:example/gen/fonts.gen.dart';
44
import 'package:example_resources/gen/assets.gen.dart';
55
import 'package:flutter/material.dart';
6+
import 'package:lottie/lottie.dart';
67

78
void main() {
89
print(MyAssets.images.chip4.chip4.flavors);
@@ -59,6 +60,13 @@ class MyApp extends StatelessWidget {
5960
fit: BoxFit.contain,
6061
),
6162
),
63+
SizedBox(
64+
width: 200,
65+
height: 200,
66+
child: MyAssets.lottie.cat.lottie(
67+
decoder: LottieComposition.decodeGZip,
68+
),
69+
),
6270
MyAssets.images.chip1.image(),
6371
Container(
6472
height: 400,
25.4 KB
Binary file not shown.

examples/example_resources/lib/gen/assets.gen.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ import 'package:vector_graphics/vector_graphics.dart' as _vg;
1717
class $AssetsImagesGen {
1818
const $AssetsImagesGen();
1919

20+
/// File path: assets/images/cat.tgs
21+
LottieGenImage get cat => const LottieGenImage('assets/images/cat.tgs');
22+
2023
/// File path: assets/images/dart.svg
2124
SvgGenImage get dart => const SvgGenImage('assets/images/dart.svg');
2225

@@ -35,8 +38,8 @@ class $AssetsImagesGen {
3538
RiveGenImage get skills => const RiveGenImage('assets/images/skills.riv');
3639

3740
/// List of all assets
38-
List<dynamic> get values =>
39-
[dart, favorite, flutter3, runningCarOnRoad, skills];
41+
List<dynamic> get values => [
42+
cat, dart, favorite, flutter3, runningCarOnRoad, skills];
4043
}
4144

4245
class $AssetsUnknownGen {
@@ -51,7 +54,7 @@ class $AssetsUnknownGen {
5154
}
5255

5356
class ResAssets {
54-
ResAssets._();
57+
const ResAssets._();
5558

5659
static const String package = 'example_resources';
5760

packages/core/lib/generators/integrations/lottie_integration.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ ${isPackage ? "\n static const String package = '$packageName';" : ''}
122122
bool get isConstConstructor => true;
123123

124124
bool isLottieFile(AssetType asset) {
125-
if (asset.extension == '.lottie') {
125+
if (asset.extension == '.lottie' || asset.extension == '.tgs') {
126126
return true;
127127
}
128128
if (!_supportedMimeTypes.contains(asset.mime)) {

packages/core/test_resources/actual_data/assets_lottie_integrations.gen.dart

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

packages/core/test_resources/pubspec_assets_lottie_integrations.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ flutter:
1212
- assets/lottie/hamburger_arrow.json
1313
- assets/lottie/spinning_carrousel.zip
1414
- assets/lottie/XuiIZ9X1Rf.lottie
15+
- assets/lottie/cat_cat.tgs

0 commit comments

Comments
 (0)