Displaying lists of data is a fundamental pattern for mobile apps. Flutterincludes the ListView
Widget to make working with lists a breeze!
Create a ListView
Using the standard ListView
constructor is perfect for lists that contain onlya few items. We will also employ the built-inListTile
Widget to give our items a visual structure.
ListView(
children: <Widget>[
ListTile(
leading: Icon(Icons.map),
title: Text('Map'),
),
ListTile(
leading: Icon(Icons.photo_album),
title: Text('Album'),
),
ListTile(
leading: Icon(Icons.phone),
title: Text('Phone'),
),
],
);
Complete example
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
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: <Widget>[
ListTile(
leading: Icon(Icons.map),
title: Text('Map'),
),
ListTile(
leading: Icon(Icons.photo_album),
title: Text('Album'),
),
ListTile(
leading: Icon(Icons.phone),
title: Text('Phone'),
),
],
),
),
);
}
}
当前内容版权归 flutter.dev 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 flutter.dev .