Issue
I'm doing some testing with the CircleAvatar. I know that the background image would normally be obtained from the network, which is what the documentation shows:
CircleAvatar(
backgroundImage: NetworkImage(userAvatarUrl),
)
However, for testing purposes I just want to use asset images. I can't do this
leading: CircleAvatar(
backgroundImage: Image.asset('assets/horse.png'),
)
because as the error says
The argument type
Imagecan't be assigned to the parameter typeImageProvider.
How do I give an assets image to ImageProvider?
Solution
Use child property from CircleAvatar:
CircleAvatar(
child: Image.asset('assets/horse.png'),
);
or if you want to use the backgroundImage property use the asset provider.
CircleAvatar(
backgroundImage: AssetImage('assets/horse.png'),
);
Answered By - diegoveloper
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.