import 'package:flutter/material.dart';
2
3 class Example extends StatefulWidget {
4 @override
5 _ExampleState createState() => _ExampleState();
6 }
7
8 class _ExampleState extends State<ExamplePage> {
9 List formList;
10 initState() {
11 super.initState();
12 formList = [
13 {"title": '车牌号'},
14 {"title": '所有人'},
15 {"title": '号牌颜色'},
16 ];
17 }
18 Widget buildGrid() {
19 List<Widget> tiles = [];//先建一个数组用于存放循环生成的widget
20 Widget content; //单独一个widget组件,用于返回需要生成的内容widget
21 for(var item in formList) {
22 tiles.add(
23 new Row(
24 children: <Widget>[
25 new Text(item['title'])
26 ]
27 )
28 );
29
Flutter for循环案例
最新推荐文章于 2024-04-17 09:08:40 发布