Reputation: 2083
I need an icon that will dynamically stretch to fill the parent container.
I don't think this is possible directly on the Icon (since it only has a size property), but is there another solution I'm overlooking?
Upvotes: 16
Views: 18883
Reputation: 975
To expand the size of icon and fill his parent widget used expand it with SizedBox and fill the icon with FittedBox widget
SizedBox.expand(
child: FittedBox(
fit: BoxFit.fill,
child: Icon(Icons.volume_off),
),
),
Upvotes: 4
Reputation: 8202
I believe you can use FittedBox
with Expanded
:
new Expanded(
child: new FittedBox(
fit: BoxFit.fill,
child: new Icon(Icons.home),
),
),
Please note the in the docs that Expanded
has to be wrapped in a Column
, Row
or Flex
widget.
References:
Upvotes: 38