Home > Back-end >  Flutter not rendering color for transparent background png icon
Flutter not rendering color for transparent background png icon

Time:01-10

As I am very much new to the front-end world, I am not sure when I download the png from flaticon website such as enter image description here

CodePudding user response:

If you want to show and image from your assets you need Image.asset, so instead of ImageIcon, use Image.asset:

child: Image.asset(
  'assets/images/telescope.png',
   height: 150,
   width: 150,
)

enter image description here

CodePudding user response:

You can use assets image using Image.asset widget like this just remove ImageIcon widget from your code. also make sure you added assets path in pubsec.yaml file.

Container(
    height: 150,
    width: 150,
    color: Theme.of(context).colorScheme.background,
    child: Image.asset('assets/images/telescope.png'),
 )

Assets path in pubspec.yaml file

assets:
    - assets/images/
  • Related