Skip to content

Instantly share code, notes, and snippets.

@ryanlid
Created February 16, 2020 06:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanlid/262af581100a7fe0e8e3956e5d87478f to your computer and use it in GitHub Desktop.
Save ryanlid/262af581100a7fe0e8e3956e5d87478f to your computer and use it in GitHub Desktop.
ListView布局
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
title: "ListView布局示例",
home: MyApp(),
));
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// 列表集合
List<Widget> list = <Widget>[
// 列表项
ListTile(
// 标题
title: Text(
"广州市黄埔大道",
style: TextStyle(fontWeight: FontWeight.w400, fontSize: 18.0),
),
// 子标题
subtitle: Text("广州市"),
// 左侧图标
leading: Icon(
Icons.fastfood,
color: Colors.orange,
),
),
ListTile(
title: Text(
"广州市白云区",
style: TextStyle(fontWeight: FontWeight.w400, fontSize: 18.0),
),
subtitle: Text("广州市"),
leading: Icon(
Icons.airplay,
color: Colors.blue,
),
)
];
return Scaffold(
appBar: AppBar(
title: Text("ListView 布局示例"),
),
body: Center(
child: ListView(
children: list,
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment