I want to size an icon inside a container to be the size of that container so that it would not be small in larger devices due to hard coding the size value. I was trying something like this
Container(
child: Icon(
Icons.beach_access,
size: double.infinity,
)
)
You can increase the size of Icon to a required value by assigning the size property with specific double value.
Icons occupy a square with width and height equal to size. Defaults to the current IconTheme size, if any. If there is no IconTheme, or it does not specify an explicit size, then it defaults to 24.0.
If you want the size of the icon to meet the ends of its Container parent, you can place it in a FittedBox
Container(
child: FittedBox(
child: Icon(
Icons.beach_access,
),
),
),
You can change the fit property of the FittedBox to adjust some sizes and change alignment.
https://api.flutter.dev/flutter/widgets/FittedBox-class.html
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