Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass image asset in imageprovider type?

I currently depend on splashscreen 1.2.0 package for the a flutter app. But the backgroundimage variable type is imageprovider, whereas I want to use the image from assets folder. Does anyone know how to pass the image asset file to be able to use as the imageprovider type or maybe any other way to make it work?

Cause using the imageprovider it just loaded a bit later on compared to the other properties.

Many thanks!

I've tried using the Image.asset() but didn't work.

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: () {},
 );

Expected to be able to use Image.assets but it only works for the network image.

like image 690
leemuljadi Avatar asked Oct 17 '19 07:10

leemuljadi


1 Answers

Try changing the Image.asset(AppAsset.background) to as follows

Image.asset(AppAsset.background).image

Or

AssetImage(AppAsset.background)

like image 180
nmanikiran Avatar answered Oct 24 '22 02:10

nmanikiran