【发布时间】:2018-11-09 04:12:55
【问题描述】:
我是 Flutter 新手,没有太多经验。
我正在尝试使用 Flutter 开发一个 Android 应用,这是我之前的应用设计。
而且我也能够成功地在颤动中制作网格视图,但列高是问题所在。他们有没有人可以帮助我处理我的颤振代码。
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
hi(){
}
return new Scaffold(
appBar: new AppBar(
actions: <Widget>[],
title: new Text("milla"),
),
body: new Container(
child: new Center(
child: new GridView.count(
shrinkWrap: true,
scrollDirection: Axis.vertical,
childAspectRatio:1.0,
crossAxisCount: MediaQuery.of(context).size.width <= 400.0 ? 3 : MediaQuery.of(context).size.width >= 1000.0 ? 5 : 4,
// Create a grid with 2 columns. If you change the scrollDirection to
// horizontal, this would produce 2 rows.
crossAxisSpacing: 2.0,
// Generate 100 Widgets that display their index in the List
children: new List.generate(100, (index) {
return new Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
verticalDirection: VerticalDirection.down,
children: <Widget>[
new Center(
child: new Image(
image: new NetworkImage('https://github.com/flutter/website/blob/master/_includes/code/layout/lakes/images/lake.jpg?raw=true')
)
),
new Expanded(child: new Text("apple2")), new Expanded(child: new Text(
'Item $index',
style: Theme.of(context).textTheme.headline,
)),new Expanded(child: new Center(child: new Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[new Text("+",style: new TextStyle(fontSize: 24.0),),new Text("1"),new Text("-")])))]
);
}),
),
),
)
);
}
}
如何设置列高?
当我尝试添加新视图时,它显示此错误
“引发了另一个异常:A RenderFlex 在底部溢出了 21 个像素。”
【问题讨论】:
-
你必须调整你的纵横比。
-
我必须以 1:1(宽:高)的比例显示网格,但高度应该额外增加 100 像素。例如。我能怎么做?请建议。谢谢。