Flutter ListView长列表布局
发布日期:2021-10-10 05:31:00
浏览次数:35
分类:技术文章
本文共 1034 字,大约阅读时间需要 3 分钟。
import 'package:flutter/material.dart';void main() =>runApp( new MyApp());// 在外部定义数据const CITY_Names =['北京','田径','上海','北京','田径','上海','北京','田径','上海','北京','田径','上海','北京','田径','上海','北京','田径','上海','北京','田径','上海',];class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { final title = 'Basic List'; return MaterialApp( title: title, home: Scaffold( appBar: AppBar( title: Text('title'), ), body: ListView( children: _buildList(), ), ), ); } /把城市的名字 传入下面的小部件 转化为数组 List_buildList(){ return CITY_Names.map((city) =>_item(city)).toList(); }//写的是list 的样式 Widget _item(String city){ return Container( height: 80, margin: EdgeInsets.only(bottom:5), alignment: Alignment.center, decoration: BoxDecoration( color: Colors.teal ), child: Text( city, style:TextStyle(color:Colors.white,fontSize:20) ), ); }}
这段是flutter 实在携程网的代码,我在bilili 上看到的,初学者学习
转载地址:https://blog.csdn.net/qq_22049619/article/details/103466494 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
初次前来,多多关照!
[***.217.46.12]2024年05月01日 09时55分56秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
TypeError: this.getOptions is not a function
2019-04-29
el-table 二维数组合并行
2019-04-29
js获取当月的天数
2019-04-29
多个相邻的盒子外边框合并的问题
2019-04-29
js实现复制功能
2019-04-29
UR5e机械臂运行一直阻塞在waitForServer
2019-04-29
ROS把pkg1下的某个头文件和源文件生成动态链接库供pkg2调用
2019-04-29
使用urdf_tutorial快速可视化urdf文件
2019-04-29
SQl 数据完整性(随堂博客)
2019-04-29
左连接、右连接、内连接
2019-04-29
MySQL DQL语句基础(随堂博客)
2019-04-29
MySQL基础练习
2019-04-29
利用MySQL进行数据复杂查询(1)
2019-04-29
利用MySQL进行数据复杂查询(2)
2019-04-29
MySQL 表与表之间的关系
2019-04-29
Python数据处理
2019-04-29
Java练习题(面向对象)
2019-04-29
Python 利用os和shutil复制系统文件
2019-04-29
Python 循环输出菱形字符串
2019-04-29