Skip to content

Commit 309bde1

Browse files
authored
Remove unnecessary nullable types in examples. (flutter#176713)
### Description - Removes unnecessary `bool?` usage in examples ## Pre-launch Checklist - [X] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [X] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [X] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [X] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [X] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [X] All existing and new tests are passing. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
1 parent 2aca931 commit 309bde1

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

examples/api/lib/cupertino/switch/cupertino_switch.0.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ class _CupertinoSwitchExampleState extends State<CupertinoSwitchExample> {
3939
// This bool value toggles the switch.
4040
value: switchValue,
4141
activeTrackColor: CupertinoColors.activeBlue,
42-
onChanged: (bool? value) {
42+
onChanged: (bool value) {
4343
// This is called when the user toggles the switch.
4444
setState(() {
45-
switchValue = value ?? false;
45+
switchValue = value;
4646
});
4747
},
4848
),

examples/api/lib/material/autocomplete/autocomplete.4.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class _AsyncAutocompleteState extends State<_AsyncAutocomplete> {
107107
),
108108
Switch(
109109
value: _networkEnabled,
110-
onChanged: (bool? value) {
110+
onChanged: (bool value) {
111111
setState(() {
112112
_networkEnabled = !_networkEnabled;
113113
});

examples/api/lib/material/list_tile/list_tile.3.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ class _ListTileExampleState extends State<ListTileExample> {
6262
title: const Text('Headline'),
6363
subtitle: Text('Enabled: $_enabled, Selected: $_selected'),
6464
trailing: Switch(
65-
onChanged: (bool? value) {
65+
onChanged: (bool value) {
6666
// This is called when the user toggles the switch.
6767
setState(() {
68-
_enabled = value!;
68+
_enabled = value;
6969
});
7070
},
7171
value: _enabled,

examples/api/lib/material/switch_list_tile/switch_list_tile.1.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ class _SwitchListTileExampleState extends State<SwitchListTileExample> {
4141
children: <Widget>[
4242
SwitchListTile(
4343
value: switchValue1,
44-
onChanged: (bool? value) {
44+
onChanged: (bool value) {
4545
setState(() {
46-
switchValue1 = value!;
46+
switchValue1 = value;
4747
});
4848
},
4949
title: const Text('Headline'),
@@ -52,9 +52,9 @@ class _SwitchListTileExampleState extends State<SwitchListTileExample> {
5252
const Divider(height: 0),
5353
SwitchListTile(
5454
value: switchValue2,
55-
onChanged: (bool? value) {
55+
onChanged: (bool value) {
5656
setState(() {
57-
switchValue2 = value!;
57+
switchValue2 = value;
5858
});
5959
},
6060
title: const Text('Headline'),
@@ -65,9 +65,9 @@ class _SwitchListTileExampleState extends State<SwitchListTileExample> {
6565
const Divider(height: 0),
6666
SwitchListTile(
6767
value: switchValue3,
68-
onChanged: (bool? value) {
68+
onChanged: (bool value) {
6969
setState(() {
70-
switchValue3 = value!;
70+
switchValue3 = value;
7171
});
7272
},
7373
title: const Text('Headline'),

0 commit comments

Comments
 (0)