Flutter水平排列的布局
发布日期:2021-10-10 05:31:00
浏览次数:24
分类:技术文章
本文共 1062 字,大约阅读时间需要 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( // 控制水平排列的方向 scrollDirection: Axis.horizontal, children: _buildList(), ), ), ); } List_buildList(){ return CITY_Names.map((city) =>_item(city)).toList(); } Widget _item(String city){ return Container( //height: 80, width: 160, height: 80, margin: EdgeInsets.only(bottom:5,right: 10), alignment: Alignment.center, decoration: BoxDecoration( color: Colors.teal ), child: Text( city, style:TextStyle(color:Colors.white,fontSize:20) ), ); }}
转载地址:https://blog.csdn.net/qq_22049619/article/details/103466706 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
第一次来,支持一个
[***.219.124.196]2024年04月18日 20时23分58秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
spring boot 与 Ant Design of Vue 实现左侧组织树(二十三)
2021-06-30
spring boot 与 Ant Design of Vue 实现新增组织(二十四)
2021-06-30
spring boot 与 Ant Design of Vue 实现修改组织(二十五)
2021-06-30
spring boot 与 Ant Design of Vue 实现删除组织(二十六)
2021-06-30
spring boot 与 Ant Design of Vue 实现新增用户(二十八)
2021-06-30
spring boot 与 Ant Design of Vue 实现修改用户(二十九)
2021-06-30
spring boot 与 Ant Design of Vue 实现删除用户(三十)
2021-06-30
Druid连接池实现自定义场景的多数据库的连接
2021-06-30
CentOs7命令行(静默)的方式安装oracle数据库
2021-06-30
基于VMware安装CentOs7的镜像
2021-06-30
PL/SQL数据库管理工具的使用
2021-06-30
史上最简单的spring-boot集成websocket的实现方式
2021-06-30
带你玩转属于自己的spring-boot-starter系列(一)
2021-06-30
带你玩转属于自己自己的spring-boot-starter系列(二)
2021-06-30
带你玩转属于自己的spring-boot-starter系列(三)
2021-06-30
基于SnowFlake算法如何让分库分表中不同的ID落在同一个库的算法的实现
2021-06-30