Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
Fix null-aware operation warn for Flutter 2 and 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Braun committed Jun 6, 2022
1 parent 6c4b8e3 commit 9cc47b0
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 24 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [2.0.0-mb.20] - 06/Jun/2022

- Revert previous changes and solve null-aware operation warning in a way that the package is warn-free for Flutter 2 and 3.

## [2.0.0-mb.19] - 26/May/2022

- Remove unnecessary null-aware operation `!` that throws a compiler warning since Flutter 3.0.1
Expand Down
22 changes: 11 additions & 11 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ packages:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.16.0"
version: "1.15.0"
crypto:
dependency: transitive
description:
Expand All @@ -63,7 +63,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.2.0"
ffi:
dependency: transitive
description:
Expand Down Expand Up @@ -162,7 +162,7 @@ packages:
path: ".."
relative: true
source: path
version: "2.0.0-mb.19"
version: "2.0.0-mb.20"
google_maps_webservice:
dependency: transitive
description:
Expand Down Expand Up @@ -190,7 +190,7 @@ packages:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.4"
version: "0.6.3"
json_annotation:
dependency: transitive
description:
Expand Down Expand Up @@ -232,7 +232,7 @@ packages:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.4"
version: "0.1.3"
meta:
dependency: transitive
description:
Expand Down Expand Up @@ -295,7 +295,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.8.0"
plugin_platform_interface:
dependency: transitive
description:
Expand Down Expand Up @@ -328,7 +328,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.2"
version: "1.8.1"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -370,7 +370,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.9"
version: "0.4.8"
tuple:
dependency: transitive
description:
Expand Down Expand Up @@ -398,7 +398,7 @@ packages:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
version: "2.1.1"
win32:
dependency: transitive
description:
Expand All @@ -407,5 +407,5 @@ packages:
source: hosted
version: "2.2.9"
sdks:
dart: ">=2.17.0-0 <3.0.0"
flutter: ">=2.8.0"
dart: ">=2.15.0 <3.0.0"
flutter: ">=2.10.5"
11 changes: 10 additions & 1 deletion lib/src/autocomplete_search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ class AutoCompleteSearchState extends State<AutoCompleteSearch> {
void initState() {
super.initState();
if (widget.initialSearchString != null) {
WidgetsBinding.instance.addPostFrameCallback((_) {
// ignore:
_ambiguate(WidgetsBinding.instance)!.addPostFrameCallback((_) {

This comment has been minimized.

Copy link
@martin-braun

martin-braun Jun 6, 2022

Member

This will improve #28 and fix fysoul17#173 and #23, so it will run on Flutter 2 and 3.

controller.text = widget.initialSearchString!;
if (widget.searchForInitialValue!) {
_onSearchInputChange();
Expand Down Expand Up @@ -314,4 +315,12 @@ class AutoCompleteSearchState extends State<AutoCompleteSearch> {
clearOverlay() {
_clearOverlay();
}

/// 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.
// TODO: Remove this, once Flutter 2 support is dropped
// See https://github.com/flutter/flutter/issues/64830
T? _ambiguate<T>(T? value) => value;
}
20 changes: 10 additions & 10 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ packages:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.16.0"
version: "1.15.0"
crypto:
dependency: transitive
description:
Expand All @@ -56,7 +56,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.2.0"
ffi:
dependency: transitive
description:
Expand Down Expand Up @@ -176,7 +176,7 @@ packages:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.4"
version: "0.6.3"
json_annotation:
dependency: transitive
description:
Expand Down Expand Up @@ -218,7 +218,7 @@ packages:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.4"
version: "0.1.3"
meta:
dependency: transitive
description:
Expand Down Expand Up @@ -281,7 +281,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.8.0"
plugin_platform_interface:
dependency: transitive
description:
Expand Down Expand Up @@ -314,7 +314,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.2"
version: "1.8.1"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -356,7 +356,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.9"
version: "0.4.8"
tuple:
dependency: "direct main"
description:
Expand Down Expand Up @@ -384,7 +384,7 @@ packages:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
version: "2.1.1"
win32:
dependency: transitive
description:
Expand All @@ -393,5 +393,5 @@ packages:
source: hosted
version: "2.3.1"
sdks:
dart: ">=2.17.0-0 <3.0.0"
flutter: ">=2.8.0"
dart: ">=2.15.0 <3.0.0"
flutter: ">=2.10.5"
5 changes: 3 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: google_maps_place_picker_mb
description: A Flutter plugin which provides 'Picking Place' using Google Maps
widget. (MB version)
version: 2.0.0-mb.19
version: 2.0.0-mb.20
homepage: https://github.com/martin-braun/google_maps_place_picker_mb

environment:
sdk: ">=2.12.0 <3.0.0"
sdk: ">=2.15.0 <3.0.0"
flutter: ">=2.10.5 <4.0.0"

dependencies:
flutter:
Expand Down

1 comment on commit 9cc47b0

@martin-braun
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I now raised the minimum Flutter version to 2.10.5, but downgraded the dart version to 2.15.0 (minimum version required for null-aware operations).

Please sign in to comment.