From 47712afa2f268d60019feecd59dd2cad8b52cd75 Mon Sep 17 00:00:00 2001 From: cp-ishita-g Date: Fri, 27 Dec 2024 16:41:24 +0530 Subject: [PATCH] code refactoring --- .../ui/flow/geofence/add/locate/locate_on_map_view_model.dart | 2 +- data/lib/service/location_service.dart | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/lib/ui/flow/geofence/add/locate/locate_on_map_view_model.dart b/app/lib/ui/flow/geofence/add/locate/locate_on_map_view_model.dart index 9bfef2ea..a9f5e055 100644 --- a/app/lib/ui/flow/geofence/add/locate/locate_on_map_view_model.dart +++ b/app/lib/ui/flow/geofence/add/locate/locate_on_map_view_model.dart @@ -51,7 +51,7 @@ class LocateOnMapVieNotifier extends StateNotifier { 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: diff --git a/data/lib/service/location_service.dart b/data/lib/service/location_service.dart index ec977120..35037432 100644 --- a/data/lib/service/location_service.dart +++ b/data/lib/service/location_service.dart @@ -42,7 +42,7 @@ class LocationService { }); } - Future?> getCurrentLocation(String userId) async { + Future getCurrentLocation(String userId) async { var snapshot = await _locationRef(userId) .where("user_id", isEqualTo: userId) .orderBy('created_at', descending: true) @@ -50,7 +50,7 @@ class LocationService { .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; }