[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-9391":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":17,"stars30d":17,"stars90d":16,"forks30d":16,"starsTrendScore":17,"compositeScore":18,"rankGlobal":10,"rankLanguage":10,"license":19,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":22,"hasPages":22,"topics":23,"createdAt":10,"pushedAt":10,"updatedAt":32,"readmeContent":33,"aiSummary":34,"trendingCount":16,"starSnapshotCount":16,"syncStatus":17,"lastSyncTime":35,"discoverSource":36},9391,"lottie-flutter","xvrh\u002Flottie-flutter","xvrh","Render After Effects animations natively on Flutter. This package is a pure Dart implementation of a Lottie player.","https:\u002F\u002Fpub.dev\u002Fpackages\u002Flottie",null,"Dart",1283,220,7,137,0,2,56.23,"MIT License",false,"master",true,[24,25,26,27,28,29,30,31],"dart","flutter","flutter-web","flutter-widget","lottie","lottie-android","lottie-animation","widget","2026-06-11 04:03:18","# Lottie for Flutter\n\n[![](https:\u002F\u002Fgithub.com\u002Fxvrh\u002Flottie-flutter\u002Fworkflows\u002FLottie%20Flutter\u002Fbadge.svg?branch=master)](https:\u002F\u002Fgithub.com\u002Fxvrh\u002Flottie-flutter)\n[![pub package](https:\u002F\u002Fimg.shields.io\u002Fpub\u002Fv\u002Flottie.svg)](https:\u002F\u002Fpub.dev\u002Fpackages\u002Flottie)\n\nLottie is a mobile library for Android and iOS that parses [Adobe After Effects](https:\u002F\u002Fwww.adobe.com\u002Fproducts\u002Faftereffects.html) \nanimations exported as json with [Bodymovin](https:\u002F\u002Fgithub.com\u002Fairbnb\u002Flottie-web) and renders them natively on mobile!\n\nThis repository is an unofficial conversion of the [Lottie-android](https:\u002F\u002Fgithub.com\u002Fairbnb\u002Flottie-android) library in pure Dart. \n\nIt works on Android, iOS, macOS, linux, windows and web.\n\n\u003Ca href=\"https:\u002F\u002Fwww.buymeacoffee.com\u002Fxvrh\" target=\"_blank\">\u003Cimg src=\"https:\u002F\u002Fcdn.buymeacoffee.com\u002Fbuttons\u002Fv2\u002Fdefault-yellow.png\" alt=\"Buy Me A Coffee\" height=\"60\" width=\"217\">\u003C\u002Fa>\n\n## Usage\n\n### Simple animation\nThis example shows how to display a Lottie animation in the simplest way.  \nThe `Lottie` widget will load the json file and run the animation indefinitely.\n\n```dart\nimport 'package:flutter\u002Fmaterial.dart';\nimport 'package:lottie\u002Flottie.dart';\n\nvoid main() => runApp(const MyApp());\n\nclass MyApp extends StatelessWidget {\n  const MyApp({super.key});\n\n  @override\n  Widget build(BuildContext context) {\n    return MaterialApp(\n      home: Scaffold(\n        body: ListView(\n          children: [\n            \u002F\u002F Load a Lottie file from your assets\n            Lottie.asset('assets\u002FLottieLogo1.json'),\n\n            \u002F\u002F Load a Lottie file from a remote url\n            Lottie.network(\n              'https:\u002F\u002Fraw.githubusercontent.com\u002Fxvrh\u002Flottie-flutter\u002Fmaster\u002Fexample\u002Fassets\u002FMobilo\u002FA.json',\n            ),\n\n            \u002F\u002F Load an animation and its images from a zip file\n            Lottie.asset('assets\u002Flottiefiles\u002Fangel.zip'),\n          ],\n        ),\n      ),\n    );\n  }\n}\n```\n\n### Specify a custom `AnimationController`\nThis example shows how to take full control over the animation by providing your own `AnimationController`.\n\nWith a custom `AnimationController` you have a rich API to play the animation in various ways: start and stop the animation when you want,\n play forward or backward, loop between specifics points...  \n\n```dart\nimport 'package:flutter\u002Fmaterial.dart';\nimport 'package:lottie\u002Flottie.dart';\n\nvoid main() => runApp(const MyApp());\n\nclass MyApp extends StatefulWidget {\n  const MyApp({super.key});\n\n  @override\n  State\u003CMyApp> createState() => _MyAppState();\n}\n\nclass _MyAppState extends State\u003CMyApp> with TickerProviderStateMixin {\n  late final AnimationController _controller;\n\n  @override\n  void initState() {\n    super.initState();\n\n    _controller = AnimationController(vsync: this);\n  }\n\n  @override\n  void dispose() {\n    _controller.dispose();\n    super.dispose();\n  }\n\n  @override\n  Widget build(BuildContext context) {\n    return MaterialApp(\n      home: Scaffold(\n        body: ListView(\n          children: [\n            Lottie.asset(\n              'assets\u002FLottieLogo1.json',\n              controller: _controller,\n              onLoaded: (composition) {\n                \u002F\u002F Configure the AnimationController with the duration of the\n                \u002F\u002F Lottie file and start the animation.\n                _controller\n                  ..duration = composition.duration\n                  ..forward();\n              },\n            ),\n          ],\n        ),\n      ),\n    );\n  }\n}\n```\n\n[See this file](https:\u002F\u002Fgithub.com\u002Fxvrh\u002Flottie-flutter\u002Fblob\u002Fmaster\u002Fexample\u002Flib\u002Fexamples\u002Fanimation_full_control.dart) for a more comprehensive example.\n\n### Control the size of the Widget\nThe `Lottie` widget takes the same arguments and have the same behavior as the `Image` widget\nin term of controlling its size.\n```dart\nLottie.asset(\n  'assets\u002FLottieLogo1.json',\n  width: 200,\n  height: 200,\n  fit: BoxFit.fill,\n)\n```\n\n`width` and `height` are optionals and fallback on the size imposed by the parent or on the intrinsic size of the lottie \nanimation.\n\n### Custom loading\nThe `Lottie` widget has several convenient constructors (`Lottie.asset`, `Lottie.network`, `Lottie.memory`) to load, parse and\ncache automatically the json file.\n\nSometime you may prefer to have full control over the loading of the file. Use `AssetLottie` (or `NetworkLottie`, `MemoryLottie`) to load a lottie composition from a json file.\n\nThis example shows how to load and parse a Lottie composition from a json file.  \n\n```dart\nclass MyWidget extends StatefulWidget {\n  const MyWidget({super.key});\n\n  @override\n  State\u003CMyWidget> createState() => _MyWidgetState();\n}\n\nclass _MyWidgetState extends State\u003CMyWidget> {\n  late final Future\u003CLottieComposition> _composition;\n\n  @override\n  void initState() {\n    super.initState();\n\n    _composition = AssetLottie('assets\u002FLottieLogo1.json').load();\n  }\n\n  @override\n  Widget build(BuildContext context) {\n    return FutureBuilder\u003CLottieComposition>(\n      future: _composition,\n      builder: (context, snapshot) {\n        var composition = snapshot.data;\n        if (composition != null) {\n          return Lottie(composition: composition);\n        } else {\n          return const Center(child: CircularProgressIndicator());\n        }\n      },\n    );\n  }\n}\n```\n\n### Custom drawing\nThis example goes low level and shows you how to draw a `LottieComposition` on a custom Canvas at a specific frame in \na specific position and size.\n\n````dart\nclass CustomDrawer extends StatelessWidget {\n  final LottieComposition composition;\n\n  const CustomDrawer(this.composition, {super.key});\n\n  @override\n  Widget build(BuildContext context) {\n    return CustomPaint(\n      painter: _Painter(composition),\n      size: const Size(400, 400),\n    );\n  }\n}\n\nclass _Painter extends CustomPainter {\n  final LottieDrawable drawable;\n\n  _Painter(LottieComposition composition)\n    : drawable = LottieDrawable(composition);\n\n  @override\n  void paint(Canvas canvas, Size size) {\n    var frameCount = 40;\n    var columns = 10;\n    for (var i = 0; i \u003C frameCount; i++) {\n      var destRect = Offset(i % columns * 50.0, i ~\u002F 10 * 80.0) & (size \u002F 5);\n      drawable\n        ..setProgress(i \u002F frameCount)\n        ..draw(canvas, destRect);\n    }\n  }\n\n  @override\n  bool shouldRepaint(CustomPainter oldDelegate) {\n    return true;\n  }\n}\n````\n\n### Modify properties at runtime\nThis example shows how to modify some properties of the animation at runtime. Here we change the text,\nthe color, the opacity and the position of some layers.\nFor each `ValueDelegate` we can either provide a static `value` or a `callback` to compute a value for a each frame.\n\n````dart\nclass _Animation extends StatelessWidget {\n  @override\n  Widget build(BuildContext context) {\n    return Lottie.asset(\n      'assets\u002FTests\u002FShapes.json',\n      delegates: LottieDelegates(\n        text: (initialText) => '**$initialText**',\n        values: [\n          ValueDelegate.color(const [\n            'Shape Layer 1',\n            'Rectangle',\n            'Fill 1',\n          ], value: Colors.red),\n          ValueDelegate.opacity(\n            const ['Shape Layer 1', 'Rectangle'],\n            callback: (frameInfo) => (frameInfo.overallProgress * 100).round(),\n          ),\n          ValueDelegate.position(const [\n            'Shape Layer 1',\n            'Rectangle',\n            '**',\n          ], relative: const Offset(100, 200)),\n        ],\n      ),\n    );\n  }\n}\n````\n\n### Frame rate\nBy default, the animation is played at the frame rate exported by AfterEffect.\nThis is the most power-friendly as generally the animation is exported at 10 or 30 FPS compared to the phone's 60 or 120 FPS.\nIf the result is not good, you can change the frame rate\n\n````dart\nLottie.asset('anim.json',\n  \u002F\u002F Use the device frame rate (up to 120FPS)\n  frameRate: FrameRate.max,\n  \u002F\u002F Use the exported frame rate (default)\n  frameRate: FrameRate.composition,\n  \u002F\u002F Specific frame rate\n  frameRate: FrameRate(10),\n)\n````\n\n### Telegram Stickers (.tgs) and DotLottie (.lottie)\nTGS file can be loaded by providing a special decoder\n\n````dart\nWidget build(BuildContext context) {\n  return ListView(\n    children: [\n      Lottie.network(\n        'https:\u002F\u002Ftelegram.org\u002Ffile\u002F464001484\u002F1\u002Fbzi7gr7XRGU.10147\u002F815df2ef527132dd23',\n        decoder: LottieComposition.decodeGZip,\n      ),\n      Lottie.asset(\n        'assets\u002FLightningBug_file.tgs',\n        decoder: LottieComposition.decodeGZip,\n      ),\n    ],\n  );\n}\n````\n\nYou can select the correct .json file from a dotlottie (.lottie) archive by providing a custom decoder\n\n````dart\nclass Example extends StatelessWidget {\n  const Example({super.key});\n\n  @override\n  Widget build(BuildContext context) {\n    return Lottie.asset('assets\u002Fcat.lottie', decoder: customDecoder);\n  }\n}\n\nFuture\u003CLottieComposition?> customDecoder(List\u003Cint> bytes) {\n  return LottieComposition.decodeZip(\n    bytes,\n    filePicker: (files) {\n      return files.firstWhereOrNull(\n        (f) => f.name.startsWith('animations\u002F') && f.name.endsWith('.json'),\n      );\n    },\n  );\n}\n````\n\n## Performance or excessive CPU\u002FGPU usage\n\nVersion `v3.0` introduced the `renderCache` parameter to help reduce an excessive energy consumption.\n\nIn this mode, the frames of the animation are rendered lazily in an offscreen cache. Subsequent runs of the animation \nare cheaper to render. It helps reduce the power usage of the application at the cost of an increased memory usage.\n\n## Limitations\nThis port supports the same [feature set as Lottie Android](https:\u002F\u002Fairbnb.io\u002Flottie\u002F#\u002Fsupported-features).\n\n## Flutter Web\nRun the app with `flutter run -d chrome --web-renderer canvaskit`\n\nSee a preview here: https:\u002F\u002Fxvrh.github.io\u002Flottie-flutter-web\u002F\n\n## More examples\nSee the `example` folder for more code samples of the various possibilities.\n","lottie-flutter 是一个用于在 Flutter 应用中渲染 Adobe After Effects 动画的库。它通过纯 Dart 语言实现了 Lottie 播放器的功能，支持加载本地或远程 JSON 格式的动画文件，并且可以在 Android、iOS、macOS、Linux、Windows 和 Web 平台上运行。该项目允许开发者使用自定义的 `AnimationController` 来精确控制动画播放行为，如开始、停止、循环等，从而为应用添加丰富且流畅的动画效果。适用于需要高质量动画但又希望保持轻量级和跨平台一致性的移动应用开发场景。","2026-06-11 03:22:27","top_language"]