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

@@ -136,7 +136,7 @@ Future<void> main() async {
final List<double> scrollOffset = <double>[];
final List<Duration> delays = <Duration>[];
binding.addPersistentFrameCallback((Duration timeStamp) {
if (controller?.hasClients == true) {
if (controller?.hasClients ?? false) {
// This if is necessary because by the end of the test the widget tree
// is destroyed.
frameTimestamp.add(timeStamp.inMicroseconds);

View File

@@ -93,7 +93,7 @@ class Chrome {
options.url!,
if (io.Platform.environment['CHROME_NO_SANDBOX'] == 'true')
'--no-sandbox',
if (options.headless == true)
if (options.headless ?? false)
'--headless',
if (withDebugging)
'--remote-debugging-port=${options.debugPort}',

View File

@@ -171,7 +171,7 @@ class MotionEventsBodyState extends State<MotionEventsBody> {
}
Future<void> saveRecordedEvents(ByteData data, BuildContext context) async {
if (await channel.invokeMethod<bool>('getStoragePermission') == true) {
if (await channel.invokeMethod<bool>('getStoragePermission') ?? false) {
showMessage(
context, 'External storage permissions are required to save events');
return;

View File

@@ -230,9 +230,9 @@ class _LeaveBehindListItem extends StatelessWidget {
confirmDismiss: !confirmDismiss ? null : (DismissDirection dismissDirection) async {
switch(dismissDirection) {
case DismissDirection.endToStart:
return await _showConfirmationDialog(context, 'archive') == true;
return await _showConfirmationDialog(context, 'archive') ?? false;
case DismissDirection.startToEnd:
return await _showConfirmationDialog(context, 'delete') == true;
return await _showConfirmationDialog(context, 'delete') ?? false;
case DismissDirection.horizontal:
case DismissDirection.vertical:
case DismissDirection.up:

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>())