New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
♻️ Remove unnecessary null checks, which result in compiler warnings. #34
Conversation
According to the Dart flow analysis, the following null-checks are not needed. Removing them to get rid of these compiler warnings. ``` ../../../Dev/flutter/.pub-cache/hosted/pub.dartlang.org/adaptive_theme-2.3.1/lib/src/cupertino_adaptive_theme.dart:122:20: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null. - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../Dev/flutter/packages/flutter/lib/src/widgets/binding.dart'). WidgetsBinding.instance?.addObserver(this); ^ ../../../Dev/flutter/.pub-cache/hosted/pub.dartlang.org/adaptive_theme-2.3.1/lib/src/cupertino_adaptive_theme.dart:144:43: Warning: Operand of null-aware operation '!' has type 'SchedulerBinding' which excludes null. - 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart' ('../../../Dev/flutter/packages/flutter/lib/src/scheduler/binding.dart'). final brightness = SchedulerBinding.instance!.window.platformBrightness; ^ ../../../Dev/flutter/.pub-cache/hosted/pub.dartlang.org/adaptive_theme-2.3.1/lib/src/cupertino_adaptive_theme.dart:221:43: Warning: Operand of null-aware operation '!' has type 'SchedulerBinding' which excludes null. - 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart' ('../../../Dev/flutter/packages/flutter/lib/src/scheduler/binding.dart'). final brightness = SchedulerBinding.instance!.window.platformBrightness; ^ ../../../Dev/flutter/.pub-cache/hosted/pub.dartlang.org/adaptive_theme-2.3.1/lib/src/cupertino_adaptive_theme.dart:231:20: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null. - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../Dev/flutter/packages/flutter/lib/src/widgets/binding.dart'). WidgetsBinding.instance?.removeObserver(this); ^ ../../../Dev/flutter/.pub-cache/hosted/pub.dartlang.org/adaptive_theme-2.3.1/lib/src/adaptive_theme.dart:119:20: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null. - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../Dev/flutter/packages/flutter/lib/src/widgets/binding.dart'). WidgetsBinding.instance?.addObserver(this); ^ ../../../Dev/flutter/.pub-cache/hosted/pub.dartlang.org/adaptive_theme-2.3.1/lib/src/adaptive_theme.dart:139:43: Warning: Operand of null-aware operation '!' has type 'SchedulerBinding' which excludes null. - 'SchedulerBinding' is from 'package:flutter/src/scheduler/binding.dart' ('../../../Dev/flutter/packages/flutter/lib/src/scheduler/binding.dart'). final brightness = SchedulerBinding.instance!.window.platformBrightness; ^ ../../../Dev/flutter/.pub-cache/hosted/pub.dartlang.org/adaptive_theme-2.3.1/lib/src/adaptive_theme.dart:218:20: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null. - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../../Dev/flutter/packages/flutter/lib/src/widgets/binding.dart'). WidgetsBinding.instance?.removeObserver(this); ^ ```
@Phil9l I am on Flutter stable and I am not able to see this lint warnings. |
Hi |
I'll try this using beta channel. Maybe a solution would be to release a beta/dev version of the package for flutter beta channel. |
@BirjuVachhani Just tried on Flutter 3.0 with Dart 2.17.0, warnings can be seen now. |
@Phil9l Could you please check why tests failing? |
@BirjuVachhani probably because the workflow is using Flutter 2.10.4 instead of 3.0
|
Codecov Report
@@ Coverage Diff @@
## main #34 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 4 4
Lines 186 186
=========================================
Hits 186 186
Continue to review full report at Codecov.
|
This has been released in v3.0.0 |
According to the Dart flow analysis, the following null-checks are not needed. Removing them to get rid of these compiler warnings.
Requirements
Description of the Change
Alternate Designs
Why Should This Be In Core?
Benefits
Possible Drawbacks
Verification Process
Applicable Issues