How to stretch an icon to fill parent?

前端 未结 1 1684
小蘑菇
小蘑菇 2021-01-04 12:04

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

相关标签:
1条回答
  • 2021-01-04 12:30

    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

    0 讨论(0)
提交回复
热议问题