颤振从开关小部件中删除多余的空间

时间:2020-02-03 04:21:55

标签: flutter material-design

我正在flutter应用程序中的以下屏幕上工作,但是当我使用Switch小部件时,它会中断对齐,因为在flutter中已经定义了硬编码的高度和宽度。

enter image description here enter image description here

我如何摆脱多余的空间

注意:使用单选按钮或复选框也会出现相同的问题

1 个答案:

答案 0 :(得分:0)

enter image description here

您可以尝试将Switch小部件包装在Container中

Container(
  height: 20,
  width: 50,
  child: Switch(
   value: _value,
   onChanged: (value){
    setState((){
      _value = value
    });
   }
  )
);