xvrh / lottie-flutter

Render After Effects animations natively on Flutter. This package is a pure Dart implementation of a Lottie player.
https://pub.dev/packages/lottie
MIT License
1.15k stars 197 forks source link

errro 'Null check operator used on a null value' #270

Closed k2s closed 1 year ago

k2s commented 1 year ago

Attached json works on https://lottiefiles.github.io/lottie-docs/playground/json_editor/ Faiils in lottie-flutter with error Null check operator used on a null value

{
  "layers": [
    {
      "ddd": 0,
      "ty": 4,
      "ind": 0,
      "sr": 1,
      "ip": 0,
      "op": 180,
      "st": 0,
      "ks": {
        "a": {
          "k": [
            0,
            0
          ],
          "a": 0
        },
        "p": {
          "k": [
            0,
            0
          ],
          "a": 0
        },
        "s": {
          "k": [
            100,
            100
          ],
          "a": 0
        },
        "r": {
          "k": 0,
          "a": 0
        },
        "o": {
          "k": 100,
          "a": 0
        },
        "sk": {
          "k": 0,
          "a": 0
        },
        "sa": {
          "k": 0,
          "a": 0
        }
      },
      "ao": 0,
      "bm": 0,
      "shapes": [
        {
          "ty": "gr",
          "it": [
            {
              "ty": "sh",
              "d": 1,
              "ks": {
                "k": {
                  "c": false,
                  "i": [
                    [
                      0,
                      0
                    ],
                    [
                      32,
                      -32
                    ],
                    [
                      -64,
                      -64
                    ],
                    [
                      64,
                      64
                    ]
                  ],
                  "o": [
                    [
                      64,
                      64
                    ],
                    [
                      -32,
                      32
                    ],
                    [
                      -64,
                      64
                    ],
                    [
                      0,
                      0
                    ]
                  ],
                  "v": [
                    [
                      256,
                      128
                    ],
                    [
                      256,
                      376
                    ],
                    [
                      256,
                      256
                    ],
                    [
                      128,
                      376
                    ]
                  ]
                },
                "a": 0
              }
            },
            {
              "ty": "st",
              "lc": 2,
              "lj": 2,
              "ml": 0,
              "o": {
                "k": 100,
                "a": 0
              },
              "w": {
                "k": 5,
                "a": 0
              },
              "c": {
                "k": [
                  1,
                  0,
                  0,
                  1
                ],
                "a": 0
              }
            },
            {
              "ty": "tr",
              "a": {
                "k": [
                  0,
                  0
                ],
                "a": 0
              },
              "p": {
                "k": [
                  0,
                  0
                ],
                "a": 0
              },
              "s": {
                "k": [
                  100,
                  100
                ],
                "a": 0
              },
              "r": {
                "k": 0,
                "a": 0
              },
              "o": {
                "k": 100,
                "a": 0
              },
              "sk": {
                "k": 0,
                "a": 0
              },
              "sa": {
                "k": 0,
                "a": 0
              }
            }
          ]
        },
        {
          "ty": "tm",
          "s": {
            "k": 0,
            "a": 0
          },
          "e": {
            "k": 50,
            "a": 0
          },
          "o": {
            "a": 1,
            "k": [
              {
                "t": 0,
                "i": {
                  "x": [
                    1
                  ],
                  "y": [
                    1
                  ]
                },
                "o": {
                  "x": [
                    0
                  ],
                  "y": [
                    0
                  ]
                },
                "s": [
                  0
                ],
                "e": [
                  360
                ]
              },
              {
                "t": 180,
                "s": [
                  360
                ]
              }
            ]
          }
        }
      ]
    }
  ],
  "v": "5.5.2",
  "fr": 60,
  "ip": 0,
  "op": 180,
  "w": 968,
  "h": 1090,
  "ddd": 0,
  "assets": []
}

That file was generated with python-lottie:

import sys
import os
sys.path.insert(0, os.path.join(
   os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
   "lib"
))
from lottie.utils import script
from lottie import objects
from lottie.utils import animation as anutils
from lottie import Point, Color
from lottie.exporters.core import export_lottie

an = objects.Animation(180)
an.width = 968
an.height = 1090

layer = objects.ShapeLayer()
an.add_layer(layer)

group = layer.add_shape(objects.Group())
bez = group.add_shape(objects.Path())
bez.shape.value.add_point(Point(256, 128), Point(0, 0), Point(64, 64))
bez.shape.value.add_smooth_point(Point(256, 256+120), Point(32, -32))
bez.shape.value.add_point(Point(256, 256), Point(-64, -64), Point(-64, 64))
bez.shape.value.add_point(Point(128, 256+120), Point(64, 64), Point(0, 0))
group.add_shape(objects.Stroke(Color(1, 0, 0), 5))

trim = layer.add_shape(objects.Trim())
trim.offset.add_keyframe(0, 0)
trim.offset.add_keyframe(180, 360)
trim.start.value = 0
trim.end.value = 50

lottie_filename = os.path.join(
 os.path.dirname(os.path.abspath(__file__)),
 "assets/lottie.json")

export_lottie(an, lottie_filename)
xvrh commented 1 year ago

Should be fixed in v2.3.1. Let me know if there is still a problem.

k2s commented 1 year ago

it works now. thank you

gfb-47 commented 1 year ago

I'm having the same issue..

xvrh commented 1 year ago

@gfb-47 can you send your animation?

gfb-47 commented 1 year ago

https://drive.google.com/file/d/1fuygYZNcGhYW7iRWXNI_VRSYxL5BJ0Pw/view?usp=sharing

xvrh commented 1 year ago

@gfb-47 this is fixed with version 2.4.0

gfb-47 commented 1 year ago

you rock