【问题标题】:Flutter: show asset gif in alert dialogFlutter:在警报对话框中显示资产 gif
【发布时间】:2021-08-14 12:50:14
【问题描述】:

我正在尝试在我的警报对话框中显示此 gif 资源,但出现错误:

Another exception was thrown: Unable to load asset: assets/tutorial/lip.gif

但 .png 图像可以正常工作。

这是我的警报对话框代码:

...
AlertDialog(
        title: Text('Showing Lip'),
        content: Container(
          child: Image.asset(
            'assets/tutorial/lip.gif',
            height: 125.0,
            width: 125.0,
          ),
        ),
...

感谢任何帮助!

【问题讨论】:

    标签: flutter dialog gif


    【解决方案1】:

    您正在使用正确的方法来显示 GIF。

    您的问题可能是您尝试显示的文件的路径不正确。

    您是否将此文件添加到您的pubspec.yaml 文件中? 这里是official documentation,介绍如何将资产添加到您的 Flutter 项目中

    【讨论】:

    • 我刚刚发现出了什么问题...我没有重建项目,只是热加载它...在使用“flutter run”完全重建后,一切正常...
    猜你喜欢
    • 2021-01-17
    • 2020-03-21
    • 1970-01-01
    • 2020-05-13
    • 2023-03-13
    • 2020-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多