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.13k stars 197 forks source link

ValueDelegate.position can not change images #321

Closed cjl84914 closed 4 months ago

cjl84914 commented 7 months ago

data.json

{
  "v": "5.12.2",
  "fr": 30,
  "ip": 0,
  "op": 30,
  "w": 500,
  "h": 500,
  "nm": "合成 1",
  "ddd": 0,
  "assets": [
    {
      "id": "image_0",
      "w": 512,
      "h": 512,
      "u": "images/",
      "p": "img_0.jpg",
      "e": 0
    }
  ],
  "layers": [
    {
      "ddd": 0,
      "ind": 1,
      "ty": 2,
      "nm": "logo",
      "refId": "image_0",
      "sr": 1,
      "ks": {
        "o": {
          "a": 0,
          "k": 100,
          "ix": 11
        },
        "r": {
          "a": 0,
          "k": 0,
          "ix": 10
        },
        "p": {
          "a": 0,
          "k": [
            382,
            104,
            0
          ],
          "ix": 2,
          "l": 2
        },
        "a": {
          "a": 0,
          "k": [
            256,
            256,
            0
          ],
          "ix": 1,
          "l": 2
        },
        "s": {
          "a": 0,
          "k": [
            25.781,
            25.781,
            100
          ],
          "ix": 6,
          "l": 2
        }
      },
      "ao": 0,
      "ip": 0,
      "op": 30,
      "st": 0,
      "bm": 0
    }
  ],
  "markers": [],
  "props": {}
}

flutter code:

class _AnimationState2 extends State<_Animation2> {
  @override
  Widget build(BuildContext context) {
    return Lottie.asset(
      'assets/bodymovin/data.json',
      delegates: LottieDelegates(
        text: (initialText) => '**$initialText**',
        values: [
          ValueDelegate.position(
            const ['logo', '**'],
            relative: const Offset(120, 400),
          ),
        ],
      ),
    );
  }
}