我目前依赖于splashscreen 1.2.0软件包的一个Flutter 翼应用程序. 但是backgroundimage变量类型是imageprovider,而我想使用Assets文件夹中的图像.有没有人知道如何传递图像资源文件,以便能够用作imageprovider类型,或者知道如何使用任何其他方式使其工作?

因为与其他属性相比,使用它刚刚加载的imageprovider稍晚一些.

非常感谢!

我try 使用Image.Asset(),但不起作用.

return SplashScreen(
    seconds: 5,
    navigateAfterSeconds: AppRoute,
    title: Text('Welcome', style: AppTextStyle),
    image: Image.asset(AppAsset.logo),
    photoSize: AppScreen,
    imageBackground: Image.asset(AppAsset.background),
    loaderColor: AppColor,
    loadingText: Text('Loading'),
    styleTextUnderTheLoader: AppTextStyle,
    onClick: () {},
 );

期望能够使用Image.sets,但它仅适用于网络映像.

推荐答案

try 将Image.asset(AppAsset.background)改为如下所示

Image.asset(AppAsset.background).image

AssetImage(AppAsset.background)

Dart相关问答推荐

我不明白在DART的`if()`语句中使用`case

如何通过点击 BottomNavigationBarItem 以编程方式打开Drawer抽屉?

Flutter Web:无法用鼠标向下滚动(drag)(Flutter 2.5+)

flutter pub run build_runner 卡住了

在 Dart 中定义一个接受参数的 getter

如何在Flatter中zoom 两个谷歌 map 标记

如何使用 StreamBuilder 更新 TextField 的值?

如何在 Flutter 中渲染单个像素?

dart- 四舍五入

dart:web_gl: 渲染警告:texture bound to texture unit 0 is not renderable

如何在图像内的任意点上旋转图像?

如何在 Flutter 中让 Android 状态栏变亮

Dart 有小部件库吗?

什么时候在 Dart 中使用 num

Dart 有 int.INFINITY 吗?

Dart 中 http 和 HttpClient 的区别

如何在 Dart 中调用超类的构造函数和其他语句?

如何在 timeLimit 之后使future 的计算超时?

如何在 Dart 中为 Completer.CompleteException(exception, stackTrace) 获取当前堆栈跟踪;

了解工厂构造函数代码示例