代码之家  ›  专栏  ›  技术社区  ›  atreeon

FittedBox在包装图标和包装图标按钮时具有不同的行为

  •  0
  • atreeon  · 技术社区  · 8 年前

    FittedBox BoxFit.fitWidth Icon 缩小到分配的数量。如果我包一个 IconButton 在一个 它什么也不做!

    我如何调整我的尺寸 图标按钮

    enter image description here

    这是我的密码

    return new Scaffold(
        body: Column(children: [
      Row(children: [
        Expanded(
            flex: 5,
            child: Container(
              child: Text('Icon button ->'),
              color: Colors.green,
            )),
        Expanded(
            flex: 1,
            child: FittedBox(
                fit: BoxFit.fitWidth,
                child: IconButton(
                  icon: Icon(
                    Icons.radio,
                    size: 200.0,
                  ),
                  onPressed: () => print('x'),
                )))
      ]),
      Row(children: [
        Expanded(
            flex: 5,
            child: Container(
              child: Text('just an Icon ->'),
              color: Colors.green,
            )),
        Expanded(
            flex: 1,
            child: FittedBox(
                fit: BoxFit.fitWidth,
                child: Icon(
                  Icons.radio,
                  size: 200.0,
                )))
      ])
    ]));
    
    1 回复  |  直到 8 年前
        1
  •  0
  •   atreeon    8 年前

    好的,所以我需要从图标中删除我的尺寸:200.0,图标和图标按钮之间的行为是不同的,如果在图标上设置尺寸并用FittedBox(fitWidth)包装图标,图标会缩小,如果在图标按钮上设置尺寸并用FittedBox(fittedwidth)包装图标,图标按钮不会被FittedBox包装覆盖。