Skip to content

Commit 8c46968

Browse files
authored
fix compile error in the example code (flutter#103261)
1 parent aed6b6f commit 8c46968

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/flutter/lib/src/material/checkbox_list_tile.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import 'theme.dart';
1111
import 'theme_data.dart';
1212

1313
// Examples can assume:
14+
// bool? _throwShotAway = false;
1415
// void setState(VoidCallback fn) { }
1516

1617
/// A [ListTile] with a [Checkbox]. In other words, a checkbox with a label.
@@ -163,21 +164,24 @@ class CheckboxListTile extends StatelessWidget {
163164
///
164165
/// If null, the checkbox will be displayed as disabled.
165166
///
167+
/// {@tool snippet}
168+
///
166169
/// The callback provided to [onChanged] should update the state of the parent
167170
/// [StatefulWidget] using the [State.setState] method, so that the parent
168171
/// gets rebuilt; for example:
169172
///
170173
/// ```dart
171174
/// CheckboxListTile(
172175
/// value: _throwShotAway,
173-
/// onChanged: (bool newValue) {
176+
/// onChanged: (bool? newValue) {
174177
/// setState(() {
175178
/// _throwShotAway = newValue;
176179
/// });
177180
/// },
178-
/// title: Text('Throw away your shot'),
181+
/// title: const Text('Throw away your shot'),
179182
/// )
180183
/// ```
184+
/// {@end-tool}
181185
final ValueChanged<bool?>? onChanged;
182186

183187
/// The color to use when this checkbox is checked.

0 commit comments

Comments
 (0)