Skip to content

Commit

Permalink
Update dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbendebiene committed Jul 30, 2024
1 parent 25227c8 commit 7680495
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions lib/view_models/home_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class HomeViewModel extends ViewModel with MakeTickerProvider, PromptMediator, N
/// User Location properties ///
////////////////////////////////
final locationIndicatorController = AnimatedLocationController();
late final locationIndicatorController = AnimatedLocationController(vsync: this);

final _cameraIsFollowingLocation = Observable<bool>(false);
bool get cameraIsFollowingLocation => _cameraIsFollowingLocation.value;
Expand All @@ -144,12 +144,10 @@ class HomeViewModel extends ViewModel with MakeTickerProvider, PromptMediator, N
if (!locationIndicatorController.isActive) {
locationIndicatorController.activate();
}
// if no location permission was granted the initial location is unset, so we need to wait for it
await _locationIsInitialized;
try {
await mapController.animateTo(
ticker: this,
location: locationIndicatorController.rawLocation,
location: await _incomingLocation,
id: 'KeepCameraTracking',
).orCancel;
}
Expand All @@ -162,18 +160,20 @@ class HomeViewModel extends ViewModel with MakeTickerProvider, PromptMediator, N
});
}

Future<void> get _locationIsInitialized async {
if (locationIndicatorController.rawLocation == null) {
final completer = Completer<void>();
// if no location permission was granted the initial location is unset, so we need to wait for it
Future<LatLng> get _incomingLocation async {
if (locationIndicatorController.location == null) {
final completer = Completer<LatLng>();
void complete() {
if (locationIndicatorController.rawLocation != null) {
locationIndicatorController.removeRawListener(complete);
completer.complete();
if (locationIndicatorController.location != null) {
locationIndicatorController.removeListener(complete);
completer.complete(locationIndicatorController.location);
}
}
locationIndicatorController.addRawListener(complete);
locationIndicatorController.addListener(complete);
return completer.future;
}
return locationIndicatorController.location!;
}

Future<bool> _requestLocationPermission() async {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ packages:
description:
path: "."
ref: HEAD
resolved-ref: "7dd0a6d2110989230219b80d88b1078d768b308b"
resolved-ref: c7868193edffc5684bf8e9d5b0a0e9ff90975832
url: "https://github.com/OPENER-next/animated_location_indicator.git"
source: git
version: "1.0.0"
Expand Down

0 comments on commit 7680495

Please sign in to comment.