Voyz's Studio.

Flutter学习笔记-3

字数统计: 143阅读时长: 1 min
2020/08/25 Share

Flutter学习笔记-3

基础组件

GridView

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
import 'package:flutter/material.dart';

void main() => {
runApp(MyApp(
items: new List<Widget>.generate(120, (i) {
return new Container(
child: new Text(
'第${(i ~/ 4 + 1)}行\n第${i % 4 + 1}个元素',
style: TextStyle(fontSize: 15.0),
),
color: Colors.red[200],
alignment: Alignment.center,
margin: const EdgeInsets.fromLTRB(0, 0, 0, 5.0),
);
})))
};

class MyApp extends StatelessWidget {
final List<Widget> items;
MyApp({Key key, @required this.items}) : super(key: key);

@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'GridView',
home: Scaffold(
appBar: new AppBar(title: new Text('GirdView')),
body: GridView.count(
padding: const EdgeInsets.all(20.0),
crossAxisCount: 4,
crossAxisSpacing: 10.0,
children: items),
),
);
}
}
CATALOG
  1. 1. Flutter学习笔记-3
    1. 1.1. 基础组件
      1. 1.1.1. GridView