目前,我正在使用以下代码:

body: new Container(

child: new Column(

crossAxisAlignment: CrossAxisAlignment.stretch,

mainAxisAlignment: MainAxisAlignment.spaceEvenly,

children: [

new MaterialButton(

height: 120.0,

child: new Column(

children: [

new Icon(

Icons.av_timer,

size: 100.0,

),

new Text('TIMER'),

],

),

onPressed: null,

),

new MaterialButton(

height: 120.0,

child: new Column(

children: [

new Icon(Icons.alarm_add, size: 100.0),

new Text('ALARM'),

],

),

onPressed: null,

)

])));

但是,我不得不将Icon大小“硬编码”为100.0,将MaterialButton的高度“硬编码”为120.0.

我希望MaterialButton占用尽可能多的空间(每个屏幕占50%),我希望这些图标能够“很好地适应”该空间,理想情况下还有文本缩放.

我还没有找到在Flutter中做到这一点的方法.如果尝试这样做不是一个好主意(我希望在任何设备上使用屏幕的整个空间),请告诉我原因?

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐