forked from flutter/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkbox_list_tile.1.dart
79 lines (70 loc) · 2.48 KB
/
checkbox_list_tile.1.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// 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.
// Flutter code sample for [CheckboxListTile].
import 'package:flutter/material.dart';
void main() => runApp(const CheckboxListTileApp());
class CheckboxListTileApp extends StatelessWidget {
const CheckboxListTileApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(colorSchemeSeed: const Color(0xff6750a4), useMaterial3: true),
home: const CheckboxListTileExample(),
);
}
}
class CheckboxListTileExample extends StatefulWidget {
const CheckboxListTileExample({super.key});
@override
State<CheckboxListTileExample> createState() => _CheckboxListTileExampleState();
}
class _CheckboxListTileExampleState extends State<CheckboxListTileExample> {
bool checkboxValue1 = true;
bool checkboxValue2 = true;
bool checkboxValue3 = true;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('CheckboxListTile Sample')),
body: Column(
children: <Widget>[
CheckboxListTile(
value: checkboxValue1,
onChanged: (bool? value) {
setState(() {
checkboxValue1 = value!;
});
},
title: const Text('Headline'),
subtitle: const Text('Supporting text'),
),
const Divider(height: 0),
CheckboxListTile(
value: checkboxValue2,
onChanged: (bool? value) {
setState(() {
checkboxValue2 = value!;
});
},
title: const Text('Headline'),
subtitle: const Text('Longer supporting text to demonstrate how the text wraps and the checkbox is centered vertically with the text.'),
),
const Divider(height: 0),
CheckboxListTile(
value: checkboxValue3,
onChanged: (bool? value) {
setState(() {
checkboxValue3 = value!;
});
},
title: const Text('Headline'),
subtitle: const Text("Longer supporting text to demonstrate how the text wraps and how setting 'CheckboxListTile.isThreeLine = true' aligns the checkbox to the top vertically with the text."),
isThreeLine: true,
),
const Divider(height: 0),
],
),
);
}
}