简体   繁体   English

flare_flutter animation 显示问题

[英]flare_flutter animation display issues

The issue is the animation can't be displayed but only image can be shown.问题是 animation 无法显示,但只能显示图像。 There is only part of code about BottomAnimeLoader right here.这里只有关于 BottomAnimeLoader 的部分代码。 So please help me figure what's happen why only the static image is right here.所以请帮我弄清楚为什么只有 static 图像就在这里。 (using flutter framework and dart language) (使用flutter框架和dart语言)

the animation is static animation 是 static

import 'package:flare_flutter/flare_actor.dart';
import 'package:flutter/material.dart';

class BottomAnimeLoader extends StatefulWidget {
  @override
  _BottomAnimeLoaderState createState() => _BottomAnimeLoaderState();
}

class _BottomAnimeLoaderState extends State<BottomAnimeLoader> {
  String _animationName = "new";
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        mainAxisSize: MainAxisSize.min,
        children: [
          Expanded(
              child: FlareActor(
            "assets/flr/success.flr",
            fit: BoxFit.contain,
            alignment: Alignment.center,
            animation: _animationName,
          ))
        ],
      ),
    );
  }
}

I use the official example's flr file to simulate this case because I do not have your flr file我用官方例子的flr文件来模拟这种情况,因为我没有你的flr文件
If you have wrong _animationName name, then it will become static image如果_animationName名称有误,则会变成 static 图像
In official example, the _animationName is idle , if I change it to new it will become static image在官方示例中, _animationNameidle ,如果我将其更改为new它将成为 static 图像
Please correct your _animationName , for example the following https://rive.app/a/pollux/files/flare/success-check _animationName is Untitled请更正您的_animationName ,例如以下https://rive.app/a/pollux/files/flare/success-check _animationName is Untitled

在此处输入图像描述

working demo工作演示

在此处输入图像描述

full test code完整的测试代码

import 'package:flutter/material.dart';
import 'package:flare_flutter/flare_actor.dart';

class BottomAnimeLoader extends StatefulWidget {
  @override
  _BottomAnimeLoaderState createState() => _BottomAnimeLoaderState();
}

class _BottomAnimeLoaderState extends State<BottomAnimeLoader> {
  String _animationName = "success";
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        mainAxisSize: MainAxisSize.min,
        children: [
          Expanded(
              child: FlareActor(
            "assets/flr/success.flr",
            fit: BoxFit.contain,
            alignment: Alignment.center,
            animation: _animationName,
          ))
        ],
      ),
    );
  }
}

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: BottomAnimeLoader(),
    );
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM