Home > database >  How can I make image to active like button in flutter?
How can I make image to active like button in flutter?

Time:08-24

appBar: AppBar(
    backgroundColor: Colors.white,
    leading: IconButton(
      icon: Icon(Icons.menu, color: Colors.pink,),
      onPressed: () {
        print("menu button is clicked");
      }
    ),
    title: IconButton(
      onPressed: () { print("run button"); },
      icon: Image.asset('assets/images/Slimer_by_shinrider-dcqaiza.webp')),
    ),

In codes, there's a IconButton that I made for making image to button. but it doesn't appear image. Is there any incorrect thing in code? or Do I have to another method?

CodePudding user response:

Check the assets path setting in pubspec.yaml. Also, check if the image is in the assets path that you set normally.

pubspec.yaml

assets:
    - assets/images/

show documents
https://docs.flutter.dev/development/ui/assets-and-images

CodePudding user response:

GestureDetector(
onTap: () {print('click on edit');},
child: Image(
    image: AssetImage('assets/images/icons/edit-button.png'),
    fit: BoxFit.cover,
    height: 20,
)),

try to use with .png

  • Related