0

耀斑动画不会显示在屏幕上。我在用着:

Container(
              height: 300.0,
              width: 300.0,
              child: FlareActor('checkmarkone.flr',
                  fit: BoxFit.contain,
                  alignment: Alignment.center,
              ),
            ),

当我运行应用程序时,我在运行控制台中收到此消息:

[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: Unable to load asset: checkmarkone.flr
#0      PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart:221:7)
<asynchronous suspension>
#1      FlareCacheAsset.load (package:flare_flutter/flare_cache_asset.dart:31:20)
#2      Cache.getAsset (package:flare_flutter/cache.dart:56:15)
#3      cachedActor (package:flare_flutter/flare_cache.dart:35:16)
#4      FlareRenderBox.loadFlare (package:flare_flutter/flare_render_box.dart:322:35)
#5      FlareActorRenderObject.coldLoad (package:flare_flutter/flare_actor.dart:322:20)
#6      FlareRenderBox.load (package:flare_flutter/flare_render_box.dart:272:7)
#7      FlareRenderBox.attach (package:flare_flutter/flare_render_box.dart:115:7)
#8      AbstractNode.adoptChild (package:flutter/src/foundation/node.dart:132:13)
#9      RenderObject.adoptChild (package:flutter/src/rendering/object.dart:1238:11)
#10     RenderObjectWithChildMixin.child= (package:flutter/src/rendering/object.dart:2905:7)<…&gt;

我感谢所有建议。谢谢

4

2 回答 2

0

确保您checkmarkone.flr的资产文件夹中有文件,然后将其添加到您的 pubspec.yaml 文件中

flutter:
  assets:
    - checkmarkone.flr

然后,运行flutter packages get命令来更新依赖项。最后,冷重启你的项目

于 2019-12-31T17:51:58.573 回答
0

请检查您的pubspec.yaml文件并确保该文件checkmarkone.flr已正确添加/加载。

例如。

发布规范.yaml

... (more on top)
# The following section is specific to Flutter.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  assets:
   - assets/checkmarkone.flr # Add it here
... (more on bottom)

现在等待颤振任务(更新包)完成,然后尝试使用上面添加的资产路径通过热重启在屏幕/小部件中加载 Flare 动画。

小部件.dart


Container(
  height: 300.0,
  width: 300.0,
  child: FlareActor('assets/checkmarkone.flr',
      fit: BoxFit.contain,
      alignment: Alignment.center,
  ),
),

进一步阅读

于 2019-12-31T17:53:57.997 回答