homePage.dart
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import 'package:flutter/material.dart';
class homePage extends StatefulWidget {
@override
State<StatefulWidget> createState() => StateFulhomePageState();
}
class StateFulhomePageState extends State<homePage> {
List<Container> buildGridTitleList(int count){
return new List<Container>.generate(count, (int index) => new Container(
child:
Container(
width: 64,
height: 64,
alignment: Alignment.center,
// child: Image.asset("images/a.jpeg",
// fit:BoxFit.cover,
// ),
child: Image.asset("images/projectManager.png",
fit:BoxFit.cover,
),
),
));
}
Widget buildGrid(){
return new GridView.count(
//水平子Widget之间间距
crossAxisSpacing: 10.0,
//垂直子Widget之间间距
mainAxisSpacing: 30.0,
//GridView内边距
padding: EdgeInsets.all(10.0),
//一行的Widget数量
crossAxisCount: 4,
//子Widget宽高比例
childAspectRatio: 2.0,
children: buildGridTitleList(5),
);
}
@override
Widget build(BuildContext context) {
// TODO: implement build
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text("首页"),
centerTitle: true, // 标题居中
),
body: new Center(
child: buildGrid(),
),
),
);
}
}