如何以 imageprovider 类型传递图像资产?

lee*_*adi 8 assets image dart flutter

我目前依赖于flashscreen 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: () {},
 );
Run Code Online (Sandbox Code Playgroud)

预计能够使用 Image.assets 但它仅适用于网络图像。

nma*_*ran 15

尝试更改Image.asset(AppAsset.background)为如下

Image.asset(AppAsset.background).image

或者

AssetImage(AppAsset.background)