Skip to content

Commit

Permalink
Merge pull request #871 from Lyokone/fix/map_cast_error
Browse files Browse the repository at this point in the history
Fix cast error in `Location.onLocationChanged`
  • Loading branch information
bartekpacia authored Aug 4, 2023
2 parents eef35c5 + 5c38a1a commit 5c8038c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
4 changes: 4 additions & 0 deletions packages/location_platform_interface/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.1.1

- Fix cast error in `Location.onLocationChanged` (#871)

## 3.1.0

- Refactoring (#853)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,15 @@ class MethodChannelLocation extends LocationPlatform {
/// Throws an error if the app has no permission to access location.
@override
Stream<LocationData> get onLocationChanged {
return _onLocationChanged ??=
_eventChannel!.receiveBroadcastStream().map<LocationData>(
(dynamic event) => LocationData.fromMap(
Map<String, dynamic>.of(event as Map<String, dynamic>),
),
);
return _onLocationChanged ??= _eventChannel!
.receiveBroadcastStream()
.map<LocationData>((dynamic event) {
event as Map<Object?, Object?>;

return LocationData.fromMap(
Map<String, dynamic>.of(event.cast<String, dynamic>()),
);
});
}

/// Change options of sticky background notification on Android.
Expand Down
2 changes: 1 addition & 1 deletion packages/location_platform_interface/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: location_platform_interface
description: A common platform interface for the location plugin.
version: 3.1.0
version: 3.1.1
homepage: https://github.com/Lyokone/flutterlocation

environment:
Expand Down

0 comments on commit 5c8038c

Please sign in to comment.