Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stretch an icon to fill parent?

Tags:

flutter

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?

like image 606
Paul Avatar asked Jul 25 '17 09:07

Paul


1 Answers

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:

  • Expanded

  • FittedBox

  • BoxFit

  • https://groups.google.com/forum/#!msg/flutter-dev/lsgdU1yl7xc/0pYS2qrzBQAJ

like image 94
user1462442 Avatar answered Sep 28 '22 18:09

user1462442