GithubHelp home page GithubHelp logo

load from json object about lottie-flutter HOT 4 CLOSED

xvrh avatar xvrh commented on July 26, 2024
load from json object

from lottie-flutter.

Comments (4)

sultanmyrza avatar sultanmyrza commented on July 26, 2024

Could not find exmaple for
Lottie.file(file)
can you please provide one

from lottie-flutter.

xvrh avatar xvrh commented on July 26, 2024

Hi, thanks for your interest in this library

There is the LottieComposition.fromBytes getter that allows to load a lottie composition from a list of bytes (loaded from the network for instance).

  Future<LottieComposition> _loadComposition() async {
    var response = await get('<url>'); // from the "http" library
    return LottieComposition.fromBytes(response.bodyBytes);
  }

And you display the LottieComposition with the Lottie constructor:

  @override
  Widget build(BuildContext context) {
    return FutureBuilder<LottieComposition>(
      future: _futureComposition,
      builder: (context, snapshot) {
        if (snapshot.hasError) return ErrorWidget(snapshot.error);
        if (snapshot.data == null) return CircularProgressIndicator();
        return Lottie(composition: snapshot.data);
      },
    );
  }

Also there is the Lottie.memory constructor that may help you.

The Lottie.file is very easy to use.
There is this example that saves and load lottie animation to files in a "temp" directory.

from lottie-flutter.

sultanmyrza avatar sultanmyrza commented on July 26, 2024

Thank you. It's working now.

In my app user can choose subject
it opens subject page which loads lottie files from remote(in avarage 10-15 lottie files)
and user can swipe left right to see lottie animations

one problem is
first animations start from beginning
but when user swipe to next,prev animation it starts not from beginning

there is a way to start from beginning right?

By the way any tips to optimize loading and playing lottie files?

from lottie-flutter.

xvrh avatar xvrh commented on July 26, 2024

The recommendation is to use a custom AnimationController to have full control on how to run the animation.

from lottie-flutter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.