Created
February 16, 2020 06:45
-
-
Save ryanlid/262af581100a7fe0e8e3956e5d87478f to your computer and use it in GitHub Desktop.
ListView布局
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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