我一直在尝试 Flutter 和 GridView。目前我有许多容器出现在网格布局中,但是我想在它们下面再添加一个容器并自定义大小。我希望所有现有容器占用 60% 的屏幕,而新容器完全覆盖剩余的 40%。我已经尝试过扩展类,但没有运气。任何反馈/建议将不胜感激。
Widget build(BuildContext context){
final title = ' MyFirstApp';
return MaterialApp(
title: title,
home: Scaffold(
appBar: AppBar(
backgroundColor: Colors.green,
title: Text(title),
),
body: GridView.count(
crossAxisCount: 3,
crossAxisSpacing: 10.0,
mainAxisSpacing: 10.0,
childAspectRatio: 0.80,
children: <Widget> [
new InkWell(
onTap: (){
navigateToSubPage(context, Page1());
print("Container clicked");
},
child: Container(
child: Column(
children: [
Image.asset('assets/main/page1.jpg'),
Text("Page1", style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 18),),
]),
)
),
new InkWell(
onTap: (){
navigateToSubPage(context, page2());
print("Container clicked 1");
},
child: Container(
child: Column(
children: [
Image.asset('assets/main/page2.jpg'),
Text("Page2", style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 18),),
]),
),
),
new InkWell(
onTap: (){
navigateToSubPage(context, page3());
print("Container clicked 2");
},
child: Container(
child: Column(
children: [
Image.asset('assets/main/page3.jpg'),
Text("Record", style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 18),),
]),
),
),
new InkWell(
onTap: (){
navigateToSubPage(context, page4());
print("Container clicked 3");
},
child: Container(
child: Column(
children: [
Image.asset('assets/main/page4.jpg'),
Text("Page4", style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 18),)
]),
),
),
new InkWell(
onTap: (){
print("Container clicked 4");
},
child: Container(
child: Column(
children: [
Image.asset('assets/main/page5.jpg'),
Text("Page5", style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 18),),
]),
),
),
new InkWell(
onTap: (){
print("Container clicked 5");
},
),
],
),
),
);
}```