Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter ImageIcon showing image white or black

Tags:

flutter

So I have been trying to use a picture I have stored in assets and use it as a logo. This way I can animate the logo rather then just having it as a static picture. But the logo keeps showing up just white or when I tried to wrap it and set the colors to null then it shows it all black. So wondering how I get it to show my original image.

new IconTheme(
data: new IconThemeData(
  color: null,
),//IconThemeData
  child: new ImageIcon( new AssetImage("images/logo.png"), color: null, size: _logoAnimation.value * 200),//Logo

),//IconTheme
like image 771
Petahwil Avatar asked Mar 08 '18 06:03

Petahwil


1 Answers

This happens because, the IconThemeData returned by IconTheme.of method is merged with IconThemeData.fallback() which has a default color as black.

You can look here to know what actually the IconTheme.of method returns and the IconThemeData.fallback() just returns this.

You can raise an issue regarding the same here.

As a workaround, you can just do what ImageIcon does with color as null.

Example:

new Image(
  image: new AssetImage("images/logo.png"),
  width: _logoAnimation.value * 200,
  height: _logoAnimation.value * 200,
  color: null,
  fit: BoxFit.scaleDown,
  alignment: Alignment.center,
)

Hope that helps!

like image 67
Hemanth Raj Avatar answered Oct 17 '22 19:10

Hemanth Raj