Skip to content

Commit d449a17

Browse files
[various] Remove unnecessary null checks (flutter#4060)
Removes `unnecessary_null_comparison: ignore` from the repository analysis options. Now that Dart 3 has reached the stable channel, all fully supported customers will be running in strong mode, so the extra null checks are no longer needed. While many packages do support earlier versions, this won't break anyone, it will just mean that people who are both a) using old versions of Flutter and b) violating the API contract by passing null to a non-nullable type, won't get error messages that are as obvious, which is fine for the best-effort support level we give to pre-current-stable versions of Flutter.
1 parent 30ebcf3 commit d449a17

File tree

136 files changed

+242
-396
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+242
-396
lines changed

analysis_options.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ analyzer:
1313
# allow self-reference to deprecated members (we do this because otherwise we have
1414
# to annotate every member in every test, assert, etc, when we deprecate something)
1515
deprecated_member_use_from_same_package: ignore
16-
# Turned off until null-safe rollout is complete.
17-
unnecessary_null_comparison: ignore
1816
exclude: # DIFFERENT FROM FLUTTER/FLUTTER
1917
# Ignore generated files
2018
- '**/*.g.dart'

packages/camera/camera/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.10.5+1
2+
3+
* Removes obsolete null checks on non-nullable values.
4+
15
## 0.10.5
26

37
* Adds NV21 as an image streaming option for Android.

packages/camera/camera/example/lib/main.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
250250
child: Center(
251251
child: AspectRatio(
252252
aspectRatio:
253-
localVideoController.value.size != null
254-
? localVideoController.value.aspectRatio
255-
: 1.0,
253+
localVideoController.value.aspectRatio,
256254
child: VideoPlayer(localVideoController)),
257255
),
258256
),
@@ -1000,7 +998,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
1000998
: VideoPlayerController.file(File(videoFile!.path));
1001999

10021000
videoPlayerListener = () {
1003-
if (videoController != null && videoController!.value.size != null) {
1001+
if (videoController != null) {
10041002
// Refreshing the state to update video player with the correct ratio.
10051003
if (mounted) {
10061004
setState(() {});

packages/camera/camera/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: A Flutter plugin for controlling the camera. Supports previewing
44
Dart.
55
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera
66
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
7-
version: 0.10.5
7+
version: 0.10.5+1
88

99
environment:
1010
sdk: ">=2.18.0 <4.0.0"

packages/camera/camera_android/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.10.8+2
2+
3+
* Removes obsolete null checks on non-nullable values.
4+
15
## 0.10.8+1
26

37
* Fixes lint errors.

packages/camera/camera_android/example/lib/main.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
253253
child: Center(
254254
child: AspectRatio(
255255
aspectRatio:
256-
localVideoController.value.size != null
257-
? localVideoController.value.aspectRatio
258-
: 1.0,
256+
localVideoController.value.aspectRatio,
259257
child: VideoPlayer(localVideoController)),
260258
),
261259
),
@@ -1008,7 +1006,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
10081006
: VideoPlayerController.file(File(videoFile!.path));
10091007

10101008
videoPlayerListener = () {
1011-
if (videoController != null && videoController!.value.size != null) {
1009+
if (videoController != null) {
10121010
// Refreshing the state to update video player with the correct ratio.
10131011
if (mounted) {
10141012
setState(() {});

packages/camera/camera_android/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Android implementation of the camera plugin.
33
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
55

6-
version: 0.10.8+1
6+
version: 0.10.8+2
77

88
environment:
99
sdk: ">=2.18.0 <4.0.0"

packages/camera/camera_android_camerax/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.5.0+4
2+
3+
* Removes obsolete null checks on non-nullable values.
4+
15
## 0.5.0+3
26

37
* Fixes Java lints.

packages/camera/camera_android_camerax/example/lib/main.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
253253
child: Center(
254254
child: AspectRatio(
255255
aspectRatio:
256-
localVideoController.value.size != null
257-
? localVideoController.value.aspectRatio
258-
: 1.0,
256+
localVideoController.value.aspectRatio,
259257
child: VideoPlayer(localVideoController)),
260258
),
261259
),
@@ -985,7 +983,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
985983
: VideoPlayerController.file(File(videoFile!.path));
986984

987985
videoPlayerListener = () {
988-
if (videoController != null && videoController!.value.size != null) {
986+
if (videoController != null) {
989987
// Refreshing the state to update video player with the correct ratio.
990988
if (mounted) {
991989
setState(() {});

packages/camera/camera_android_camerax/lib/src/system_services.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,6 @@ class SystemServicesFlutterApiImpl implements SystemServicesFlutterApi {
125125
void onDeviceOrientationChanged(String orientation) {
126126
final DeviceOrientation deviceOrientation =
127127
deserializeDeviceOrientation(orientation);
128-
if (deviceOrientation == null) {
129-
return;
130-
}
131128
SystemServices.deviceOrientationChangedStreamController
132129
.add(DeviceOrientationChangedEvent(deviceOrientation));
133130
}

0 commit comments

Comments
 (0)