Enable use_if_null_to_convert_nulls_to_bools lint (#98753)

This commit is contained in:
Tomasz Gucio
2022-02-22 23:39:20 +01:00
committed by GitHub
parent a7790d8e3a
commit e4351ff053
71 changed files with 179 additions and 166 deletions

View File

@@ -322,14 +322,14 @@ class _OptionsState extends State<Options> {
LabeledCheckbox(
label: 'Enabled',
onChanged: (bool? checked) {
widget.model.enable = checked == true;
widget.model.enable = checked ?? false;
},
value: widget.model.enable,
),
LabeledCheckbox(
label: 'Slow',
onChanged: (bool? checked) {
widget.model.slowAnimations = checked == true;
widget.model.slowAnimations = checked ?? false;
Future<void>.delayed(const Duration(milliseconds: 150)).then((_) {
if (widget.model.slowAnimations) {
timeDilation = 20.0;
@@ -343,7 +343,7 @@ class _OptionsState extends State<Options> {
LabeledCheckbox(
label: 'RTL',
onChanged: (bool? checked) {
widget.model.rtl = checked == true;
widget.model.rtl = checked ?? false;
},
value: widget.model.rtl,
),
@@ -566,7 +566,7 @@ class _MyHomePageState extends State<MyHomePage> {
onChanged: _model.enable
? (bool? value) {
setState(() {
checkboxValues[index] = value == true;
checkboxValues[index] = value ?? false;
});
}
: null,

View File

@@ -337,7 +337,7 @@ class _FuzzerState extends State<Fuzzer> with SingleTickerProviderStateMixin {
}
int depthOf(TextSpan node) {
if (node.children == null || node.children?.isEmpty == true)
if (node.children == null || (node.children?.isEmpty ?? false))
return 0;
int result = 0;
for (final TextSpan child in node.children!.cast<TextSpan>())