diff --git a/README.md b/README.md index 4ca1b2cfa..122fd10fd 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,7 @@ flutter_gen: flutter_svg: true flare_flutter: true rive: true + lottie: true colors: inputs: @@ -225,6 +226,8 @@ Widget build(BuildContext context) { |[flutter_svg](https://pub.dev/packages/flutter_svg)|.svg| `flutter_svg: true` |Assets.images.icons.paint.**svg()**| |[flare_flutter](https://pub.dev/packages/flare_flutter)|.flr| `flare_flutter: true` |Assets.flare.penguin.**flare()**| |[rive](https://pub.dev/packages/rive)|.flr| `rive: true` |Assets.rive.vehicles.**rive()**| +|[lottie](https://pub.dev/packages/lottie)|_lottie.json| `lottie: true` |Assets.lottie.hamburgerArrow.**lottie()**| +
@@ -725,6 +728,7 @@ flutter_gen: flutter_svg: false flare_flutter: false rive: false + lottie: false assets: # Optional diff --git a/example/assets/lottie/hamburger_arrow.json b/example/assets/lottie/hamburger_arrow.json new file mode 100644 index 000000000..886cc5756 --- /dev/null +++ b/example/assets/lottie/hamburger_arrow.json @@ -0,0 +1 @@ +{"assets":[],"layers":[{"ddd":0,"ind":0,"ty":3,"nm":"Rotator","ks":{"o":{"k":0},"r":{"k":[{"i":{"x":[0.56],"y":[1]},"o":{"x":[0.634],"y":[0]},"n":["0p56_1_0p634_0"],"t":19,"s":[0],"e":[190.7]},{"i":{"x":[0.562],"y":[1]},"o":{"x":[0.398],"y":[0]},"n":["0p562_1_0p398_0"],"t":33,"s":[190.7],"e":[176.1]},{"i":{"x":[0.684],"y":[1]},"o":{"x":[0.31],"y":[0]},"n":["0p684_1_0p31_0"],"t":40.5,"s":[176.1],"e":[181.8]},{"i":{"x":[0.684],"y":[1]},"o":{"x":[0.438],"y":[0]},"n":["0p684_1_0p438_0"],"t":55,"s":[181.8],"e":[180]},{"i":{"x":[0.733],"y":[0.733]},"o":{"x":[0.385],"y":[0.385]},"n":["0p733_0p733_0p385_0p385"],"t":71,"s":[180],"e":[180]},{"i":{"x":[0.092],"y":[1]},"o":{"x":[0.406],"y":[0]},"n":["0p092_1_0p406_0"],"t":111,"s":[180],"e":[167.9]},{"i":{"x":[0.341],"y":[1]},"o":{"x":[0.6],"y":[0]},"n":["0p341_1_0p6_0"],"t":116,"s":[167.9],"e":[363]},{"i":{"x":[0.462],"y":[1]},"o":{"x":[0.167],"y":[0]},"n":["0p462_1_0p167_0"],"t":134,"s":[363],"e":[360]},{"t":141}]},"p":{"k":[200.5,149.375,0]},"a":{"k":[60,60,0]},"s":{"k":[100,100,100]}},"ao":0,"ip":0,"op":180,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":1,"ty":4,"nm":"A1","parent":0,"ks":{"o":{"k":100},"r":{"k":[{"i":{"x":[0.56],"y":[1]},"o":{"x":[0.634],"y":[0]},"n":["0p56_1_0p634_0"],"t":19,"s":[0],"e":[-45]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":33,"s":[-45],"e":[-45]},{"i":{"x":[0.341],"y":[1]},"o":{"x":[0.6],"y":[0]},"n":["0p341_1_0p6_0"],"t":116,"s":[-45],"e":[0]},{"t":134}]},"p":{"k":[{"i":{"x":0.56,"y":1},"o":{"x":0.634,"y":0},"n":"0p56_1_0p634_0","t":19,"s":[94.5,82.875,0],"e":[96.2,57.055,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0,"y":0},"o":{"x":0.167,"y":0.167},"n":"0_0_0p167_0p167","t":33,"s":[96.2,57.055,0],"e":[96.2,57.055,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.341,"y":1},"o":{"x":0.6,"y":0},"n":"0p341_1_0p6_0","t":116,"s":[96.2,57.055,0],"e":[94.5,82.875,0],"to":[0,0,0],"ti":[0,0,0]},{"t":134}]},"a":{"k":[35,22.25,0]},"s":{"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ks":{"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[-34,22.25],[35,22.25]],"c":false}},"nm":"Path 1"},{"ty":"st","fillEnabled":true,"c":{"k":[0.4,0.16,0.7,1]},"o":{"k":100},"w":{"k":10},"lc":1,"lj":1,"ml":4,"nm":"Stroke 1"},{"ty":"tr","p":{"k":[0,0],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Shape 1"},{"ty":"tm","s":{"k":[{"i":{"x":[0.56],"y":[1]},"o":{"x":[0.634],"y":[0]},"n":["0p56_1_0p634_0"],"t":19,"s":[0],"e":[26]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":33,"s":[26],"e":[26]},{"i":{"x":[0.341],"y":[1]},"o":{"x":[0.6],"y":[0]},"n":["0p341_1_0p6_0"],"t":116,"s":[26],"e":[0]},{"t":134}],"ix":1},"e":{"k":[{"i":{"x":[0.56],"y":[0.56]},"o":{"x":[0.634],"y":[0.634]},"n":["0p56_0p56_0p634_0p634"],"t":19,"s":[100],"e":[100]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":33,"s":[100],"e":[100]},{"i":{"x":[0.341],"y":[0.341]},"o":{"x":[0.6],"y":[0.6]},"n":["0p341_0p341_0p6_0p6"],"t":116,"s":[100],"e":[100]},{"t":134}],"ix":2},"o":{"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1"}],"ip":0,"op":180,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":2,"ty":4,"nm":"A2","parent":0,"ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[60,60.625,0]},"a":{"k":[0.5,0,0]},"s":{"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ks":{"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[-34,0],[35,0]],"c":false}},"nm":"Path 1"},{"ty":"st","fillEnabled":true,"c":{"k":[0.4,0.16,0.7,1]},"o":{"k":100},"w":{"k":10},"lc":1,"lj":1,"ml":4,"nm":"Stroke 1"},{"ty":"tr","p":{"k":[0,0],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Shape 1"}],"ip":0,"op":180,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":3,"ty":4,"nm":"A3","parent":0,"ks":{"o":{"k":100},"r":{"k":[{"i":{"x":[0.56],"y":[1]},"o":{"x":[0.634],"y":[0]},"n":["0p56_1_0p634_0"],"t":19,"s":[0],"e":[45]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":33,"s":[45],"e":[45]},{"i":{"x":[0.341],"y":[1]},"o":{"x":[0.6],"y":[0]},"n":["0p341_1_0p6_0"],"t":116,"s":[45],"e":[0]},{"t":134}]},"p":{"k":[{"i":{"x":0.56,"y":1},"o":{"x":0.634,"y":0},"n":"0p56_1_0p634_0","t":19,"s":[94.5,37.125,0],"e":[96.2,64.045,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0,"y":0},"o":{"x":0.167,"y":0.167},"n":"0_0_0p167_0p167","t":33,"s":[96.2,64.045,0],"e":[96.2,64.045,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.341,"y":1},"o":{"x":0.6,"y":0},"n":"0p341_1_0p6_0","t":116,"s":[96.2,64.045,0],"e":[94.5,37.125,0],"to":[0,0,0],"ti":[0,0,0]},{"t":134}]},"a":{"k":[35,-23.5,0]},"s":{"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ks":{"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[-34,-23.5],[35,-23.5]],"c":false}},"nm":"Path 1"},{"ty":"st","fillEnabled":true,"c":{"k":[0.4,0.16,0.7,1]},"o":{"k":100},"w":{"k":10},"lc":1,"lj":1,"ml":4,"nm":"Stroke 1"},{"ty":"tr","p":{"k":[0,0],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Shape 1"},{"ty":"tm","s":{"k":[{"i":{"x":[0.56],"y":[1]},"o":{"x":[0.634],"y":[0]},"n":["0p56_1_0p634_0"],"t":19,"s":[0],"e":[26]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":33,"s":[26],"e":[26]},{"i":{"x":[0.341],"y":[1]},"o":{"x":[0.6],"y":[0]},"n":["0p341_1_0p6_0"],"t":116,"s":[26],"e":[0]},{"t":134}],"ix":1},"e":{"k":[{"i":{"x":[0.56],"y":[0.56]},"o":{"x":[0.634],"y":[0.634]},"n":["0p56_0p56_0p634_0p634"],"t":19,"s":[100],"e":[100]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":33,"s":[100],"e":[100]},{"i":{"x":[0.341],"y":[0.341]},"o":{"x":[0.6],"y":[0.6]},"n":["0p341_0p341_0p6_0p6"],"t":116,"s":[100],"e":[100]},{"t":134}],"ix":2},"o":{"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1"}],"ip":0,"op":180,"st":0,"bm":0,"sr":1}],"v":"4.4.26","ddd":0,"ip":0,"op":180,"fr":30,"w":400,"h":300} \ No newline at end of file diff --git a/example/lib/gen/assets.gen.dart b/example/lib/gen/assets.gen.dart index 7d9b07c50..e95a52c86 100644 --- a/example/lib/gen/assets.gen.dart +++ b/example/lib/gen/assets.gen.dart @@ -13,6 +13,7 @@ import 'package:flutter/services.dart'; import 'package:flare_flutter/flare_actor.dart'; import 'package:flare_flutter/flare_controller.dart'; import 'package:rive/rive.dart'; +import 'package:lottie/lottie.dart'; class $AssetsFlareGen { const $AssetsFlareGen(); @@ -52,6 +53,14 @@ class $AssetsJsonGen { String get fruits => 'assets/json/fruits.json'; } +class $AssetsLottieGen { + const $AssetsLottieGen(); + + /// File path: assets/lottie/hamburger_arrow.json + LottieGenImage get hamburgerArrow => + const LottieGenImage('assets/lottie/hamburger_arrow.json'); +} + class $AssetsMovieGen { const $AssetsMovieGen(); @@ -111,6 +120,7 @@ class MyAssets { static const $AssetsFlareGen flare = $AssetsFlareGen(); static const $AssetsImagesGen images = $AssetsImagesGen(); static const $AssetsJsonGen json = $AssetsJsonGen(); + static const $AssetsLottieGen lottie = $AssetsLottieGen(); static const $AssetsMovieGen movie = $AssetsMovieGen(); static const $AssetsRiveGen rive = $AssetsRiveGen(); static const $AssetsUnknownGen unknown = $AssetsUnknownGen(); @@ -301,3 +311,59 @@ class RiveGenImage { String get path => _assetName; } + +class LottieGenImage { + const LottieGenImage(this._assetName); + + final String _assetName; + + LottieBuilder lottie({ + Animation? controller, + bool? animate, + FrameRate? frameRate, + bool? repeat, + bool? reverse, + LottieDelegates? delegates, + LottieOptions? options, + void Function(LottieComposition)? onLoaded, + LottieImageProviderFactory? imageProviderFactory, + Key? key, + AssetBundle? bundle, + Widget Function(BuildContext, Widget, LottieComposition?)? frameBuilder, + ImageErrorWidgetBuilder? errorBuilder, + double? width, + double? height, + BoxFit? fit, + AlignmentGeometry? alignment, + String? package, + bool? addRepaintBoundary, + FilterQuality? filterQuality, + void Function(String)? onWarning, + }) { + return Lottie.asset( + _assetName, + animate: animate, + frameRate: frameRate, + repeat: repeat, + reverse: reverse, + delegates: delegates, + options: options, + onLoaded: onLoaded, + imageProviderFactory: imageProviderFactory, + key: key, + bundle: bundle, + frameBuilder: frameBuilder, + errorBuilder: errorBuilder, + width: width, + height: height, + fit: fit, + alignment: alignment, + package: package, + addRepaintBoundary: addRepaintBoundary, + filterQuality: filterQuality, + onWarning: onWarning, + ); + } + + String get path => _assetName; +} diff --git a/example/lib/main.dart b/example/lib/main.dart index c9fe64ee6..7d8ad40e4 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -43,6 +43,13 @@ void main() async { fit: BoxFit.contain, ), ), + SizedBox( + width: 200, + height: 200, + child: MyAssets.lottie.hamburgerArrow.lottie( + fit: BoxFit.contain, + ), + ), MyAssets.images.chip1.image(), // Use from example_resource package. res.Assets.images.flutter3.image(), diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 03edc584f..3a566d7ba 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -57,7 +57,7 @@ dependencies: flutter_secure_storage: 5.0.2 auto_route: 3.2.4 gap: 2.0.0 - lottie: 1.3.0 + lottie: 1.4.1 flutter_layout_grid: 2.0.0 video_player: 2.4.0 audio_service: 0.18.4 @@ -119,6 +119,7 @@ flutter_gen: flutter_svg: true flare_flutter: true rive: true + lottie: true assets: enabled: true @@ -169,6 +170,7 @@ flutter: - pictures/chip5.jpg - assets/flare/ - assets/rive/ + - assets/lottie/ - assets/movie/ - assets/unknown/ fonts: diff --git a/packages/core/example/lib/main.dart b/packages/core/example/lib/main.dart index b90abec27..6f4365019 100644 --- a/packages/core/example/lib/main.dart +++ b/packages/core/example/lib/main.dart @@ -38,6 +38,13 @@ void main() { fit: BoxFit.contain, ), ), + SizedBox( + width: 200, + height: 200, + child: Assets.lottie.hamburgerArrow.lottie( + fit: BoxFit.contain, + ), + ), Image(image: Assets.images.chip1), Assets.images.icons.kmm.svg(key: const Key("kmm_svg")), Assets.images.icons.fuchsia.svg(), diff --git a/packages/core/lib/generators/assets_generator.dart b/packages/core/lib/generators/assets_generator.dart index aff8c2d62..a7678129c 100644 --- a/packages/core/lib/generators/assets_generator.dart +++ b/packages/core/lib/generators/assets_generator.dart @@ -17,6 +17,7 @@ import 'integrations/flare_integration.dart'; import 'integrations/integration.dart'; import 'integrations/rive_integration.dart'; import 'integrations/svg_integration.dart'; +import 'integrations/lottie_integration.dart'; class AssetsGenConfig { AssetsGenConfig._( @@ -29,7 +30,7 @@ class AssetsGenConfig { factory AssetsGenConfig.fromConfig(File pubspecFile, Config config) { return AssetsGenConfig._( - pubspecFile.parent.path, + pubspecFile.parent.absolute.path, config.pubspec.packageName, config.pubspec.flutterGen, config.pubspec.flutter.assets, @@ -66,6 +67,7 @@ String generateAssets( SvgIntegration(config.packageParameterLiteral), if (config.flutterGen.integrations.flareFlutter) FlareIntegration(), if (config.flutterGen.integrations.rive) RiveIntegration(), + if (config.flutterGen.integrations.lottie) LottieIntegration(), ]; if (config.flutterGen.assets.isDotDelimiterStyle) { @@ -130,15 +132,16 @@ List _getAssetRelativePathList( .toList(); } -AssetType _constructAssetTree(List assetRelativePathList) { +AssetType _constructAssetTree( + List assetRelativePathList, String rootPath) { // Relative path is the key final assetTypeMap = { - '.': AssetType('.'), + '.': AssetType('.', rootPath), }; for (final assetPath in assetRelativePathList) { var path = assetPath; while (path != '.') { - assetTypeMap.putIfAbsent(path, () => AssetType(path)); + assetTypeMap.putIfAbsent(path, () => AssetType(path, rootPath)); path = dirname(path); } } @@ -222,7 +225,7 @@ String _dotDelimiterStyleDefinition( final assetsStaticStatements = <_Statement>[]; final assetTypeQueue = ListQueue.from( - _constructAssetTree(assetRelativePathList).children); + _constructAssetTree(assetRelativePathList, config.rootPath).children); while (assetTypeQueue.isNotEmpty) { final assetType = assetTypeQueue.removeFirst(); @@ -316,7 +319,7 @@ String _flatStyleDefinition( ) .distinct() .sorted() - .map((relativePath) => AssetType(relativePath)) + .map((relativePath) => AssetType(relativePath, config.rootPath)) .mapToIsUniqueWithoutExtension() .map( (e) => _createAssetTypeStatement( @@ -336,10 +339,12 @@ String _flatStyleAssetsClassDefinition( String className, List<_Statement> statements, ) { - final statementsBlock = - statements.map((statement) => '''${statement.toDartDocString()} + final statementsBlock = statements + .map((statement) => + '''${statement.toDartDocString()} ${statement.toStaticFieldString()} - ''').join('\n'); + ''') + .join('\n'); return _assetsClassDefinition(className, statementsBlock); } diff --git a/packages/core/lib/generators/integrations/lottie_integration.dart b/packages/core/lib/generators/integrations/lottie_integration.dart new file mode 100644 index 000000000..47f0327ba --- /dev/null +++ b/packages/core/lib/generators/integrations/lottie_integration.dart @@ -0,0 +1,122 @@ +import 'package:pub_semver/pub_semver.dart'; + +import '../../settings/asset_type.dart'; +import 'integration.dart'; +import 'dart:convert'; +import 'dart:io'; + +class LottieIntegration extends Integration { + // These are required keys for this integration. + static const lottieKeys = [ + 'w', // width + 'h', // height + 'ip', // The frame at which the Lottie animation starts at + 'op', // The frame at which the Lottie animation ends at + 'fr', // frame rate + 'v', // // Must include version + 'layers', // Must include layers + ]; + + // Semver regular expression + // https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string + final semVer = RegExp( + r'^(?0|[1-9]\d*)\.(?0|[1-9]\d*)\.(?0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$', + multiLine: true); + + @override + List get requiredImports => [ + 'package:lottie/lottie.dart', + ]; + + @override + String get classOutput => _classDefinition; + + final String _classDefinition = '''class LottieGenImage { + const LottieGenImage(this._assetName); + + final String _assetName; + + LottieBuilder lottie({ + Animation? controller, + bool? animate, + FrameRate? frameRate, + bool? repeat, + bool? reverse, + LottieDelegates? delegates, + LottieOptions? options, + void Function(LottieComposition)? onLoaded, + LottieImageProviderFactory? imageProviderFactory, + Key? key, + AssetBundle? bundle, + Widget Function(BuildContext, Widget, LottieComposition?)? frameBuilder, + ImageErrorWidgetBuilder? errorBuilder, + double? width, + double? height, + BoxFit? fit, + AlignmentGeometry? alignment, + String? package, + bool? addRepaintBoundary, + FilterQuality? filterQuality, + void Function(String)? onWarning, + }) { + return Lottie.asset( + _assetName, + animate: animate, + frameRate: frameRate, + repeat: repeat, + reverse: reverse, + delegates: delegates, + options: options, + onLoaded: onLoaded, + imageProviderFactory: imageProviderFactory, + key: key, + bundle: bundle, + frameBuilder: frameBuilder, + errorBuilder: errorBuilder, + width: width, + height: height, + fit: fit, + alignment: alignment, + package: package, + addRepaintBoundary: addRepaintBoundary, + filterQuality: filterQuality, + onWarning: onWarning, + ); + } + + String get path => _assetName; +}'''; + + @override + String get className => 'LottieGenImage'; + + @override + String classInstantiate(String path) => 'LottieGenImage(\'$path\')'; + + @override + bool isSupport(AssetType type) => isLottieFile(type); + + @override + bool get isConstConstructor => true; + + bool isLottieFile(AssetType type) { + try { + if (type.extension != '.json') { + return false; + } + String input = File(type.absolutePath).readAsStringSync(); + final fileKeys = jsonDecode(input) as Map; + if (lottieKeys.every((key) => fileKeys.containsKey(key)) && + fileKeys['v'] != null) { + var version = Version.parse(fileKeys['v']); + // Lottie version 4.4.0 is the first version that supports BodyMovin. + // https://github.com/xvrh/lottie-flutter/blob/0e7499d82ea1370b6acf023af570395bbb59b42f/lib/src/parser/lottie_composition_parser.dart#L60 + return version >= Version(4, 4, 0); + } + } on FormatException catch (e) { + // Catches bad/corrupted json and reports it to user. + stderr.writeln(e.message); + } + return false; + } +} diff --git a/packages/core/lib/settings/asset_type.dart b/packages/core/lib/settings/asset_type.dart index d40909505..0d21da451 100644 --- a/packages/core/lib/settings/asset_type.dart +++ b/packages/core/lib/settings/asset_type.dart @@ -4,7 +4,9 @@ import 'package:path/path.dart' as p; /// https://github.com/dart-lang/mime/blob/master/lib/src/default_extension_map.dart class AssetType { - AssetType(this.path); + AssetType(this.path, String rootPath) : absolutePath = p.join(rootPath, path); + + final String absolutePath; final String path; diff --git a/packages/core/lib/settings/config.dart b/packages/core/lib/settings/config.dart index 1d0912b8d..e17f2692c 100644 --- a/packages/core/lib/settings/config.dart +++ b/packages/core/lib/settings/config.dart @@ -51,6 +51,7 @@ flutter_gen: flutter_svg: false flare_flutter: false rive: false + lottie: false assets: enabled: true diff --git a/packages/core/lib/settings/pubspec.dart b/packages/core/lib/settings/pubspec.dart index 150b2b989..d9a213693 100644 --- a/packages/core/lib/settings/pubspec.dart +++ b/packages/core/lib/settings/pubspec.dart @@ -172,6 +172,7 @@ class FlutterGenIntegrations { required this.flutterSvg, required this.flareFlutter, required this.rive, + required this.lottie, }); @JsonKey(name: 'flutter_svg', required: true) @@ -183,6 +184,9 @@ class FlutterGenIntegrations { @JsonKey(name: 'rive', required: true) final bool rive; + @JsonKey(name: 'lottie', required: true) + final bool lottie; + factory FlutterGenIntegrations.fromJson(Map json) => _$FlutterGenIntegrationsFromJson(json); } diff --git a/packages/core/lib/settings/pubspec.g.dart b/packages/core/lib/settings/pubspec.g.dart index 4b96a1e1a..ad3b593c4 100644 --- a/packages/core/lib/settings/pubspec.g.dart +++ b/packages/core/lib/settings/pubspec.g.dart @@ -168,12 +168,18 @@ FlutterGenIntegrations _$FlutterGenIntegrationsFromJson(Map json) => ($checkedConvert) { $checkKeys( json, - requiredKeys: const ['flutter_svg', 'flare_flutter', 'rive'], + requiredKeys: const [ + 'flutter_svg', + 'flare_flutter', + 'rive', + 'lottie' + ], ); final val = FlutterGenIntegrations( flutterSvg: $checkedConvert('flutter_svg', (v) => v as bool), flareFlutter: $checkedConvert('flare_flutter', (v) => v as bool), rive: $checkedConvert('rive', (v) => v as bool), + lottie: $checkedConvert('lottie', (v) => v as bool), ); return val; }, diff --git a/packages/core/pubspec.yaml b/packages/core/pubspec.yaml index ea760dd7c..ec1ad1668 100644 --- a/packages/core/pubspec.yaml +++ b/packages/core/pubspec.yaml @@ -14,6 +14,7 @@ version_gen: path: lib/ dependencies: + lottie: '>=1.4.1 <2.0.0' path: '>=1.8.0 <2.0.0' yaml: '>=3.0.0 <4.0.0' mime: '>=1.0.0 <2.0.0' diff --git a/packages/core/test/assets_gen_integrations_test.dart b/packages/core/test/assets_gen_integrations_test.dart index f532f896b..3df6d7153 100644 --- a/packages/core/test/assets_gen_integrations_test.dart +++ b/packages/core/test/assets_gen_integrations_test.dart @@ -1,14 +1,16 @@ @TestOn('vm') import 'package:flutter_gen_core/generators/integrations/flare_integration.dart'; +import 'package:flutter_gen_core/generators/integrations/lottie_integration.dart'; import 'package:flutter_gen_core/generators/integrations/rive_integration.dart'; import 'package:flutter_gen_core/generators/integrations/svg_integration.dart'; import 'package:flutter_gen_core/settings/asset_type.dart'; +import 'package:path/path.dart' as p; import 'package:test/test.dart'; - import 'gen_test_helper.dart'; void main() { group('Test Assets Integration generator', () { + final resPath = p.absolute('test_resources'); test('Assets with No integrations on pubspec.yaml', () async { const pubspec = 'test_resources/pubspec_assets_no_integrations.yaml'; const fact = 'test_resources/actual_data/assets_no_integrations.gen.dart'; @@ -31,8 +33,10 @@ void main() { expect(integration.className, 'SvgGenImage'); expect(integration.classInstantiate('assets/path'), 'SvgGenImage(\'assets/path\')'); - expect(integration.isSupport(AssetType('assets/path/dog.svg')), isTrue); - expect(integration.isSupport(AssetType('assets/path/dog.png')), isFalse); + expect(integration.isSupport(AssetType('assets/path/dog.svg', resPath)), + isTrue); + expect(integration.isSupport(AssetType('assets/path/dog.png', resPath)), + isFalse); expect(integration.isConstConstructor, isTrue); }); @@ -49,8 +53,10 @@ void main() { expect(integration.className, 'FlareGenImage'); expect(integration.classInstantiate('assets/path'), 'FlareGenImage(\'assets/path\')'); - expect(integration.isSupport(AssetType('assets/path/dog.flr')), isTrue); - expect(integration.isSupport(AssetType('assets/path/dog.json')), isFalse); + expect(integration.isSupport(AssetType('assets/path/dog.flr', resPath)), + isTrue); + expect(integration.isSupport(AssetType('assets/path/dog.json', resPath)), + isFalse); expect(integration.isConstConstructor, isTrue); }); @@ -67,8 +73,34 @@ void main() { expect(integration.className, 'RiveGenImage'); expect(integration.classInstantiate('assets/path'), 'RiveGenImage(\'assets/path\')'); - expect(integration.isSupport(AssetType('assets/path/dog.riv')), isTrue); - expect(integration.isSupport(AssetType('assets/path/dog.json')), isFalse); + expect(integration.isSupport(AssetType('assets/path/dog.riv', resPath)), + isTrue); + expect(integration.isSupport(AssetType('assets/path/dog.json', resPath)), + isFalse); + expect(integration.isConstConstructor, isTrue); + }); + + test('Assets with Lottie integrations on pubspec.yaml', () async { + const pubspec = 'test_resources/pubspec_assets_lottie_integrations.yaml'; + const fact = + 'test_resources/actual_data/assets_lottie_integrations.gen.dart'; + const generated = + 'test_resources/lib/gen/assets_lottie_integrations.gen.dart'; + + await expectedAssetsGen(pubspec, generated, fact); + + final integration = LottieIntegration(); + expect(integration.className, 'LottieGenImage'); + expect(integration.classInstantiate('assets/lottie'), + 'LottieGenImage(\'assets/lottie\')'); + expect( + integration.isSupport( + AssetType('assets/lottie/hamburger_arrow.json', resPath)), + isTrue); + expect( + integration.isSupport(AssetType( + 'assets/lottie/hamburger_arrow_without_version.json', resPath)), + isFalse); expect(integration.isConstConstructor, isTrue); }); }); diff --git a/packages/core/test_resources/actual_data/assets_lottie_integrations.gen.dart b/packages/core/test_resources/actual_data/assets_lottie_integrations.gen.dart new file mode 100644 index 000000000..7e3864bc1 --- /dev/null +++ b/packages/core/test_resources/actual_data/assets_lottie_integrations.gen.dart @@ -0,0 +1,144 @@ +/// GENERATED CODE - DO NOT MODIFY BY HAND +/// ***************************************************** +/// FlutterGen +/// ***************************************************** + +// coverage:ignore-file +// ignore_for_file: type=lint +// ignore_for_file: directives_ordering,unnecessary_import + +import 'package:flutter/widgets.dart'; +import 'package:lottie/lottie.dart'; + +class $AssetsLottieGen { + const $AssetsLottieGen(); + + /// File path: assets/lottie/hamburger_arrow.json + LottieGenImage get hamburgerArrow => + const LottieGenImage('assets/lottie/hamburger_arrow.json'); +} + +class Assets { + Assets._(); + + static const $AssetsLottieGen lottie = $AssetsLottieGen(); +} + +class AssetGenImage { + const AssetGenImage(this._assetName); + + final String _assetName; + + Image image({ + Key? key, + AssetBundle? bundle, + ImageFrameBuilder? frameBuilder, + ImageErrorWidgetBuilder? errorBuilder, + String? semanticLabel, + bool excludeFromSemantics = false, + double? scale, + double? width, + double? height, + Color? color, + Animation? opacity, + BlendMode? colorBlendMode, + BoxFit? fit, + AlignmentGeometry alignment = Alignment.center, + ImageRepeat repeat = ImageRepeat.noRepeat, + Rect? centerSlice, + bool matchTextDirection = false, + bool gaplessPlayback = false, + bool isAntiAlias = false, + String? package, + FilterQuality filterQuality = FilterQuality.low, + int? cacheWidth, + int? cacheHeight, + }) { + return Image.asset( + _assetName, + key: key, + bundle: bundle, + frameBuilder: frameBuilder, + errorBuilder: errorBuilder, + semanticLabel: semanticLabel, + excludeFromSemantics: excludeFromSemantics, + scale: scale, + width: width, + height: height, + color: color, + opacity: opacity, + colorBlendMode: colorBlendMode, + fit: fit, + alignment: alignment, + repeat: repeat, + centerSlice: centerSlice, + matchTextDirection: matchTextDirection, + gaplessPlayback: gaplessPlayback, + isAntiAlias: isAntiAlias, + package: package, + filterQuality: filterQuality, + cacheWidth: cacheWidth, + cacheHeight: cacheHeight, + ); + } + + String get path => _assetName; + + String get keyName => _assetName; +} + +class LottieGenImage { + const LottieGenImage(this._assetName); + + final String _assetName; + + LottieBuilder lottie({ + Animation? controller, + bool? animate, + FrameRate? frameRate, + bool? repeat, + bool? reverse, + LottieDelegates? delegates, + LottieOptions? options, + void Function(LottieComposition)? onLoaded, + LottieImageProviderFactory? imageProviderFactory, + Key? key, + AssetBundle? bundle, + Widget Function(BuildContext, Widget, LottieComposition?)? frameBuilder, + ImageErrorWidgetBuilder? errorBuilder, + double? width, + double? height, + BoxFit? fit, + AlignmentGeometry? alignment, + String? package, + bool? addRepaintBoundary, + FilterQuality? filterQuality, + void Function(String)? onWarning, + }) { + return Lottie.asset( + _assetName, + animate: animate, + frameRate: frameRate, + repeat: repeat, + reverse: reverse, + delegates: delegates, + options: options, + onLoaded: onLoaded, + imageProviderFactory: imageProviderFactory, + key: key, + bundle: bundle, + frameBuilder: frameBuilder, + errorBuilder: errorBuilder, + width: width, + height: height, + fit: fit, + alignment: alignment, + package: package, + addRepaintBoundary: addRepaintBoundary, + filterQuality: filterQuality, + onWarning: onWarning, + ); + } + + String get path => _assetName; +} diff --git a/packages/core/test_resources/assets/lottie/hamburger_arrow.json b/packages/core/test_resources/assets/lottie/hamburger_arrow.json new file mode 100644 index 000000000..886cc5756 --- /dev/null +++ b/packages/core/test_resources/assets/lottie/hamburger_arrow.json @@ -0,0 +1 @@ +{"assets":[],"layers":[{"ddd":0,"ind":0,"ty":3,"nm":"Rotator","ks":{"o":{"k":0},"r":{"k":[{"i":{"x":[0.56],"y":[1]},"o":{"x":[0.634],"y":[0]},"n":["0p56_1_0p634_0"],"t":19,"s":[0],"e":[190.7]},{"i":{"x":[0.562],"y":[1]},"o":{"x":[0.398],"y":[0]},"n":["0p562_1_0p398_0"],"t":33,"s":[190.7],"e":[176.1]},{"i":{"x":[0.684],"y":[1]},"o":{"x":[0.31],"y":[0]},"n":["0p684_1_0p31_0"],"t":40.5,"s":[176.1],"e":[181.8]},{"i":{"x":[0.684],"y":[1]},"o":{"x":[0.438],"y":[0]},"n":["0p684_1_0p438_0"],"t":55,"s":[181.8],"e":[180]},{"i":{"x":[0.733],"y":[0.733]},"o":{"x":[0.385],"y":[0.385]},"n":["0p733_0p733_0p385_0p385"],"t":71,"s":[180],"e":[180]},{"i":{"x":[0.092],"y":[1]},"o":{"x":[0.406],"y":[0]},"n":["0p092_1_0p406_0"],"t":111,"s":[180],"e":[167.9]},{"i":{"x":[0.341],"y":[1]},"o":{"x":[0.6],"y":[0]},"n":["0p341_1_0p6_0"],"t":116,"s":[167.9],"e":[363]},{"i":{"x":[0.462],"y":[1]},"o":{"x":[0.167],"y":[0]},"n":["0p462_1_0p167_0"],"t":134,"s":[363],"e":[360]},{"t":141}]},"p":{"k":[200.5,149.375,0]},"a":{"k":[60,60,0]},"s":{"k":[100,100,100]}},"ao":0,"ip":0,"op":180,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":1,"ty":4,"nm":"A1","parent":0,"ks":{"o":{"k":100},"r":{"k":[{"i":{"x":[0.56],"y":[1]},"o":{"x":[0.634],"y":[0]},"n":["0p56_1_0p634_0"],"t":19,"s":[0],"e":[-45]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":33,"s":[-45],"e":[-45]},{"i":{"x":[0.341],"y":[1]},"o":{"x":[0.6],"y":[0]},"n":["0p341_1_0p6_0"],"t":116,"s":[-45],"e":[0]},{"t":134}]},"p":{"k":[{"i":{"x":0.56,"y":1},"o":{"x":0.634,"y":0},"n":"0p56_1_0p634_0","t":19,"s":[94.5,82.875,0],"e":[96.2,57.055,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0,"y":0},"o":{"x":0.167,"y":0.167},"n":"0_0_0p167_0p167","t":33,"s":[96.2,57.055,0],"e":[96.2,57.055,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.341,"y":1},"o":{"x":0.6,"y":0},"n":"0p341_1_0p6_0","t":116,"s":[96.2,57.055,0],"e":[94.5,82.875,0],"to":[0,0,0],"ti":[0,0,0]},{"t":134}]},"a":{"k":[35,22.25,0]},"s":{"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ks":{"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[-34,22.25],[35,22.25]],"c":false}},"nm":"Path 1"},{"ty":"st","fillEnabled":true,"c":{"k":[0.4,0.16,0.7,1]},"o":{"k":100},"w":{"k":10},"lc":1,"lj":1,"ml":4,"nm":"Stroke 1"},{"ty":"tr","p":{"k":[0,0],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Shape 1"},{"ty":"tm","s":{"k":[{"i":{"x":[0.56],"y":[1]},"o":{"x":[0.634],"y":[0]},"n":["0p56_1_0p634_0"],"t":19,"s":[0],"e":[26]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":33,"s":[26],"e":[26]},{"i":{"x":[0.341],"y":[1]},"o":{"x":[0.6],"y":[0]},"n":["0p341_1_0p6_0"],"t":116,"s":[26],"e":[0]},{"t":134}],"ix":1},"e":{"k":[{"i":{"x":[0.56],"y":[0.56]},"o":{"x":[0.634],"y":[0.634]},"n":["0p56_0p56_0p634_0p634"],"t":19,"s":[100],"e":[100]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":33,"s":[100],"e":[100]},{"i":{"x":[0.341],"y":[0.341]},"o":{"x":[0.6],"y":[0.6]},"n":["0p341_0p341_0p6_0p6"],"t":116,"s":[100],"e":[100]},{"t":134}],"ix":2},"o":{"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1"}],"ip":0,"op":180,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":2,"ty":4,"nm":"A2","parent":0,"ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[60,60.625,0]},"a":{"k":[0.5,0,0]},"s":{"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ks":{"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[-34,0],[35,0]],"c":false}},"nm":"Path 1"},{"ty":"st","fillEnabled":true,"c":{"k":[0.4,0.16,0.7,1]},"o":{"k":100},"w":{"k":10},"lc":1,"lj":1,"ml":4,"nm":"Stroke 1"},{"ty":"tr","p":{"k":[0,0],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Shape 1"}],"ip":0,"op":180,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":3,"ty":4,"nm":"A3","parent":0,"ks":{"o":{"k":100},"r":{"k":[{"i":{"x":[0.56],"y":[1]},"o":{"x":[0.634],"y":[0]},"n":["0p56_1_0p634_0"],"t":19,"s":[0],"e":[45]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":33,"s":[45],"e":[45]},{"i":{"x":[0.341],"y":[1]},"o":{"x":[0.6],"y":[0]},"n":["0p341_1_0p6_0"],"t":116,"s":[45],"e":[0]},{"t":134}]},"p":{"k":[{"i":{"x":0.56,"y":1},"o":{"x":0.634,"y":0},"n":"0p56_1_0p634_0","t":19,"s":[94.5,37.125,0],"e":[96.2,64.045,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0,"y":0},"o":{"x":0.167,"y":0.167},"n":"0_0_0p167_0p167","t":33,"s":[96.2,64.045,0],"e":[96.2,64.045,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.341,"y":1},"o":{"x":0.6,"y":0},"n":"0p341_1_0p6_0","t":116,"s":[96.2,64.045,0],"e":[94.5,37.125,0],"to":[0,0,0],"ti":[0,0,0]},{"t":134}]},"a":{"k":[35,-23.5,0]},"s":{"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ks":{"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[-34,-23.5],[35,-23.5]],"c":false}},"nm":"Path 1"},{"ty":"st","fillEnabled":true,"c":{"k":[0.4,0.16,0.7,1]},"o":{"k":100},"w":{"k":10},"lc":1,"lj":1,"ml":4,"nm":"Stroke 1"},{"ty":"tr","p":{"k":[0,0],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Shape 1"},{"ty":"tm","s":{"k":[{"i":{"x":[0.56],"y":[1]},"o":{"x":[0.634],"y":[0]},"n":["0p56_1_0p634_0"],"t":19,"s":[0],"e":[26]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":33,"s":[26],"e":[26]},{"i":{"x":[0.341],"y":[1]},"o":{"x":[0.6],"y":[0]},"n":["0p341_1_0p6_0"],"t":116,"s":[26],"e":[0]},{"t":134}],"ix":1},"e":{"k":[{"i":{"x":[0.56],"y":[0.56]},"o":{"x":[0.634],"y":[0.634]},"n":["0p56_0p56_0p634_0p634"],"t":19,"s":[100],"e":[100]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":33,"s":[100],"e":[100]},{"i":{"x":[0.341],"y":[0.341]},"o":{"x":[0.6],"y":[0.6]},"n":["0p341_0p341_0p6_0p6"],"t":116,"s":[100],"e":[100]},{"t":134}],"ix":2},"o":{"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1"}],"ip":0,"op":180,"st":0,"bm":0,"sr":1}],"v":"4.4.26","ddd":0,"ip":0,"op":180,"fr":30,"w":400,"h":300} \ No newline at end of file diff --git a/packages/core/test_resources/assets/lottie/hamburger_arrow_without_version.json b/packages/core/test_resources/assets/lottie/hamburger_arrow_without_version.json new file mode 100644 index 000000000..ffd074bcd --- /dev/null +++ b/packages/core/test_resources/assets/lottie/hamburger_arrow_without_version.json @@ -0,0 +1 @@ +{"assets":[],"layers":[{"ddd":0,"ind":0,"ty":3,"nm":"Rotator","ks":{"o":{"k":0},"r":{"k":[{"i":{"x":[0.56],"y":[1]},"o":{"x":[0.634],"y":[0]},"n":["0p56_1_0p634_0"],"t":19,"s":[0],"e":[190.7]},{"i":{"x":[0.562],"y":[1]},"o":{"x":[0.398],"y":[0]},"n":["0p562_1_0p398_0"],"t":33,"s":[190.7],"e":[176.1]},{"i":{"x":[0.684],"y":[1]},"o":{"x":[0.31],"y":[0]},"n":["0p684_1_0p31_0"],"t":40.5,"s":[176.1],"e":[181.8]},{"i":{"x":[0.684],"y":[1]},"o":{"x":[0.438],"y":[0]},"n":["0p684_1_0p438_0"],"t":55,"s":[181.8],"e":[180]},{"i":{"x":[0.733],"y":[0.733]},"o":{"x":[0.385],"y":[0.385]},"n":["0p733_0p733_0p385_0p385"],"t":71,"s":[180],"e":[180]},{"i":{"x":[0.092],"y":[1]},"o":{"x":[0.406],"y":[0]},"n":["0p092_1_0p406_0"],"t":111,"s":[180],"e":[167.9]},{"i":{"x":[0.341],"y":[1]},"o":{"x":[0.6],"y":[0]},"n":["0p341_1_0p6_0"],"t":116,"s":[167.9],"e":[363]},{"i":{"x":[0.462],"y":[1]},"o":{"x":[0.167],"y":[0]},"n":["0p462_1_0p167_0"],"t":134,"s":[363],"e":[360]},{"t":141}]},"p":{"k":[200.5,149.375,0]},"a":{"k":[60,60,0]},"s":{"k":[100,100,100]}},"ao":0,"ip":0,"op":180,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":1,"ty":4,"nm":"A1","parent":0,"ks":{"o":{"k":100},"r":{"k":[{"i":{"x":[0.56],"y":[1]},"o":{"x":[0.634],"y":[0]},"n":["0p56_1_0p634_0"],"t":19,"s":[0],"e":[-45]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":33,"s":[-45],"e":[-45]},{"i":{"x":[0.341],"y":[1]},"o":{"x":[0.6],"y":[0]},"n":["0p341_1_0p6_0"],"t":116,"s":[-45],"e":[0]},{"t":134}]},"p":{"k":[{"i":{"x":0.56,"y":1},"o":{"x":0.634,"y":0},"n":"0p56_1_0p634_0","t":19,"s":[94.5,82.875,0],"e":[96.2,57.055,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0,"y":0},"o":{"x":0.167,"y":0.167},"n":"0_0_0p167_0p167","t":33,"s":[96.2,57.055,0],"e":[96.2,57.055,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.341,"y":1},"o":{"x":0.6,"y":0},"n":"0p341_1_0p6_0","t":116,"s":[96.2,57.055,0],"e":[94.5,82.875,0],"to":[0,0,0],"ti":[0,0,0]},{"t":134}]},"a":{"k":[35,22.25,0]},"s":{"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ks":{"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[-34,22.25],[35,22.25]],"c":false}},"nm":"Path 1"},{"ty":"st","fillEnabled":true,"c":{"k":[0.4,0.16,0.7,1]},"o":{"k":100},"w":{"k":10},"lc":1,"lj":1,"ml":4,"nm":"Stroke 1"},{"ty":"tr","p":{"k":[0,0],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Shape 1"},{"ty":"tm","s":{"k":[{"i":{"x":[0.56],"y":[1]},"o":{"x":[0.634],"y":[0]},"n":["0p56_1_0p634_0"],"t":19,"s":[0],"e":[26]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":33,"s":[26],"e":[26]},{"i":{"x":[0.341],"y":[1]},"o":{"x":[0.6],"y":[0]},"n":["0p341_1_0p6_0"],"t":116,"s":[26],"e":[0]},{"t":134}],"ix":1},"e":{"k":[{"i":{"x":[0.56],"y":[0.56]},"o":{"x":[0.634],"y":[0.634]},"n":["0p56_0p56_0p634_0p634"],"t":19,"s":[100],"e":[100]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":33,"s":[100],"e":[100]},{"i":{"x":[0.341],"y":[0.341]},"o":{"x":[0.6],"y":[0.6]},"n":["0p341_0p341_0p6_0p6"],"t":116,"s":[100],"e":[100]},{"t":134}],"ix":2},"o":{"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1"}],"ip":0,"op":180,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":2,"ty":4,"nm":"A2","parent":0,"ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[60,60.625,0]},"a":{"k":[0.5,0,0]},"s":{"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ks":{"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[-34,0],[35,0]],"c":false}},"nm":"Path 1"},{"ty":"st","fillEnabled":true,"c":{"k":[0.4,0.16,0.7,1]},"o":{"k":100},"w":{"k":10},"lc":1,"lj":1,"ml":4,"nm":"Stroke 1"},{"ty":"tr","p":{"k":[0,0],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Shape 1"}],"ip":0,"op":180,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":3,"ty":4,"nm":"A3","parent":0,"ks":{"o":{"k":100},"r":{"k":[{"i":{"x":[0.56],"y":[1]},"o":{"x":[0.634],"y":[0]},"n":["0p56_1_0p634_0"],"t":19,"s":[0],"e":[45]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":33,"s":[45],"e":[45]},{"i":{"x":[0.341],"y":[1]},"o":{"x":[0.6],"y":[0]},"n":["0p341_1_0p6_0"],"t":116,"s":[45],"e":[0]},{"t":134}]},"p":{"k":[{"i":{"x":0.56,"y":1},"o":{"x":0.634,"y":0},"n":"0p56_1_0p634_0","t":19,"s":[94.5,37.125,0],"e":[96.2,64.045,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0,"y":0},"o":{"x":0.167,"y":0.167},"n":"0_0_0p167_0p167","t":33,"s":[96.2,64.045,0],"e":[96.2,64.045,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.341,"y":1},"o":{"x":0.6,"y":0},"n":"0p341_1_0p6_0","t":116,"s":[96.2,64.045,0],"e":[94.5,37.125,0],"to":[0,0,0],"ti":[0,0,0]},{"t":134}]},"a":{"k":[35,-23.5,0]},"s":{"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ks":{"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[-34,-23.5],[35,-23.5]],"c":false}},"nm":"Path 1"},{"ty":"st","fillEnabled":true,"c":{"k":[0.4,0.16,0.7,1]},"o":{"k":100},"w":{"k":10},"lc":1,"lj":1,"ml":4,"nm":"Stroke 1"},{"ty":"tr","p":{"k":[0,0],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Shape 1"},{"ty":"tm","s":{"k":[{"i":{"x":[0.56],"y":[1]},"o":{"x":[0.634],"y":[0]},"n":["0p56_1_0p634_0"],"t":19,"s":[0],"e":[26]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":33,"s":[26],"e":[26]},{"i":{"x":[0.341],"y":[1]},"o":{"x":[0.6],"y":[0]},"n":["0p341_1_0p6_0"],"t":116,"s":[26],"e":[0]},{"t":134}],"ix":1},"e":{"k":[{"i":{"x":[0.56],"y":[0.56]},"o":{"x":[0.634],"y":[0.634]},"n":["0p56_0p56_0p634_0p634"],"t":19,"s":[100],"e":[100]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":33,"s":[100],"e":[100]},{"i":{"x":[0.341],"y":[0.341]},"o":{"x":[0.6],"y":[0.6]},"n":["0p341_0p341_0p6_0p6"],"t":116,"s":[100],"e":[100]},{"t":134}],"ix":2},"o":{"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1"}],"ip":0,"op":180,"st":0,"bm":0,"sr":1}],"ddd":0,"ip":0,"op":180,"fr":30,"w":400,"h":300} \ No newline at end of file diff --git a/packages/core/test_resources/pubspec_assets_lottie_integrations.yaml b/packages/core/test_resources/pubspec_assets_lottie_integrations.yaml new file mode 100644 index 000000000..08e80a261 --- /dev/null +++ b/packages/core/test_resources/pubspec_assets_lottie_integrations.yaml @@ -0,0 +1,12 @@ +name: test + +flutter_gen: + output: lib/gen/ + line_length: 80 + + integrations: + lottie: true + +flutter: + assets: + - assets/lottie/hamburger_arrow.json