Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use an image instead of an icon in flutter?

Tags:

I am currently doing something like this

new Tab(icon: new Icon(Icons.arrow_forward), text: "Browse"), 

However I would like to use an image as an icon . I get images using

new Image.asset("assets/img/logo.png"), 

My question is how can i use that image as an icon in my tab shown above ?

like image 927
MistyD Avatar asked May 06 '18 10:05

MistyD


People also ask

How do I use an image instead of icon in Flutter?

To set the image to be displayed as the icon, you need to pass an ImageProvider instance. For that purpose, you need to create an instance of any class that's a descendant of ImageProvider such as AssetImage , NetworkImage , MemoryImage , and ResizeImage . The below example uses AssetImage to load the image.


1 Answers

As per documentation Tab icon property ask a widget so you can pass like this also or any other widget also

new Tab(icon: new Image.asset("assets/img/logo.png"), text: "Browse"), 
like image 150
Robin Sinha Avatar answered Sep 20 '22 18:09

Robin Sinha