如何通过图像提供者类型传递图像资产?

问题描述 投票:0回答:1

我目前依赖于splashscreen 1.2.0软件包来安装flutter应用程序。但是backgroundimage变量类型是imageprovider,而我想使用资产文件夹中的图像。有谁知道如何传递图像资产文件以用作imageprovider类型或可能以其他任何方式使其工作?

由于使用imageprovider,与其他属性相比,它稍后才加载。

非常感谢!

我尝试使用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.assets,但仅适用于网络图像。

image flutter dart assets
1个回答
0
投票

尝试将Image.asset(AppAsset.background)更改如下Image.asset(AppAsset.background).image要么AssetImage(AppAsset.background)

© www.soinside.com 2019 - 2024. All rights reserved.