-
Notifications
You must be signed in to change notification settings - Fork 3.3k
/
Copy pathlist_demo.dart
51 lines (45 loc) · 1.41 KB
/
list_demo.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright 2019 The Flutter team. 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';
class ListDemo extends StatelessWidget {
const ListDemo({super.key, required this.type});
final ListDemoType type;
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
),
home: Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
title: const Text('List demo'),
),
body: Scrollbar(
child: ListView(
restorationId: 'list_demo_list_view',
padding: const EdgeInsets.symmetric(vertical: 8),
children: [
for (var index = 1; index < 21; index++)
ListTile(
leading: ExcludeSemantics(
child: CircleAvatar(child: Text('$index')),
),
title: Text('Item $index'),
subtitle:
type == ListDemoType.twoLine
? const Text('Secondary text')
: null,
),
],
),
),
),
);
}
}
enum ListDemoType { oneLine, twoLine }
void main() {
runApp(const ListDemo(type: ListDemoType.twoLine));
}