Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The lottie files downloaded from lottiefiles can not render #342

Open
OpenJarvisAI opened this issue Apr 10, 2024 · 19 comments
Open

The lottie files downloaded from lottiefiles can not render #342

OpenJarvisAI opened this issue Apr 10, 2024 · 19 comments

Comments

@OpenJarvisAI
Copy link

image image

Why??

@xvrh xvrh added the need-info label Apr 10, 2024
@Domestositos
Copy link

A similar problem occurs when using Lottie.asset. The animation I'm using: https://lottie.host/34058a8b-b777-412c-9dd2-dcd31d035e2b/Dt6WZU5Wu7.json
Expected Outcome:
anination
What's happening:
current

The lottie version:
lottie: ^3.1.0

@tkc-alien
Copy link

tkc-alien commented Apr 15, 2024

Same issue.

My Flutter version is 3.19.5,
lottie is 3.1.0 (and I also tried 2.7.0 with the same results).

Expected: https://lottiefiles.com/animations/restaurant-website-pre-loader-YposeqGL8Q
expected

But rendered:

@huangfengjing
Copy link

me too!

lottie: ^3.1.0

Flutter 3.19.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 300451adae (3 weeks ago) • 2024-03-27 21:54:07 -0500
Engine • revision e76c956498
Tools • Dart 3.3.3 • DevTools 2.31.1

@xvrh
Copy link
Owner

xvrh commented Apr 21, 2024

Can anyone provide a reproducible example?

  • A link to the json file
  • A minimal dart program (to see the parameters used).
  • The flutter version used
  • Whether this is in release, profile or debug mode
  • Whether this on a native app or a web app
  • The list of phone models were this is reproduced

I've tried the example from here #342 (comment) on 5 differents phones and various flutter version but it doesn't reproduce. So there is something I'm missing.

@Abdo-Nabil
Copy link

Abdo-Nabil commented Apr 21, 2024

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

class CustomCircularProgressIndicator extends StatelessWidget {
  final Color? color;
  const CustomCircularProgressIndicator({this.color, Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Lottie.asset(
        "assets/jsons/loading_animation2.json",
        height: 100,
        width: 100,
      ),
    );
  }
}
  • Flutter Version Used:
Flutter 3.19.5 • channel stable • https://github.com/flutter/flutter.git 
Framework • revision 300451adae (4 weeks ago) • 2024-03-27 21:54:07 -0500
Engine • revision e76c956498                                             
Tools • Dart 3.3.3 • DevTools 2.31.1  
  • lottie: ^3.1.0
  • In debug mode
  • In native flutter app (in android, I didn't test on IOS)

Phones:

  • Realme 11 (Android 13) as a physical device
  • Emulator (API 30)

@xvrh

@xvrh
Copy link
Owner

xvrh commented Apr 21, 2024

@Abdo-Nabil thanks. Can you put the .json link or directly the json content here. That lottiefiles link doesn't work for me.

@Abdo-Nabil
Copy link

Abdo-Nabil commented Apr 21, 2024

@xvrh
Copy link
Owner

xvrh commented Apr 21, 2024

@Abdo-Nabil your animation indeed renders incorrectly compared to the web version.
But it also render badly on the native iOS Lottie library and Android Lottie library (I tested on the Lottie and Lottiefiles app from the stores).
My guess is that your animation uses some features that are not supported by all runtimes: https://lottiefiles.com/supported-features.

@Abdo-Nabil
Copy link

@xvrh Thanks for your interest, so the problem in some of the animations that are not fully supported by the package....right?

@xvrh
Copy link
Owner

xvrh commented Apr 22, 2024

@Abdo-Nabil in your case, yes. This Flutter library but also the Android and iOS library.

@OpenJarvisAI
Copy link
Author

My case looks like not, the json without color modification works normal, but changed color abnormal

@Domestositos
Copy link

Domestositos commented Apr 22, 2024

JSON code in default animation and JSON code in animation with changed color or other parameters are very different. It is quite possible that during editing functions that are not supported by the package are added to the code.
JSON default:
lottie default.json
JSON with changed color:
lottie with changed color.json

@mendoxe
Copy link

mendoxe commented Apr 28, 2024

I have the exact same issue, any updates?

@Abdo-Nabil
Copy link

@mendoxe May be you need to select another animation

@mendoxe
Copy link

mendoxe commented Apr 28, 2024

I have tried 6 files and 2 dotfiles, all of them have the same problem (they look distorted).

No settings applied

LottieBuilder.asset(_selectedCategory.lottie)

Lottie: 3.1.0

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.19.6, on macOS 14.4.1 23E224 darwin-arm64,
locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version
34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.1)
[✓] VS Code (version 1.88.1)
[✓] Connected device (5 available)

@Abdo-Nabil

@afradahsan
Copy link

I'm also facing a similar issue.

Expected output:
Animation - 1715507778152

Output on flutter app:
lv_0_20240512181545

I'm using an android emulator (not working on a physical device as well). Currently on the latest version of flutter. Tried downgrading the lottie package but didn't work.

If anyone has got a solution/workaround, please share.

@Domestositos
Copy link

@Abdo-Nabil in your case, yes. This Flutter library but also the Android and iOS library.

Is work underway to address this issue?

@afradahsan
Copy link

Guys, I've just found a temporary workaround for the issue, the issue basically arises whenever you're using a custom-colored JSON file. Instead, download the original file, and manually edit the JSON file to change the color.

How to edit:

In a lottie file this is how color is structured:
{ "ty": "fl", "nm": "Fill", "o": { "a": 0, "k": 100 }, "c": { "a": 0, "k": [ 0.710, 0.192, 0.278 ] }, "r": 1 }

  • So, open the json in your code editor and find the "Fill" objects within the "shapes" section of each shape group. These objects define the fill color for each shape.

  • Within each "Fill" object, locate the "c" property, which represents the color. It will be an array of RGB values expressed as fractions between 0 and 1.

  • Modify the RGB values to change the color. For example, if you want to change the color to red, you can set the RGB values to [1, 0, 0]. If you want to change it to blue, you can set the RGB values to [0, 0, 1].

  • If you notice the value of rgb will be all values less than, so to achieve a color, for eg:- RGB(207, 248, 11, 1), you gotta divide each value by 255:
    R: 207 / 255 ≈ 0.8118
    G: 248 / 255 ≈ 0.9725
    B: 11 / 255 ≈ 0.0431

  • You got to apply it to each color that you want to change and then just use the file.

The above steps actually worked for me, thanks to gpt for breaking the json down.

@hmartiins
Copy link

Same issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants