How to resizing an Icon / Icon Button in Flutter?

后端 未结 4 1182
情书的邮戳
情书的邮戳 2021-01-17 11:27

I have 2 questions.

  1. how to scale our icon ? I mean not a default icon from Flutter. but when you change into an Image. I have an Icon Button with an image like
4条回答
  •  悲&欢浪女
    2021-01-17 12:05

    I'm going to answer my questions based on All Suhu answers here and based on my experience asking uncle google.

    1. how to scale our icon ? I mean not a default icon from Flutter. but when you change into an Image. ?

    mr @CopsOnRoad has give his answer on the comment column. and it really works. thanks :) my answer:

    Row(
                            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                            children: [
                              Image.asset("images/line.png", width: 30,),
                              SizedBox(width: 5,),
                              Image.asset("images/Wa.png", width: 30,),
                              SizedBox(width: 5,),
                              Image.asset("images/IG.png", width: 30,),
                              SizedBox(width: 5,),
                              Image.asset("images/Twitter.png", width: 30,),
                              SizedBox(width: 5,),
                              Image.asset("images/Fb.png", width: 30,),
    
                            ],
    

    I use an image asset and give them a size to resize. but this is only dumb way. the great way you can see mr. Cops answer above.

    1. how to change an Icon with an Image ? here are the code: Icon(Icons.star, color: Colors.red)

    my answer is by using ImageIcon. Its makes an image just like an icon. here the code.

      ImageIcon(AssetImage("images/Free Ongkir.png")),
    

    because I still cant change the "star" into an image asset then I used ImageIcon. you can change the size also. by adding "size" behind the first ")".

    hope this could help you :)

提交回复
热议问题