Flutter:在警报对话框中显示资产 gif

Flutter: show asset gif in alert dialog

我试图在我的警告对话框中显示此 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,
          ),
        ),
...

感谢任何帮助!

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

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

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