我几乎用
double number = 0.2;
someWidgetSize : MediaQuery.of(context).size."width or height" * number
对于每个小部件
但是突然我想为所有设备屏幕尺寸制作小部件太容易了
所以我很好奇这是坏习惯吗(可能有副作用或其他)
谢谢
我几乎用
double number = 0.2;
someWidgetSize : MediaQuery.of(context).size."width or height" * number
对于每个小部件
但是突然我想为所有设备屏幕尺寸制作小部件太容易了
所以我很好奇这是坏习惯吗(可能有副作用或其他)
谢谢
不会。对此没有副作用。
We all do this when it is important to have a dynamic widget size. Just be aware that this uses the device size. If you want to use the parent widget's dize use
LayoutBuilder
widget that gives you the constraints of the parent wiget.