Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to flutter lottie animation in flutter app?

I want to animate the Lottie file in the flutter app. I tried searching every corner of the internet and failed to find any info on it.

I found out that there is a flutter package "flutter_lottie.dart" and has a function to animate.

There is also an example provided by the author about the usage of the flutter_lottie.dart

but this I tried running the exact example : flutter Lottie example

and it gave the same error:

Creating Method Channel convictiontech/flutter_lottie_0
E/flutter (11371): [ERROR:flutter/shell/common/shell.cc(199)] Dart Error: Unhandled exception:
E/flutter (11371): PlatformException(error, java.lang.IllegalStateException: Unable to parse 
composition
E/flutter (11371):  at com.airbnb.lottie.LottieAnimationView$2.onResult(LottieAnimationView.java:68)

How to use animate using Lottie in flutter?

like image 401
rahul Kushwaha Avatar asked Feb 04 '23 16:02

rahul Kushwaha


1 Answers

The lottie package is a pure Flutter/Dart implementation of a Lottie Player.
It is a direct port of Lottie-Android and support the same set of features.

Include this in your pubspec.yaml

dependencies:
  lottie:
import 'package:flutter/material.dart';
import 'package:lottie/lottie.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Lottie.asset('assets/lottiefile.json'),
      ),
    );
  }
}

Pub: https://pub.dev/packages/lottie
Github: https://github.com/xvrh/lottie-flutter

like image 181
Xavier Avatar answered Feb 08 '23 15:02

Xavier