Skip to content

Commit

Permalink
[camera_android] Removes usage of _ambiguate method in example (flu…
Browse files Browse the repository at this point in the history
…tter#4924)

Since the minimum Flutter version for this package is +3.0, we can remove the `_ambiguate` method.

Part of flutter#111841
  • Loading branch information
nilsreichardt authored Sep 18, 2023
1 parent a26d8a8 commit d4e2454
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
4 changes: 4 additions & 0 deletions packages/camera/camera_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.10.8+9

* Removes usage of `_ambiguate` method in example.

## 0.10.8+8

* Adds pub topics to package metadata.
Expand Down
12 changes: 3 additions & 9 deletions packages/camera/camera_android/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
@override
void initState() {
super.initState();
_ambiguate(WidgetsBinding.instance)?.addObserver(this);
WidgetsBinding.instance.addObserver(this);

_flashModeControlRowAnimationController = AnimationController(
duration: const Duration(milliseconds: 300),
Expand Down Expand Up @@ -105,7 +105,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>

@override
void dispose() {
_ambiguate(WidgetsBinding.instance)?.removeObserver(this);
WidgetsBinding.instance.removeObserver(this);
_flashModeControlRowAnimationController.dispose();
_exposureModeControlRowAnimationController.dispose();
super.dispose();
Expand Down Expand Up @@ -580,7 +580,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
}

if (_cameras.isEmpty) {
_ambiguate(SchedulerBinding.instance)?.addPostFrameCallback((_) async {
SchedulerBinding.instance.addPostFrameCallback((_) async {
showInSnackBar('No camera found.');
});
return const Text('None');
Expand Down Expand Up @@ -1075,9 +1075,3 @@ Future<void> main() async {
}
runApp(const CameraApp());
}

/// This allows a value of type T or T? to be treated as a value of type T?.
///
/// We use this so that APIs that have become non-nullable can still be used
/// with `!` and `?` on the stable branch.
T? _ambiguate<T>(T? value) => value;
2 changes: 1 addition & 1 deletion packages/camera/camera_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Android implementation of the camera plugin.
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22

version: 0.10.8+8
version: 0.10.8+9

environment:
sdk: ">=2.19.0 <4.0.0"
Expand Down

0 comments on commit d4e2454

Please sign in to comment.