Skip to content

Commit

Permalink
code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-ishita-g committed Dec 27, 2024
1 parent 3cf5cf5 commit 47712af
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class LocateOnMapVieNotifier extends StateNotifier<LocateOnMapState> {
await locationService.getCurrentLocation(_currentUser.id);
if (location != null) {
final latLng =
LatLng(location.first.latitude, location.first.longitude);
LatLng(location.latitude, location.longitude);
state = state.copyWith(
currentLatLng: latLng,
centerPosition:
Expand Down
4 changes: 2 additions & 2 deletions data/lib/service/location_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ class LocationService {
});
}

Future<List<ApiLocation>?> getCurrentLocation(String userId) async {
Future<ApiLocation?> getCurrentLocation(String userId) async {
var snapshot = await _locationRef(userId)
.where("user_id", isEqualTo: userId)
.orderBy('created_at', descending: true)
.limit(1)
.get();

if (snapshot.docs.isNotEmpty) {
return snapshot.docs.map((doc) => doc.data() as ApiLocation).toList();
return snapshot.docs.map((doc) => doc.data() as ApiLocation).first;
}
return null;
}
Expand Down

0 comments on commit 47712af

Please sign in to comment.