list_tile.1.dart 2.19 KB
Newer Older
1 2 3 4 5 6
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/material.dart';

7 8
/// Flutter code sample for [ListTile].

9 10 11 12 13 14 15
void main() => runApp(const ListTileApp());

class ListTileApp extends StatelessWidget {
  const ListTileApp({super.key});

  @override
  Widget build(BuildContext context) {
16 17 18
    return MaterialApp(
      theme: ThemeData(useMaterial3: true),
      home: const LisTileExample(),
19 20 21 22 23 24 25 26 27
    );
  }
}

class LisTileExample extends StatelessWidget {
  const LisTileExample({super.key});

  @override
  Widget build(BuildContext context) {
28 29 30 31 32 33 34 35 36 37
    return Scaffold(
      appBar: AppBar(title: const Text('ListTile Sample')),
      body: ListView(
        children: const <Widget>[
          Card(child: ListTile(title: Text('One-line ListTile'))),
          Card(
            child: ListTile(
              leading: FlutterLogo(),
              title: Text('One-line with leading widget'),
            ),
38
          ),
39 40 41 42 43
          Card(
            child: ListTile(
              title: Text('One-line with trailing widget'),
              trailing: Icon(Icons.more_vert),
            ),
44
          ),
45 46 47 48 49 50
          Card(
            child: ListTile(
              leading: FlutterLogo(),
              title: Text('One-line with both widgets'),
              trailing: Icon(Icons.more_vert),
            ),
51
          ),
52 53 54 55 56
          Card(
            child: ListTile(
              title: Text('One-line dense ListTile'),
              dense: true,
            ),
57
          ),
58 59 60 61 62 63 64
          Card(
            child: ListTile(
              leading: FlutterLogo(size: 56.0),
              title: Text('Two-line ListTile'),
              subtitle: Text('Here is a second line'),
              trailing: Icon(Icons.more_vert),
            ),
65
          ),
66 67 68 69
          Card(
            child: ListTile(
              leading: FlutterLogo(size: 72.0),
              title: Text('Three-line ListTile'),
70
              subtitle: Text('A sufficiently long subtitle warrants three lines.'),
71 72
              trailing: Icon(Icons.more_vert),
              isThreeLine: true,
73 74
            ),
          ),
75 76
        ],
      ),
77 78 79
    );
  }
}