Search code examples
flutteranimated-gif

Using an animated gif in flutter


I have an animated gif in my assets folder. I want to use it on my app login page but How? I used this code:

          Image.asset(
            "login.gif",
            height: 125.0,
            width: 125.0,
          ),

but it is not doing any thing.

this is the error:

I/flutter (31581): The following assertion was thrown resolving an image codec: I/flutter (31581): Unable to load asset: login.gif


Solution

  • You have to give the relative path of the gif from assets not just the file name.

    Try this..

    Image.asset('assets/login.gif', width: 15.0, height: 15.0)
    

    Also make sure that you have mentioned it in your pubspec.yaml.