I have 2 questions.
Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
IconButton(
icon: new Image.asset("images/IG.png"),
),
IconButton(
icon: new Image.asset("images/Twitter.png"),
),
IconButton(
icon: new Image.asset("images/Fb.png"),
),
],
)
its only 3 icons. when I add more icon, its gonna break the layout into bricks yellow-black. how to make them become smaller ?
Question above is for IconButton. how to change an Icon with an Image ? here are the code:
Icon(Icons.star, color: Colors.red)
how to change the 'star
' with Image.asset ?
without any referal to other link, that only show the icon.
You can use size property for Icon . For normal Icon you can use size but for IconButton with your own images you should use scale .
Create IconButton wrapped around Center Widget to make it center. Provide it with an icon and change the size of the icon using iconSize parameter. Implement the required onPressed method. Provide optional hoverColor, focusColor, splashColor parameter to IconButton.
You can use size
property for Icon
.
Icon(
Icons.radio_button_checked,
size: 12,
),
And for IconButton
you can use
Transform.scale(
scale: 0.5,
child: IconButton(
onPressed: (){},
icon: new Image.asset("images/IG.png"),
),
),
For first question u can use sized box to contain IconButton and if it is breaking when adding more either use scroll or reduce width and height of sized box with respect to child.
new SizedBox(
height: /*calculate from width and no:of child*/,
width: /*calculate from width and no:of child*/,
child: new IconButton(
padding: new EdgeInsets.all(0.0),
icon: new Image.asset("images/IG.png"),
onPressed: null,
)
)
for second question u can use AssetImage('icons/heart.png', package: 'my_icons')
you can refer Doc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With