From e8e74c9e4713fe71c262c5174f32ab614ce991ac Mon Sep 17 00:00:00 2001 From: kaushik Date: Mon, 8 Jul 2024 16:43:27 +0530 Subject: [PATCH 1/6] Tamp --- app/android/app/src/main/AndroidManifest.xml | 5 + app/lib/ui/flow/home/map/map_view.dart | 11 +- app/lib/ui/flow/home/map/map_view_model.dart | 69 ++++++++-- app/pubspec.lock | 32 +++++ data/.flutter-plugins | 3 + data/.flutter-plugins-dependencies | 2 +- data/lib/service/location_manager.dart | 132 +++++++++++++++++++ data/pubspec.yaml | 1 + 8 files changed, 240 insertions(+), 15 deletions(-) create mode 100644 data/lib/service/location_manager.dart diff --git a/app/android/app/src/main/AndroidManifest.xml b/app/android/app/src/main/AndroidManifest.xml index cc2e8ddd..1e4c6b9f 100644 --- a/app/android/app/src/main/AndroidManifest.xml +++ b/app/android/app/src/main/AndroidManifest.xml @@ -42,6 +42,11 @@ android:name="com.google.android.geo.API_KEY" android:value="${MAPS_API_KEY}" /> + + { onMemberTap: (member) { notifier.showMemberDetail(member); }, - onRelocateTap: () {}, + onRelocateTap: () { + notifier.getUserLastLocation(); + }, onPlacesTap: () { - if (widget.space != null) { - AppRoute.placesList(widget.space!.space.id).push(context); - } + notifier.stopTracing(); + // if (widget.space != null) { + // AppRoute.placesList(widget.space!.space.id).push(context); + // } }, onDismiss: () => notifier.onDismissMemberDetail(), onTapTimeline: () {}, diff --git a/app/lib/ui/flow/home/map/map_view_model.dart b/app/lib/ui/flow/home/map/map_view_model.dart index eff6f836..a04c20f3 100644 --- a/app/lib/ui/flow/home/map/map_view_model.dart +++ b/app/lib/ui/flow/home/map/map_view_model.dart @@ -4,6 +4,7 @@ import 'dart:ui' as ui; import 'package:data/api/auth/auth_models.dart'; import 'package:data/api/place/api_place.dart'; import 'package:data/log/logger.dart'; +import 'package:data/service/location_manager.dart'; import 'package:data/service/permission_service.dart'; import 'package:data/service/place_service.dart'; import 'package:data/service/space_service.dart'; @@ -26,6 +27,7 @@ final mapViewStateProvider = ref.read(spaceServiceProvider), ref.read(placeServiceProvider), ref.read(permissionServiceProvider), + ref.read(locationManagerProvider), ); }); @@ -34,12 +36,14 @@ class MapViewNotifier extends StateNotifier { final SpaceService spaceService; final PlaceService placeService; final PermissionService permissionService; + final LocationManager locationManager; MapViewNotifier( this._currentUser, this.spaceService, this.placeService, this.permissionService, + this.locationManager, ) : super(const MapViewState()); void loadData(String? spaceId) { @@ -98,7 +102,11 @@ class MapViewNotifier extends StateNotifier { final List markers = []; for (final info in userInfo) { if (info.user.id == _currentUser?.id) { - _mapCameraPosition(info); + final latLng = LatLng( + info.location?.latitude ?? 0.0, + info.location?.longitude ?? 0.0, + ); + _mapCameraPosition(latLng, defaultCameraZoom); } if (info.location != null) { @@ -148,15 +156,6 @@ class MapViewNotifier extends StateNotifier { return null; } - void _mapCameraPosition(ApiUserInfo userInfo) { - final position = CameraPosition( - target: LatLng(userInfo.location?.latitude ?? 0.0, - userInfo.location?.longitude ?? 0.0), - zoom: defaultCameraZoom, - ); - state = state.copyWith(defaultPosition: position); - } - void onAddMemberTap(String spaceId) async { try { state = state.copyWith(fetchingInviteCode: true, spaceInvitationCode: ''); @@ -235,6 +234,56 @@ class MapViewNotifier extends StateNotifier { void showEnableLocationDialog() { state = state.copyWith(showLocationDialog: DateTime.now()); } + + void getUserLastLocation() async { + try { + locationManager.configure(); + locationManager.startService(); + // final isEnabled = await permissionService.isLocationServiceEnabled(); + // if (isEnabled) { + // final position = await locationManager.getLastLocation(); + // final latLng = LatLng(position!.latitude, position.longitude); + // _mapCameraPosition(latLng, defaultCameraZoom); + // } else { + // for (final info in state.userInfo) { + // if (info.user.id == _currentUser?.id) { + // final latLng = LatLng( + // info.location?.latitude ?? 0.0, + // info.location?.longitude ?? 0.0, + // ); + // _mapCameraPosition(latLng, defaultCameraZoom); + // } + // } + // } + } catch (error, stack) { + logger.e( + 'MapViewNotifier: Error while getting last location', + error: error, + stackTrace: stack, + ); + } + } + + void _mapCameraPosition(LatLng latLng, double zoom) { + final cameraPosition = CameraPosition( + target: LatLng(latLng.latitude, latLng.longitude), + zoom: zoom, + ); + state = state.copyWith(defaultPosition: cameraPosition); + } + + void stopTracing(){ + print('XXX cal stop'); + try { + locationManager.stopLocationTracking(); + } catch (error, stack) { + logger.e( + 'MapViewNotifier: Error while stopping location', + error: error, + stackTrace: stack, + ); + } + } } @freezed diff --git a/app/pubspec.lock b/app/pubspec.lock index 1bbbf0d3..e26d595c 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -517,6 +517,38 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_background_service: + dependency: transitive + description: + name: flutter_background_service + sha256: "30d1786c7fccba10ba1ca49297bc14343456f24e3dfd4cafc06f35de68d92619" + url: "https://pub.dev" + source: hosted + version: "5.0.6" + flutter_background_service_android: + dependency: transitive + description: + name: flutter_background_service_android + sha256: b28215e18ee743eb78105a5869a802ca7a13b01ed21a0401a4b1c4900b63676e + url: "https://pub.dev" + source: hosted + version: "6.2.3" + flutter_background_service_ios: + dependency: transitive + description: + name: flutter_background_service_ios + sha256: "9365d6b8d71ef967e32320417ea9e2444c82b526930cd6b88adb2c459e7dfc9d" + url: "https://pub.dev" + source: hosted + version: "5.0.1" + flutter_background_service_platform_interface: + dependency: transitive + description: + name: flutter_background_service_platform_interface + sha256: da16560237e055c0ef65bc93597b71d4442698acee983951474f8882c1928ea7 + url: "https://pub.dev" + source: hosted + version: "5.1.0" flutter_cache_manager: dependency: "direct main" description: diff --git a/data/.flutter-plugins b/data/.flutter-plugins index fc05ec80..27a94871 100644 --- a/data/.flutter-plugins +++ b/data/.flutter-plugins @@ -10,6 +10,9 @@ firebase_core=/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core-2.32.0/ firebase_core_web=/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core_web-2.17.1/ firebase_storage=/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage-11.7.7/ firebase_storage_web=/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage_web-3.9.7/ +flutter_background_service=/home/kaushik/.pub-cache/hosted/pub.dev/flutter_background_service-5.0.6/ +flutter_background_service_android=/home/kaushik/.pub-cache/hosted/pub.dev/flutter_background_service_android-6.2.3/ +flutter_background_service_ios=/home/kaushik/.pub-cache/hosted/pub.dev/flutter_background_service_ios-5.0.1/ flutter_timezone=/home/kaushik/.pub-cache/hosted/pub.dev/flutter_timezone-1.0.8/ geolocator=/home/kaushik/.pub-cache/hosted/pub.dev/geolocator-12.0.0/ geolocator_android=/home/kaushik/.pub-cache/hosted/pub.dev/geolocator_android-4.6.0/ diff --git a/data/.flutter-plugins-dependencies b/data/.flutter-plugins-dependencies index 32924483..2930cda9 100644 --- a/data/.flutter-plugins-dependencies +++ b/data/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"cloud_firestore","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_firestore-4.17.5/","native_build":true,"dependencies":["firebase_core"]},{"name":"cloud_functions","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_functions-4.7.6/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","native_build":true,"dependencies":[]},{"name":"firebase_auth","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_auth-4.20.0/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core-2.32.0/","native_build":true,"dependencies":[]},{"name":"firebase_storage","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage-11.7.7/","native_build":true,"dependencies":["firebase_core"]},{"name":"flutter_timezone","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_timezone-1.0.8/","native_build":true,"dependencies":[]},{"name":"geolocator_apple","path":"/home/kaushik/.pub-cache/hosted/pub.dev/geolocator_apple-2.3.7/","native_build":true,"dependencies":[]},{"name":"google_sign_in_ios","path":"/home/kaushik/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.6/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","native_build":true,"dependencies":[]},{"name":"permission_handler_apple","path":"/home/kaushik/.pub-cache/hosted/pub.dev/permission_handler_apple-9.4.5/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.4.0/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"cloud_firestore","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_firestore-4.17.5/","native_build":true,"dependencies":["firebase_core"]},{"name":"cloud_functions","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_functions-4.7.6/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","native_build":true,"dependencies":[]},{"name":"firebase_auth","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_auth-4.20.0/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core-2.32.0/","native_build":true,"dependencies":[]},{"name":"firebase_storage","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage-11.7.7/","native_build":true,"dependencies":["firebase_core"]},{"name":"flutter_timezone","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_timezone-1.0.8/","native_build":true,"dependencies":[]},{"name":"geolocator_android","path":"/home/kaushik/.pub-cache/hosted/pub.dev/geolocator_android-4.6.0/","native_build":true,"dependencies":[]},{"name":"google_sign_in_android","path":"/home/kaushik/.pub-cache/hosted/pub.dev/google_sign_in_android-6.1.24/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","native_build":true,"dependencies":[]},{"name":"permission_handler_android","path":"/home/kaushik/.pub-cache/hosted/pub.dev/permission_handler_android-12.0.7/","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_android-2.2.3/","native_build":true,"dependencies":[]}],"macos":[{"name":"cloud_firestore","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_firestore-4.17.5/","native_build":true,"dependencies":["firebase_core"]},{"name":"cloud_functions","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_functions-4.7.6/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","native_build":true,"dependencies":[]},{"name":"firebase_auth","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_auth-4.20.0/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core-2.32.0/","native_build":true,"dependencies":[]},{"name":"firebase_storage","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage-11.7.7/","native_build":true,"dependencies":["firebase_core"]},{"name":"flutter_timezone","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_timezone-1.0.8/","native_build":true,"dependencies":[]},{"name":"geolocator_apple","path":"/home/kaushik/.pub-cache/hosted/pub.dev/geolocator_apple-2.3.7/","native_build":true,"dependencies":[]},{"name":"google_sign_in_ios","path":"/home/kaushik/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.6/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.4.0/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","native_build":false,"dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","native_build":false,"dependencies":[]},{"name":"path_provider_linux","path":"/home/kaushik/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.3.2/","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"cloud_firestore","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_firestore-4.17.5/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","native_build":false,"dependencies":[]},{"name":"firebase_auth","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_auth-4.20.0/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core-2.32.0/","native_build":true,"dependencies":[]},{"name":"firebase_storage","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage-11.7.7/","native_build":true,"dependencies":["firebase_core"]},{"name":"geolocator_windows","path":"/home/kaushik/.pub-cache/hosted/pub.dev/geolocator_windows-0.2.3/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","native_build":false,"dependencies":[]},{"name":"path_provider_windows","path":"/home/kaushik/.pub-cache/hosted/pub.dev/path_provider_windows-2.2.1/","native_build":false,"dependencies":[]},{"name":"permission_handler_windows","path":"/home/kaushik/.pub-cache/hosted/pub.dev/permission_handler_windows-0.2.1/","native_build":true,"dependencies":[]},{"name":"shared_preferences_windows","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.3.2/","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"cloud_firestore_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_firestore_web-3.12.5/","dependencies":["firebase_core_web"]},{"name":"cloud_functions_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_functions_web-4.9.6/","dependencies":["firebase_core_web"]},{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","dependencies":[]},{"name":"firebase_auth_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_auth_web-5.12.0/","dependencies":["firebase_core_web"]},{"name":"firebase_core_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core_web-2.17.1/","dependencies":[]},{"name":"firebase_storage_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage_web-3.9.7/","dependencies":["firebase_core_web"]},{"name":"flutter_timezone","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_timezone-1.0.8/","dependencies":[]},{"name":"geolocator_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/geolocator_web-4.0.0/","dependencies":[]},{"name":"google_sign_in_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/google_sign_in_web-0.12.4/","dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","dependencies":[]},{"name":"permission_handler_html","path":"/home/kaushik/.pub-cache/hosted/pub.dev/permission_handler_html-0.1.1/","dependencies":[]},{"name":"shared_preferences_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_web-2.3.0/","dependencies":[]}]},"dependencyGraph":[{"name":"cloud_firestore","dependencies":["cloud_firestore_web","firebase_core"]},{"name":"cloud_firestore_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"cloud_functions","dependencies":["cloud_functions_web","firebase_core"]},{"name":"cloud_functions_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"device_info_plus","dependencies":[]},{"name":"firebase_auth","dependencies":["firebase_auth_web","firebase_core"]},{"name":"firebase_auth_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"firebase_core","dependencies":["firebase_core_web"]},{"name":"firebase_core_web","dependencies":[]},{"name":"firebase_storage","dependencies":["firebase_core","firebase_storage_web"]},{"name":"firebase_storage_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"flutter_timezone","dependencies":[]},{"name":"geolocator","dependencies":["geolocator_android","geolocator_apple","geolocator_web","geolocator_windows"]},{"name":"geolocator_android","dependencies":[]},{"name":"geolocator_apple","dependencies":[]},{"name":"geolocator_web","dependencies":[]},{"name":"geolocator_windows","dependencies":[]},{"name":"google_sign_in","dependencies":["google_sign_in_android","google_sign_in_ios","google_sign_in_web"]},{"name":"google_sign_in_android","dependencies":[]},{"name":"google_sign_in_ios","dependencies":[]},{"name":"google_sign_in_web","dependencies":[]},{"name":"package_info_plus","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"permission_handler","dependencies":["permission_handler_android","permission_handler_apple","permission_handler_html","permission_handler_windows"]},{"name":"permission_handler_android","dependencies":[]},{"name":"permission_handler_apple","dependencies":[]},{"name":"permission_handler_html","dependencies":[]},{"name":"permission_handler_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]}],"date_created":"2024-07-03 14:46:27.136362","version":"3.22.2"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"cloud_firestore","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_firestore-4.17.5/","native_build":true,"dependencies":["firebase_core"]},{"name":"cloud_functions","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_functions-4.7.6/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","native_build":true,"dependencies":[]},{"name":"firebase_auth","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_auth-4.20.0/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core-2.32.0/","native_build":true,"dependencies":[]},{"name":"firebase_storage","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage-11.7.7/","native_build":true,"dependencies":["firebase_core"]},{"name":"flutter_background_service_ios","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_background_service_ios-5.0.1/","native_build":true,"dependencies":[]},{"name":"flutter_timezone","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_timezone-1.0.8/","native_build":true,"dependencies":[]},{"name":"geolocator_apple","path":"/home/kaushik/.pub-cache/hosted/pub.dev/geolocator_apple-2.3.7/","native_build":true,"dependencies":[]},{"name":"google_sign_in_ios","path":"/home/kaushik/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.6/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","native_build":true,"dependencies":[]},{"name":"permission_handler_apple","path":"/home/kaushik/.pub-cache/hosted/pub.dev/permission_handler_apple-9.4.5/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.4.0/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"cloud_firestore","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_firestore-4.17.5/","native_build":true,"dependencies":["firebase_core"]},{"name":"cloud_functions","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_functions-4.7.6/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","native_build":true,"dependencies":[]},{"name":"firebase_auth","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_auth-4.20.0/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core-2.32.0/","native_build":true,"dependencies":[]},{"name":"firebase_storage","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage-11.7.7/","native_build":true,"dependencies":["firebase_core"]},{"name":"flutter_background_service_android","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_background_service_android-6.2.3/","native_build":true,"dependencies":[]},{"name":"flutter_timezone","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_timezone-1.0.8/","native_build":true,"dependencies":[]},{"name":"geolocator_android","path":"/home/kaushik/.pub-cache/hosted/pub.dev/geolocator_android-4.6.0/","native_build":true,"dependencies":[]},{"name":"google_sign_in_android","path":"/home/kaushik/.pub-cache/hosted/pub.dev/google_sign_in_android-6.1.24/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","native_build":true,"dependencies":[]},{"name":"permission_handler_android","path":"/home/kaushik/.pub-cache/hosted/pub.dev/permission_handler_android-12.0.7/","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_android-2.2.3/","native_build":true,"dependencies":[]}],"macos":[{"name":"cloud_firestore","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_firestore-4.17.5/","native_build":true,"dependencies":["firebase_core"]},{"name":"cloud_functions","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_functions-4.7.6/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","native_build":true,"dependencies":[]},{"name":"firebase_auth","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_auth-4.20.0/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core-2.32.0/","native_build":true,"dependencies":[]},{"name":"firebase_storage","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage-11.7.7/","native_build":true,"dependencies":["firebase_core"]},{"name":"flutter_timezone","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_timezone-1.0.8/","native_build":true,"dependencies":[]},{"name":"geolocator_apple","path":"/home/kaushik/.pub-cache/hosted/pub.dev/geolocator_apple-2.3.7/","native_build":true,"dependencies":[]},{"name":"google_sign_in_ios","path":"/home/kaushik/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.6/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.4.0/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","native_build":false,"dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","native_build":false,"dependencies":[]},{"name":"path_provider_linux","path":"/home/kaushik/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.3.2/","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"cloud_firestore","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_firestore-4.17.5/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","native_build":false,"dependencies":[]},{"name":"firebase_auth","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_auth-4.20.0/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core-2.32.0/","native_build":true,"dependencies":[]},{"name":"firebase_storage","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage-11.7.7/","native_build":true,"dependencies":["firebase_core"]},{"name":"geolocator_windows","path":"/home/kaushik/.pub-cache/hosted/pub.dev/geolocator_windows-0.2.3/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","native_build":false,"dependencies":[]},{"name":"path_provider_windows","path":"/home/kaushik/.pub-cache/hosted/pub.dev/path_provider_windows-2.2.1/","native_build":false,"dependencies":[]},{"name":"permission_handler_windows","path":"/home/kaushik/.pub-cache/hosted/pub.dev/permission_handler_windows-0.2.1/","native_build":true,"dependencies":[]},{"name":"shared_preferences_windows","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.3.2/","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"cloud_firestore_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_firestore_web-3.12.5/","dependencies":["firebase_core_web"]},{"name":"cloud_functions_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_functions_web-4.9.6/","dependencies":["firebase_core_web"]},{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","dependencies":[]},{"name":"firebase_auth_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_auth_web-5.12.0/","dependencies":["firebase_core_web"]},{"name":"firebase_core_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core_web-2.17.1/","dependencies":[]},{"name":"firebase_storage_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage_web-3.9.7/","dependencies":["firebase_core_web"]},{"name":"flutter_timezone","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_timezone-1.0.8/","dependencies":[]},{"name":"geolocator_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/geolocator_web-4.0.0/","dependencies":[]},{"name":"google_sign_in_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/google_sign_in_web-0.12.4/","dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","dependencies":[]},{"name":"permission_handler_html","path":"/home/kaushik/.pub-cache/hosted/pub.dev/permission_handler_html-0.1.1/","dependencies":[]},{"name":"shared_preferences_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_web-2.3.0/","dependencies":[]}]},"dependencyGraph":[{"name":"cloud_firestore","dependencies":["cloud_firestore_web","firebase_core"]},{"name":"cloud_firestore_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"cloud_functions","dependencies":["cloud_functions_web","firebase_core"]},{"name":"cloud_functions_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"device_info_plus","dependencies":[]},{"name":"firebase_auth","dependencies":["firebase_auth_web","firebase_core"]},{"name":"firebase_auth_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"firebase_core","dependencies":["firebase_core_web"]},{"name":"firebase_core_web","dependencies":[]},{"name":"firebase_storage","dependencies":["firebase_core","firebase_storage_web"]},{"name":"firebase_storage_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"flutter_background_service","dependencies":["flutter_background_service_android","flutter_background_service_ios"]},{"name":"flutter_background_service_android","dependencies":[]},{"name":"flutter_background_service_ios","dependencies":[]},{"name":"flutter_timezone","dependencies":[]},{"name":"geolocator","dependencies":["geolocator_android","geolocator_apple","geolocator_web","geolocator_windows"]},{"name":"geolocator_android","dependencies":[]},{"name":"geolocator_apple","dependencies":[]},{"name":"geolocator_web","dependencies":[]},{"name":"geolocator_windows","dependencies":[]},{"name":"google_sign_in","dependencies":["google_sign_in_android","google_sign_in_ios","google_sign_in_web"]},{"name":"google_sign_in_android","dependencies":[]},{"name":"google_sign_in_ios","dependencies":[]},{"name":"google_sign_in_web","dependencies":[]},{"name":"package_info_plus","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"permission_handler","dependencies":["permission_handler_android","permission_handler_apple","permission_handler_html","permission_handler_windows"]},{"name":"permission_handler_android","dependencies":[]},{"name":"permission_handler_apple","dependencies":[]},{"name":"permission_handler_html","dependencies":[]},{"name":"permission_handler_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]}],"date_created":"2024-07-08 11:54:45.212001","version":"3.22.2"} \ No newline at end of file diff --git a/data/lib/service/location_manager.dart b/data/lib/service/location_manager.dart new file mode 100644 index 00000000..d95d3b6a --- /dev/null +++ b/data/lib/service/location_manager.dart @@ -0,0 +1,132 @@ +import 'dart:async'; + +import 'package:data/service/permission_service.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter_background_service/flutter_background_service.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:geolocator/geolocator.dart'; +import 'package:permission_handler/permission_handler.dart'; + +const int locationUpdateInterval = 10000; // milliseconds +const double locationUpdateDistance = 10.0; // meters + +final locationManagerProvider = + Provider((ref) => LocationManager(ref.read(permissionServiceProvider))); + +class LocationManager { + final PermissionService permissionService; + final backGroundService = FlutterBackgroundService(); + Position? _lastLocation; + Timer? _locationUpdateTimer; + + LocationManager(this.permissionService); + + Stream getLiveGeoLocatorData() { + LocationSettings locationSettings; + + if (defaultTargetPlatform == TargetPlatform.android) { + locationSettings = AndroidSettings( + accuracy: LocationAccuracy.high, + distanceFilter: locationUpdateDistance.toInt(), + intervalDuration: const Duration(milliseconds: locationUpdateInterval) + ); + } else { + locationSettings = const LocationSettings( + accuracy: LocationAccuracy.high, + distanceFilter: 100, + ); + } + + return Geolocator.getPositionStream(locationSettings: locationSettings); + } + + void configure() { + getLiveGeoLocatorData().listen((position) { + + final distance = Geolocator.distanceBetween( + _lastLocation!.latitude, + _lastLocation!.longitude, + position.latitude, + position.longitude, + ); + print('Location distance:$distance update: $position'); + _lastLocation = position; + }); + // Geolocator.getPositionStream( + // locationSettings: LocationSettings( + // accuracy: LocationAccuracy.best, + // distanceFilter: locationUpdateDistance.toInt(), + // timeLimit: Duration(seconds: 10) + // ), + // ).listen((Position position) { + // print('Location update: $position'); + // _lastLocation = position; + // // Handle location update here + // }); + } + + Future getLastLocation() async { + if (!await permissionService.isLocationServiceEnabled()) { + return null; + } + + if (await Permission.location.isDenied) { + await Permission.location.request(); + if (await Permission.location.isDenied) { + return null; + } + } + + final lastLocation = await Geolocator.getLastKnownPosition(); + return lastLocation; + } + + void stopLocationTracking() { + _locationUpdateTimer?.cancel(); + stopService(); + } + + void startService() async { + await backGroundService.configure( + androidConfiguration: AndroidConfiguration( + onStart: onStart, + autoStart: true, + isForegroundMode: true, + ), + iosConfiguration: IosConfiguration( + autoStart: true, + onForeground: onStart, + onBackground: onIosBackground, + ), + ); + backGroundService.startService(); + } + + void stopService() { + FlutterBackgroundService().invoke("stopService"); + } + + static void onStart(ServiceInstance service) { + WidgetsFlutterBinding.ensureInitialized(); + + if (service is AndroidServiceInstance) { + service.setForegroundNotificationInfo( + title: "Background Location Service", + content: "Your location is being tracked", + ); + service.setAsForegroundService(); + service.setAsBackgroundService(); + } + + service.on('stopService').listen((event) { + service.stopSelf(); + }); + } + + static bool onIosBackground(ServiceInstance service) { + WidgetsFlutterBinding.ensureInitialized(); + onStart(service); + return true; + } +} diff --git a/data/pubspec.yaml b/data/pubspec.yaml index 96929166..7d6dd439 100644 --- a/data/pubspec.yaml +++ b/data/pubspec.yaml @@ -25,6 +25,7 @@ dependencies: uuid: ^4.4.0 permission_handler: ^11.3.1 geolocator: ^12.0.0 + flutter_background_service: ^5.0.6 dev_dependencies: flutter_test: From 9c729bd4c5c6ffa72b639fbc0061f9e2d79c378f Mon Sep 17 00:00:00 2001 From: kaushik Date: Wed, 10 Jul 2024 16:04:07 +0530 Subject: [PATCH 2/6] Fix location update --- app/android/app/src/main/AndroidManifest.xml | 7 +- app/android/settings.gradle | 1 + app/lib/main.dart | 93 ++++++++++- app/lib/ui/flow/home/home_screen.dart | 2 +- .../ui/flow/home/home_screen_viewmodel.dart | 32 +++- .../selected_member_detail_view.dart | 2 + app/lib/ui/flow/home/map/map_view.dart | 11 +- app/lib/ui/flow/home/map/map_view_model.dart | 48 ++---- .../setting/profile/profile_view_model.dart | 25 ++- app/pubspec.lock | 2 +- app/pubspec.yaml | 1 + data/.flutter-plugins-dependencies | 2 +- data/lib/api/auth/api_user_service.dart | 20 ++- data/lib/service/location_manager.dart | 146 +++++++++--------- data/lib/service/location_service.dart | 21 +++ firebase-debug.log | 21 +++ 16 files changed, 298 insertions(+), 136 deletions(-) create mode 100644 firebase-debug.log diff --git a/app/android/app/src/main/AndroidManifest.xml b/app/android/app/src/main/AndroidManifest.xml index 1e4c6b9f..4e4366dd 100644 --- a/app/android/app/src/main/AndroidManifest.xml +++ b/app/android/app/src/main/AndroidManifest.xml @@ -6,6 +6,7 @@ + + android:foregroundServiceType="location" + /> diff --git a/app/android/settings.gradle b/app/android/settings.gradle index 7cd71285..1df00a42 100644 --- a/app/android/settings.gradle +++ b/app/android/settings.gradle @@ -24,6 +24,7 @@ pluginManagement { plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" id "com.android.application" version "7.3.0" apply false + id "com.google.gms.google-services" version "4.3.15" apply false } include ":app" diff --git a/app/lib/main.dart b/app/lib/main.dart index c28a7c24..c2c091f8 100644 --- a/app/lib/main.dart +++ b/app/lib/main.dart @@ -1,15 +1,21 @@ +import 'dart:async'; +import 'dart:convert'; import 'dart:io'; +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:data/service/location_service.dart'; import 'package:data/storage/preferences_provider.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_background_service/flutter_background_service.dart'; import 'package:flutter_displaymode/flutter_displaymode.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:geolocator/geolocator.dart'; +import 'package:permission_handler/permission_handler.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:yourspace_flutter/firebase_options.dart'; import 'package:yourspace_flutter/ui/app.dart'; - void main() async { WidgetsFlutterBinding.ensureInitialized(); if (Platform.isAndroid) { @@ -18,6 +24,11 @@ void main() async { } final container = await _initContainer(); + final userId = await _getUserIdFromPreferences(); + final isLocationPermission = await Permission.location.isGranted; + if (userId != null && isLocationPermission) { + startService(userId); + } runApp( UncontrolledProviderScope(container: container, child: const App()), @@ -35,4 +46,82 @@ Future _initContainer() async { ], ); return container; -} \ No newline at end of file +} + +Future _getUserIdFromPreferences() async { + final prefs = await SharedPreferences.getInstance(); + final encodedUser = prefs.getString("user_account"); + if (encodedUser != null) { + final user = jsonDecode(encodedUser); + return user['id']; + } + return null; +} + +void startService(String userId) async { + final service = FlutterBackgroundService(); + await service.configure( + androidConfiguration: AndroidConfiguration( + onStart: onStart, + autoStart: true, + isForegroundMode: true, + ), + iosConfiguration: IosConfiguration( + autoStart: true, + onForeground: onStart, + onBackground: onIosBackground, + ), + ); + service.startService(); +} + +Future onStart(ServiceInstance service) async { + WidgetsFlutterBinding.ensureInitialized(); + + if (service is AndroidServiceInstance) { + service.setForegroundNotificationInfo( + title: "Background Location Service", + content: "Your location is being tracked", + ); + service.setAsForegroundService(); + } + + await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); + final locationService = LocationService(FirebaseFirestore.instance); + final userId = await _getUserIdFromPreferences(); + + if (userId != null) { + _startLocationUpdates(userId, locationService); + } + + service.on('stopService').listen((event) { + service.stopSelf(); + }); +} + +void _startLocationUpdates(String userId, LocationService locationService) { + Timer? timer; + Geolocator.getPositionStream( + locationSettings: const LocationSettings( + accuracy: LocationAccuracy.high, + distanceFilter: 10, + ), + ).listen((position) { + timer?.cancel(); + timer = Timer(const Duration(milliseconds: 5000), () { + locationService.saveCurrentLocation( + userId, + position.latitude, + position.longitude, + DateTime.now().millisecondsSinceEpoch, + 0, + ); + }); + }); +} + +bool onIosBackground(ServiceInstance service) { + WidgetsFlutterBinding.ensureInitialized(); + onStart(service); + return true; +} diff --git a/app/lib/ui/flow/home/home_screen.dart b/app/lib/ui/flow/home/home_screen.dart index c9cf18af..963dba52 100644 --- a/app/lib/ui/flow/home/home_screen.dart +++ b/app/lib/ui/flow/home/home_screen.dart @@ -47,7 +47,7 @@ class _HomeScreenState extends ConsumerState { return AppPage( body: ResumeDetector( onResume: () { - if(state.selectedSpace != null){ + if(state.selectedSpace != null) { notifier.getAllSpace(); notifier.showBatteryOptimizationDialog(); mapNotifier.checkUserPermission(); diff --git a/app/lib/ui/flow/home/home_screen_viewmodel.dart b/app/lib/ui/flow/home/home_screen_viewmodel.dart index 84abdcf1..af254e04 100644 --- a/app/lib/ui/flow/home/home_screen_viewmodel.dart +++ b/app/lib/ui/flow/home/home_screen_viewmodel.dart @@ -1,5 +1,8 @@ +import 'package:data/api/auth/auth_models.dart'; import 'package:data/api/space/space_models.dart'; import 'package:data/log/logger.dart'; +import 'package:data/service/location_manager.dart'; +import 'package:data/service/location_service.dart'; import 'package:data/service/permission_service.dart'; import 'package:data/service/space_service.dart'; import 'package:data/storage/app_preferences.dart'; @@ -15,6 +18,9 @@ final homeViewStateProvider = ref.read(currentUserSessionJsonPod.notifier), ref.read(permissionServiceProvider), ref.read(lastBatteryDialogPod.notifier), + ref.read(locationManagerProvider), + ref.read(currentUserPod), + ref.read(locationServiceProvider), ), ); @@ -23,13 +29,19 @@ class HomeViewNotifier extends StateNotifier { final PermissionService permissionService; final StateController _currentSpaceIdController; final StateController _lastBatteryDialogDate; + final LocationManager locationManager; + final ApiUser? _currentUser; + final LocationService locationService; HomeViewNotifier( - this.spaceService, - this._currentSpaceIdController, - this.permissionService, - this._lastBatteryDialogDate, - ) : super(const HomeViewState()); + this.spaceService, + this._currentSpaceIdController, + this.permissionService, + this._lastBatteryDialogDate, + this.locationManager, + this._currentUser, + this.locationService) + : super(const HomeViewState()); String? get currentSpaceId => _currentSpaceIdController.state; @@ -92,6 +104,7 @@ class HomeViewNotifier extends StateNotifier { state = state.copyWith(selectedSpace: space); currentSpaceId = space.space.id; } + // startLocationTracking(); } void showBatteryOptimizationDialog() async { @@ -127,6 +140,15 @@ class HomeViewNotifier extends StateNotifier { void requestIgnoreBatteryOptimizations() async { await permissionService.requestIgnoreBatteryOptimizations(); } + + void startLocationTracking() async { + final isLocationEnabled = + await permissionService.isLocationPermissionGranted(); + + if (isLocationEnabled) { + locationManager.startService(_currentUser!.id); + } + } } @freezed diff --git a/app/lib/ui/flow/home/map/components/selected_member_detail_view.dart b/app/lib/ui/flow/home/map/components/selected_member_detail_view.dart index 09e9656a..7b77c154 100644 --- a/app/lib/ui/flow/home/map/components/selected_member_detail_view.dart +++ b/app/lib/ui/flow/home/map/components/selected_member_detail_view.dart @@ -178,6 +178,8 @@ class _SelectedMemberDetailViewState extends State { } void getAddress(ApiLocation? location) async { + if(!mounted) return; + if (location != null) { final latLng = LatLng(location.latitude, location.longitude); final address = await latLng.getAddressFromLocation(); diff --git a/app/lib/ui/flow/home/map/map_view.dart b/app/lib/ui/flow/home/map/map_view.dart index 0213d620..f6fd7796 100644 --- a/app/lib/ui/flow/home/map/map_view.dart +++ b/app/lib/ui/flow/home/map/map_view.dart @@ -104,14 +104,11 @@ class _MapScreenState extends ConsumerState { onMemberTap: (member) { notifier.showMemberDetail(member); }, - onRelocateTap: () { - notifier.getUserLastLocation(); - }, + onRelocateTap: () => notifier.getUserLastLocation(), onPlacesTap: () { - notifier.stopTracing(); - // if (widget.space != null) { - // AppRoute.placesList(widget.space!.space.id).push(context); - // } + if (widget.space != null) { + AppRoute.placesList(widget.space!.space.id).push(context); + } }, onDismiss: () => notifier.onDismissMemberDetail(), onTapTimeline: () {}, diff --git a/app/lib/ui/flow/home/map/map_view_model.dart b/app/lib/ui/flow/home/map/map_view_model.dart index a04c20f3..7d96f6f9 100644 --- a/app/lib/ui/flow/home/map/map_view_model.dart +++ b/app/lib/ui/flow/home/map/map_view_model.dart @@ -237,24 +237,23 @@ class MapViewNotifier extends StateNotifier { void getUserLastLocation() async { try { - locationManager.configure(); - locationManager.startService(); - // final isEnabled = await permissionService.isLocationServiceEnabled(); - // if (isEnabled) { - // final position = await locationManager.getLastLocation(); - // final latLng = LatLng(position!.latitude, position.longitude); - // _mapCameraPosition(latLng, defaultCameraZoom); - // } else { - // for (final info in state.userInfo) { - // if (info.user.id == _currentUser?.id) { - // final latLng = LatLng( - // info.location?.latitude ?? 0.0, - // info.location?.longitude ?? 0.0, - // ); - // _mapCameraPosition(latLng, defaultCameraZoom); - // } - // } - // } + state = state.copyWith(defaultPosition: null); + final isEnabled = await permissionService.isLocationPermissionGranted(); + if (isEnabled) { + final position = await locationManager.getLastLocation(); + final latLng = LatLng(position!.latitude, position.longitude); + _mapCameraPosition(latLng, defaultCameraZoom); + } else { + for (final info in state.userInfo) { + if (info.user.id == _currentUser?.id) { + final latLng = LatLng( + info.location?.latitude ?? 0.0, + info.location?.longitude ?? 0.0, + ); + _mapCameraPosition(latLng, defaultCameraZoom); + } + } + } } catch (error, stack) { logger.e( 'MapViewNotifier: Error while getting last location', @@ -271,19 +270,6 @@ class MapViewNotifier extends StateNotifier { ); state = state.copyWith(defaultPosition: cameraPosition); } - - void stopTracing(){ - print('XXX cal stop'); - try { - locationManager.stopLocationTracking(); - } catch (error, stack) { - logger.e( - 'MapViewNotifier: Error while stopping location', - error: error, - stackTrace: stack, - ); - } - } } @freezed diff --git a/app/lib/ui/flow/setting/profile/profile_view_model.dart b/app/lib/ui/flow/setting/profile/profile_view_model.dart index 7b8e58e1..222ecfa3 100644 --- a/app/lib/ui/flow/setting/profile/profile_view_model.dart +++ b/app/lib/ui/flow/setting/profile/profile_view_model.dart @@ -3,21 +3,23 @@ import 'dart:io'; import 'package:data/api/auth/auth_models.dart'; import 'package:data/log/logger.dart'; import 'package:data/service/auth_service.dart'; +import 'package:data/service/location_manager.dart'; +import 'package:data/service/space_service.dart'; import 'package:data/storage/app_preferences.dart'; import 'package:firebase_storage/firebase_storage.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:data/service/space_service.dart'; part 'profile_view_model.freezed.dart'; -final editProfileViewStateProvider = - StateNotifierProvider.autoDispose( +final editProfileViewStateProvider = StateNotifierProvider.autoDispose< + EditProfileViewNotifier, EditProfileViewState>( (ref) => EditProfileViewNotifier( ref.read(spaceServiceProvider), ref.read(authServiceProvider), ref.read(currentUserPod), + ref.read(locationManagerProvider), ), ); @@ -25,9 +27,14 @@ class EditProfileViewNotifier extends StateNotifier { final SpaceService spaceService; final AuthService authService; final ApiUser? user; - - EditProfileViewNotifier(this.spaceService, this.authService, this.user) - : super(EditProfileViewState( + final LocationManager locationManager; + + EditProfileViewNotifier( + this.spaceService, + this.authService, + this.user, + this.locationManager, + ) : super(EditProfileViewState( firstName: TextEditingController(text: user?.first_name), lastName: TextEditingController(text: user?.last_name), email: TextEditingController(text: user?.email), @@ -43,6 +50,7 @@ class EditProfileViewNotifier extends StateNotifier { spaceService.deleteUserSpaces(); authService.deleteUser(); state = state.copyWith(deletingAccount: true, accountDeleted: true); + locationManager.stopService(); } catch (error, stack) { logger.e( 'EditProfileViewState: error while delete account', @@ -69,7 +77,7 @@ class EditProfileViewNotifier extends StateNotifier { logger.e( 'EditProfileViewNotifier: error while update user profile', error: error, - stackTrace: stack + stackTrace: stack, ); state = state.copyWith(error: error); } @@ -114,7 +122,8 @@ class EditProfileViewNotifier extends StateNotifier { error: error, stackTrace: stack, ); - state = state.copyWith(profileUrl: '', uploadingImage: false, error: error); + state = + state.copyWith(profileUrl: '', uploadingImage: false, error: error); onChange(); } } diff --git a/app/pubspec.lock b/app/pubspec.lock index e26d595c..6e6f5c9e 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -518,7 +518,7 @@ packages: source: sdk version: "0.0.0" flutter_background_service: - dependency: transitive + dependency: "direct main" description: name: flutter_background_service sha256: "30d1786c7fccba10ba1ca49297bc14343456f24e3dfd4cafc06f35de68d92619" diff --git a/app/pubspec.yaml b/app/pubspec.yaml index b1a4ac3f..66a78a70 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -74,6 +74,7 @@ dependencies: flutter_svg: ^2.0.9 # picker canopas_country_picker: ^0.0.4 + flutter_background_service: ^5.0.6 dev_dependencies: flutter_test: diff --git a/data/.flutter-plugins-dependencies b/data/.flutter-plugins-dependencies index 2930cda9..bbd4c766 100644 --- a/data/.flutter-plugins-dependencies +++ b/data/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"cloud_firestore","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_firestore-4.17.5/","native_build":true,"dependencies":["firebase_core"]},{"name":"cloud_functions","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_functions-4.7.6/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","native_build":true,"dependencies":[]},{"name":"firebase_auth","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_auth-4.20.0/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core-2.32.0/","native_build":true,"dependencies":[]},{"name":"firebase_storage","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage-11.7.7/","native_build":true,"dependencies":["firebase_core"]},{"name":"flutter_background_service_ios","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_background_service_ios-5.0.1/","native_build":true,"dependencies":[]},{"name":"flutter_timezone","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_timezone-1.0.8/","native_build":true,"dependencies":[]},{"name":"geolocator_apple","path":"/home/kaushik/.pub-cache/hosted/pub.dev/geolocator_apple-2.3.7/","native_build":true,"dependencies":[]},{"name":"google_sign_in_ios","path":"/home/kaushik/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.6/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","native_build":true,"dependencies":[]},{"name":"permission_handler_apple","path":"/home/kaushik/.pub-cache/hosted/pub.dev/permission_handler_apple-9.4.5/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.4.0/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"cloud_firestore","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_firestore-4.17.5/","native_build":true,"dependencies":["firebase_core"]},{"name":"cloud_functions","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_functions-4.7.6/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","native_build":true,"dependencies":[]},{"name":"firebase_auth","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_auth-4.20.0/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core-2.32.0/","native_build":true,"dependencies":[]},{"name":"firebase_storage","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage-11.7.7/","native_build":true,"dependencies":["firebase_core"]},{"name":"flutter_background_service_android","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_background_service_android-6.2.3/","native_build":true,"dependencies":[]},{"name":"flutter_timezone","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_timezone-1.0.8/","native_build":true,"dependencies":[]},{"name":"geolocator_android","path":"/home/kaushik/.pub-cache/hosted/pub.dev/geolocator_android-4.6.0/","native_build":true,"dependencies":[]},{"name":"google_sign_in_android","path":"/home/kaushik/.pub-cache/hosted/pub.dev/google_sign_in_android-6.1.24/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","native_build":true,"dependencies":[]},{"name":"permission_handler_android","path":"/home/kaushik/.pub-cache/hosted/pub.dev/permission_handler_android-12.0.7/","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_android-2.2.3/","native_build":true,"dependencies":[]}],"macos":[{"name":"cloud_firestore","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_firestore-4.17.5/","native_build":true,"dependencies":["firebase_core"]},{"name":"cloud_functions","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_functions-4.7.6/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","native_build":true,"dependencies":[]},{"name":"firebase_auth","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_auth-4.20.0/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core-2.32.0/","native_build":true,"dependencies":[]},{"name":"firebase_storage","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage-11.7.7/","native_build":true,"dependencies":["firebase_core"]},{"name":"flutter_timezone","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_timezone-1.0.8/","native_build":true,"dependencies":[]},{"name":"geolocator_apple","path":"/home/kaushik/.pub-cache/hosted/pub.dev/geolocator_apple-2.3.7/","native_build":true,"dependencies":[]},{"name":"google_sign_in_ios","path":"/home/kaushik/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.6/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.4.0/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","native_build":false,"dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","native_build":false,"dependencies":[]},{"name":"path_provider_linux","path":"/home/kaushik/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.3.2/","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"cloud_firestore","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_firestore-4.17.5/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","native_build":false,"dependencies":[]},{"name":"firebase_auth","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_auth-4.20.0/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core-2.32.0/","native_build":true,"dependencies":[]},{"name":"firebase_storage","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage-11.7.7/","native_build":true,"dependencies":["firebase_core"]},{"name":"geolocator_windows","path":"/home/kaushik/.pub-cache/hosted/pub.dev/geolocator_windows-0.2.3/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","native_build":false,"dependencies":[]},{"name":"path_provider_windows","path":"/home/kaushik/.pub-cache/hosted/pub.dev/path_provider_windows-2.2.1/","native_build":false,"dependencies":[]},{"name":"permission_handler_windows","path":"/home/kaushik/.pub-cache/hosted/pub.dev/permission_handler_windows-0.2.1/","native_build":true,"dependencies":[]},{"name":"shared_preferences_windows","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.3.2/","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"cloud_firestore_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_firestore_web-3.12.5/","dependencies":["firebase_core_web"]},{"name":"cloud_functions_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_functions_web-4.9.6/","dependencies":["firebase_core_web"]},{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","dependencies":[]},{"name":"firebase_auth_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_auth_web-5.12.0/","dependencies":["firebase_core_web"]},{"name":"firebase_core_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core_web-2.17.1/","dependencies":[]},{"name":"firebase_storage_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage_web-3.9.7/","dependencies":["firebase_core_web"]},{"name":"flutter_timezone","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_timezone-1.0.8/","dependencies":[]},{"name":"geolocator_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/geolocator_web-4.0.0/","dependencies":[]},{"name":"google_sign_in_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/google_sign_in_web-0.12.4/","dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","dependencies":[]},{"name":"permission_handler_html","path":"/home/kaushik/.pub-cache/hosted/pub.dev/permission_handler_html-0.1.1/","dependencies":[]},{"name":"shared_preferences_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_web-2.3.0/","dependencies":[]}]},"dependencyGraph":[{"name":"cloud_firestore","dependencies":["cloud_firestore_web","firebase_core"]},{"name":"cloud_firestore_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"cloud_functions","dependencies":["cloud_functions_web","firebase_core"]},{"name":"cloud_functions_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"device_info_plus","dependencies":[]},{"name":"firebase_auth","dependencies":["firebase_auth_web","firebase_core"]},{"name":"firebase_auth_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"firebase_core","dependencies":["firebase_core_web"]},{"name":"firebase_core_web","dependencies":[]},{"name":"firebase_storage","dependencies":["firebase_core","firebase_storage_web"]},{"name":"firebase_storage_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"flutter_background_service","dependencies":["flutter_background_service_android","flutter_background_service_ios"]},{"name":"flutter_background_service_android","dependencies":[]},{"name":"flutter_background_service_ios","dependencies":[]},{"name":"flutter_timezone","dependencies":[]},{"name":"geolocator","dependencies":["geolocator_android","geolocator_apple","geolocator_web","geolocator_windows"]},{"name":"geolocator_android","dependencies":[]},{"name":"geolocator_apple","dependencies":[]},{"name":"geolocator_web","dependencies":[]},{"name":"geolocator_windows","dependencies":[]},{"name":"google_sign_in","dependencies":["google_sign_in_android","google_sign_in_ios","google_sign_in_web"]},{"name":"google_sign_in_android","dependencies":[]},{"name":"google_sign_in_ios","dependencies":[]},{"name":"google_sign_in_web","dependencies":[]},{"name":"package_info_plus","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"permission_handler","dependencies":["permission_handler_android","permission_handler_apple","permission_handler_html","permission_handler_windows"]},{"name":"permission_handler_android","dependencies":[]},{"name":"permission_handler_apple","dependencies":[]},{"name":"permission_handler_html","dependencies":[]},{"name":"permission_handler_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]}],"date_created":"2024-07-08 11:54:45.212001","version":"3.22.2"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"cloud_firestore","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_firestore-4.17.5/","native_build":true,"dependencies":["firebase_core"]},{"name":"cloud_functions","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_functions-4.7.6/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","native_build":true,"dependencies":[]},{"name":"firebase_auth","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_auth-4.20.0/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core-2.32.0/","native_build":true,"dependencies":[]},{"name":"firebase_storage","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage-11.7.7/","native_build":true,"dependencies":["firebase_core"]},{"name":"flutter_background_service_ios","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_background_service_ios-5.0.1/","native_build":true,"dependencies":[]},{"name":"flutter_timezone","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_timezone-1.0.8/","native_build":true,"dependencies":[]},{"name":"geolocator_apple","path":"/home/kaushik/.pub-cache/hosted/pub.dev/geolocator_apple-2.3.7/","native_build":true,"dependencies":[]},{"name":"google_sign_in_ios","path":"/home/kaushik/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.6/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","native_build":true,"dependencies":[]},{"name":"permission_handler_apple","path":"/home/kaushik/.pub-cache/hosted/pub.dev/permission_handler_apple-9.4.5/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.4.0/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"cloud_firestore","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_firestore-4.17.5/","native_build":true,"dependencies":["firebase_core"]},{"name":"cloud_functions","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_functions-4.7.6/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","native_build":true,"dependencies":[]},{"name":"firebase_auth","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_auth-4.20.0/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core-2.32.0/","native_build":true,"dependencies":[]},{"name":"firebase_storage","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage-11.7.7/","native_build":true,"dependencies":["firebase_core"]},{"name":"flutter_background_service_android","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_background_service_android-6.2.3/","native_build":true,"dependencies":[]},{"name":"flutter_timezone","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_timezone-1.0.8/","native_build":true,"dependencies":[]},{"name":"geolocator_android","path":"/home/kaushik/.pub-cache/hosted/pub.dev/geolocator_android-4.6.0/","native_build":true,"dependencies":[]},{"name":"google_sign_in_android","path":"/home/kaushik/.pub-cache/hosted/pub.dev/google_sign_in_android-6.1.24/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","native_build":true,"dependencies":[]},{"name":"permission_handler_android","path":"/home/kaushik/.pub-cache/hosted/pub.dev/permission_handler_android-12.0.7/","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_android-2.2.3/","native_build":true,"dependencies":[]}],"macos":[{"name":"cloud_firestore","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_firestore-4.17.5/","native_build":true,"dependencies":["firebase_core"]},{"name":"cloud_functions","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_functions-4.7.6/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","native_build":true,"dependencies":[]},{"name":"firebase_auth","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_auth-4.20.0/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core-2.32.0/","native_build":true,"dependencies":[]},{"name":"firebase_storage","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage-11.7.7/","native_build":true,"dependencies":["firebase_core"]},{"name":"flutter_timezone","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_timezone-1.0.8/","native_build":true,"dependencies":[]},{"name":"geolocator_apple","path":"/home/kaushik/.pub-cache/hosted/pub.dev/geolocator_apple-2.3.7/","native_build":true,"dependencies":[]},{"name":"google_sign_in_ios","path":"/home/kaushik/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.6/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.4.0/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","native_build":false,"dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","native_build":false,"dependencies":[]},{"name":"path_provider_linux","path":"/home/kaushik/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.3.2/","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"cloud_firestore","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_firestore-4.17.5/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","native_build":false,"dependencies":[]},{"name":"firebase_auth","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_auth-4.20.0/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core-2.32.0/","native_build":true,"dependencies":[]},{"name":"firebase_storage","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage-11.7.7/","native_build":true,"dependencies":["firebase_core"]},{"name":"geolocator_windows","path":"/home/kaushik/.pub-cache/hosted/pub.dev/geolocator_windows-0.2.3/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","native_build":false,"dependencies":[]},{"name":"path_provider_windows","path":"/home/kaushik/.pub-cache/hosted/pub.dev/path_provider_windows-2.2.1/","native_build":false,"dependencies":[]},{"name":"permission_handler_windows","path":"/home/kaushik/.pub-cache/hosted/pub.dev/permission_handler_windows-0.2.1/","native_build":true,"dependencies":[]},{"name":"shared_preferences_windows","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.3.2/","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"cloud_firestore_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_firestore_web-3.12.5/","dependencies":["firebase_core_web"]},{"name":"cloud_functions_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_functions_web-4.9.6/","dependencies":["firebase_core_web"]},{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","dependencies":[]},{"name":"firebase_auth_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_auth_web-5.12.0/","dependencies":["firebase_core_web"]},{"name":"firebase_core_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core_web-2.17.1/","dependencies":[]},{"name":"firebase_storage_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage_web-3.9.7/","dependencies":["firebase_core_web"]},{"name":"flutter_timezone","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_timezone-1.0.8/","dependencies":[]},{"name":"geolocator_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/geolocator_web-4.0.0/","dependencies":[]},{"name":"google_sign_in_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/google_sign_in_web-0.12.4/","dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","dependencies":[]},{"name":"permission_handler_html","path":"/home/kaushik/.pub-cache/hosted/pub.dev/permission_handler_html-0.1.1/","dependencies":[]},{"name":"shared_preferences_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_web-2.3.0/","dependencies":[]}]},"dependencyGraph":[{"name":"cloud_firestore","dependencies":["cloud_firestore_web","firebase_core"]},{"name":"cloud_firestore_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"cloud_functions","dependencies":["cloud_functions_web","firebase_core"]},{"name":"cloud_functions_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"device_info_plus","dependencies":[]},{"name":"firebase_auth","dependencies":["firebase_auth_web","firebase_core"]},{"name":"firebase_auth_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"firebase_core","dependencies":["firebase_core_web"]},{"name":"firebase_core_web","dependencies":[]},{"name":"firebase_storage","dependencies":["firebase_core","firebase_storage_web"]},{"name":"firebase_storage_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"flutter_background_service","dependencies":["flutter_background_service_android","flutter_background_service_ios"]},{"name":"flutter_background_service_android","dependencies":[]},{"name":"flutter_background_service_ios","dependencies":[]},{"name":"flutter_timezone","dependencies":[]},{"name":"geolocator","dependencies":["geolocator_android","geolocator_apple","geolocator_web","geolocator_windows"]},{"name":"geolocator_android","dependencies":[]},{"name":"geolocator_apple","dependencies":[]},{"name":"geolocator_web","dependencies":[]},{"name":"geolocator_windows","dependencies":[]},{"name":"google_sign_in","dependencies":["google_sign_in_android","google_sign_in_ios","google_sign_in_web"]},{"name":"google_sign_in_android","dependencies":[]},{"name":"google_sign_in_ios","dependencies":[]},{"name":"google_sign_in_web","dependencies":[]},{"name":"package_info_plus","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"permission_handler","dependencies":["permission_handler_android","permission_handler_apple","permission_handler_html","permission_handler_windows"]},{"name":"permission_handler_android","dependencies":[]},{"name":"permission_handler_apple","dependencies":[]},{"name":"permission_handler_html","dependencies":[]},{"name":"permission_handler_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]}],"date_created":"2024-07-10 08:40:30.361536","version":"3.22.2"} \ No newline at end of file diff --git a/data/lib/api/auth/api_user_service.dart b/data/lib/api/auth/api_user_service.dart index 93e8a6cd..ec0c4307 100644 --- a/data/lib/api/auth/api_user_service.dart +++ b/data/lib/api/auth/api_user_service.dart @@ -4,6 +4,7 @@ import 'package:data/service/device_service.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import '../../service/location_manager.dart'; import '../../storage/app_preferences.dart'; import 'auth_models.dart'; @@ -14,6 +15,7 @@ final apiUserServiceProvider = StateProvider((ref) => ApiUserService( ref.read(currentUserSessionJsonPod.notifier), ref.read(currentUserSessionJsonPod.notifier), ref.read(isOnboardingShownPod.notifier), + ref.read(locationManagerProvider), )); class ApiUserService { @@ -23,14 +25,17 @@ class ApiUserService { final StateController currentUserSpaceId; final StateController userSessionJsonNotifier; final StateController onBoardNotifier; + final LocationManager locationManager; ApiUserService( - this._db, - this._device, - this.userJsonNotifier, - this.currentUserSpaceId, - this.userSessionJsonNotifier, - this.onBoardNotifier); + this._db, + this._device, + this.userJsonNotifier, + this.currentUserSpaceId, + this.userSessionJsonNotifier, + this.onBoardNotifier, + this.locationManager, + ); CollectionReference get _userRef => _db.collection("users").withConverter( @@ -186,12 +191,11 @@ class ApiUserService { } Future signOut() async { - // locationManager.stopLocationTracking(); + locationManager.stopService(); userJsonNotifier.state = null; userSessionJsonNotifier.state = null; onBoardNotifier.state = false; currentUserSpaceId.state = null; FirebaseAuth.instance.signOut(); - // locationManager.stopService(); } } diff --git a/data/lib/service/location_manager.dart b/data/lib/service/location_manager.dart index d95d3b6a..81e536a4 100644 --- a/data/lib/service/location_manager.dart +++ b/data/lib/service/location_manager.dart @@ -1,75 +1,36 @@ import 'dart:async'; +import 'dart:convert'; -import 'package:data/service/permission_service.dart'; +import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/cupertino.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter_background_service/flutter_background_service.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:geolocator/geolocator.dart'; import 'package:permission_handler/permission_handler.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +import 'location_service.dart'; const int locationUpdateInterval = 10000; // milliseconds -const double locationUpdateDistance = 10.0; // meters +const int locationUpdateDistance = 10; // meters final locationManagerProvider = - Provider((ref) => LocationManager(ref.read(permissionServiceProvider))); + Provider((ref) => LocationManager(ref.read(locationServiceProvider))); class LocationManager { - final PermissionService permissionService; - final backGroundService = FlutterBackgroundService(); - Position? _lastLocation; - Timer? _locationUpdateTimer; - - LocationManager(this.permissionService); + final LocationService locationService; - Stream getLiveGeoLocatorData() { - LocationSettings locationSettings; + Timer? _timer; - if (defaultTargetPlatform == TargetPlatform.android) { - locationSettings = AndroidSettings( - accuracy: LocationAccuracy.high, - distanceFilter: locationUpdateDistance.toInt(), - intervalDuration: const Duration(milliseconds: locationUpdateInterval) - ); - } else { - locationSettings = const LocationSettings( - accuracy: LocationAccuracy.high, - distanceFilter: 100, - ); - } + LocationManager(this.locationService); - return Geolocator.getPositionStream(locationSettings: locationSettings); - } - - void configure() { - getLiveGeoLocatorData().listen((position) { - - final distance = Geolocator.distanceBetween( - _lastLocation!.latitude, - _lastLocation!.longitude, - position.latitude, - position.longitude, - ); - print('Location distance:$distance update: $position'); - _lastLocation = position; - }); - // Geolocator.getPositionStream( - // locationSettings: LocationSettings( - // accuracy: LocationAccuracy.best, - // distanceFilter: locationUpdateDistance.toInt(), - // timeLimit: Duration(seconds: 10) - // ), - // ).listen((Position position) { - // print('Location update: $position'); - // _lastLocation = position; - // // Handle location update here - // }); + Future isServiceRunning() async { + final service = FlutterBackgroundService(); + return await service.isRunning(); } Future getLastLocation() async { - if (!await permissionService.isLocationServiceEnabled()) { - return null; - } + if (!await Geolocator.isLocationServiceEnabled()) return null; if (await Permission.location.isDenied) { await Permission.location.request(); @@ -77,18 +38,13 @@ class LocationManager { return null; } } - - final lastLocation = await Geolocator.getLastKnownPosition(); - return lastLocation; + return await Geolocator.getCurrentPosition(); } - void stopLocationTracking() { - _locationUpdateTimer?.cancel(); - stopService(); - } - - void startService() async { - await backGroundService.configure( + void startService(String userId) async { + print('XXX start tracking'); + final service = FlutterBackgroundService(); + await service.configure( androidConfiguration: AndroidConfiguration( onStart: onStart, autoStart: true, @@ -100,30 +56,80 @@ class LocationManager { onBackground: onIosBackground, ), ); - backGroundService.startService(); - } + print('XXX after config'); + service.startService(); - void stopService() { - FlutterBackgroundService().invoke("stopService"); + print('XXX start service'); + // startLocationTracking(userId); } - static void onStart(ServiceInstance service) { + static Future onStart(ServiceInstance service) async { + WidgetsFlutterBinding.ensureInitialized(); + print("This is exAMPLE"); if (service is AndroidServiceInstance) { service.setForegroundNotificationInfo( title: "Background Location Service", content: "Your location is being tracked", ); - service.setAsForegroundService(); - service.setAsBackgroundService(); } + // await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); + // final prefs = await SharedPreferences.getInstance(); + // final locationService = LocationService(FirebaseFirestore.instance); + + String userId = ''; + // final String? encodedUser = prefs.getString("user_account"); + // if(encodedUser != null){ + // final user = jsonDecode(encodedUser); + // userId = user['id']; + // } + + Geolocator.getPositionStream( + locationSettings: const LocationSettings( + accuracy: LocationAccuracy.high, + distanceFilter: locationUpdateDistance, + ), + ).listen((position) async { + print('XXX user id:$userId'); + // locationService.saveCurrentLocation(userId, position.latitude, + // position.longitude, DateTime.now().millisecondsSinceEpoch, 0); + }); service.on('stopService').listen((event) { service.stopSelf(); }); } + void startLocationTracking(String userId) { + Geolocator.getPositionStream( + locationSettings: const LocationSettings( + accuracy: LocationAccuracy.high, + distanceFilter: locationUpdateDistance, + ), + ).listen((position) async { + _timer?.cancel(); + _timer = Timer(const Duration(milliseconds: 5000), () { + print('XXX position:$position'); + updateUserLocation(userId, position); + }); + }); + } + + void updateUserLocation(String userId, Position position) async { + await locationService.saveCurrentLocation( + userId, + position.latitude, + position.longitude, + DateTime.now().millisecondsSinceEpoch, + 0, + ); + } + + void stopService() { + FlutterBackgroundService().invoke("stopService"); + } + static bool onIosBackground(ServiceInstance service) { WidgetsFlutterBinding.ensureInitialized(); onStart(service); diff --git a/data/lib/service/location_service.dart b/data/lib/service/location_service.dart index fb7efda0..781f0aac 100644 --- a/data/lib/service/location_service.dart +++ b/data/lib/service/location_service.dart @@ -39,4 +39,25 @@ class LocationService { return null; }); } + + Future saveCurrentLocation( + String userId, + double latitude, + double longitude, + int? recodedAt, + int? userState, + ) async { + print('XXX call save location'); + final docRef = _locationRef(userId).doc(); + + final location = ApiLocation( + id: docRef.id, + user_id: userId, + latitude: latitude, + longitude: longitude, + created_at: recodedAt, + ); + + await docRef.set(location); + } } diff --git a/firebase-debug.log b/firebase-debug.log new file mode 100644 index 00000000..688daa9e --- /dev/null +++ b/firebase-debug.log @@ -0,0 +1,21 @@ +[debug] [2024-07-08T11:57:17.355Z] ---------------------------------------------------------------------- +[debug] [2024-07-08T11:57:17.358Z] Command: /usr/local/bin/firebase /home/kaushik/.cache/firebase/tools/lib/node_modules/firebase-tools/lib/bin/firebase init +[debug] [2024-07-08T11:57:17.358Z] CLI Version: 13.0.2 +[debug] [2024-07-08T11:57:17.358Z] Platform: linux +[debug] [2024-07-08T11:57:17.359Z] Node Version: v18.5.0 +[debug] [2024-07-08T11:57:17.359Z] Time: Mon Jul 08 2024 17:27:17 GMT+0530 (India Standard Time) +[debug] [2024-07-08T11:57:17.359Z] ---------------------------------------------------------------------- +[debug] +[debug] [2024-07-08T11:57:17.366Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"] +[debug] [2024-07-08T11:57:17.367Z] > authorizing via signed-in user (kaushik.s@canopas.com) +[info] + ######## #### ######## ######## ######## ### ###### ######## + ## ## ## ## ## ## ## ## ## ## ## + ###### ## ######## ###### ######## ######### ###### ###### + ## ## ## ## ## ## ## ## ## ## ## + ## #### ## ## ######## ######## ## ## ###### ######## + +You're about to initialize a Firebase project in this directory: + + /home/kaushik/Clone projects/yourspace-flutter + From 1ac63e2ac5cd0661d39e015812e79feedcdbc885 Mon Sep 17 00:00:00 2001 From: kaushik Date: Wed, 10 Jul 2024 17:05:27 +0530 Subject: [PATCH 3/6] Fix user location tracking --- app/firebase.json | 22 +++++ app/lib/main.dart | 1 - .../ui/flow/home/home_screen_viewmodel.dart | 32 +----- .../selected_member_detail_view.dart | 24 ++--- data/.flutter-plugins-dependencies | 2 +- data/lib/service/location_manager.dart | 98 ------------------- data/lib/service/location_service.dart | 1 - 7 files changed, 40 insertions(+), 140 deletions(-) create mode 100644 app/firebase.json diff --git a/app/firebase.json b/app/firebase.json new file mode 100644 index 00000000..74093cb7 --- /dev/null +++ b/app/firebase.json @@ -0,0 +1,22 @@ +{ + "flutter": { + "platforms": { + "android": { + "default": { + "projectId": "yourspace-regional", + "appId": "1:406838982484:android:009eb33bb8f4ef583afac1", + "fileOutput": "android/app/google-services.json" + } + }, + "dart": { + "lib/firebase_options.dart": { + "projectId": "yourspace-regional", + "configurations": { + "android": "1:406838982484:android:009eb33bb8f4ef583afac1", + "ios": "1:406838982484:ios:1f872619a1a0648f3afac1" + } + } + } + } + } +} \ No newline at end of file diff --git a/app/lib/main.dart b/app/lib/main.dart index c2c091f8..dfbc1bc5 100644 --- a/app/lib/main.dart +++ b/app/lib/main.dart @@ -121,7 +121,6 @@ void _startLocationUpdates(String userId, LocationService locationService) { } bool onIosBackground(ServiceInstance service) { - WidgetsFlutterBinding.ensureInitialized(); onStart(service); return true; } diff --git a/app/lib/ui/flow/home/home_screen_viewmodel.dart b/app/lib/ui/flow/home/home_screen_viewmodel.dart index af254e04..84abdcf1 100644 --- a/app/lib/ui/flow/home/home_screen_viewmodel.dart +++ b/app/lib/ui/flow/home/home_screen_viewmodel.dart @@ -1,8 +1,5 @@ -import 'package:data/api/auth/auth_models.dart'; import 'package:data/api/space/space_models.dart'; import 'package:data/log/logger.dart'; -import 'package:data/service/location_manager.dart'; -import 'package:data/service/location_service.dart'; import 'package:data/service/permission_service.dart'; import 'package:data/service/space_service.dart'; import 'package:data/storage/app_preferences.dart'; @@ -18,9 +15,6 @@ final homeViewStateProvider = ref.read(currentUserSessionJsonPod.notifier), ref.read(permissionServiceProvider), ref.read(lastBatteryDialogPod.notifier), - ref.read(locationManagerProvider), - ref.read(currentUserPod), - ref.read(locationServiceProvider), ), ); @@ -29,19 +23,13 @@ class HomeViewNotifier extends StateNotifier { final PermissionService permissionService; final StateController _currentSpaceIdController; final StateController _lastBatteryDialogDate; - final LocationManager locationManager; - final ApiUser? _currentUser; - final LocationService locationService; HomeViewNotifier( - this.spaceService, - this._currentSpaceIdController, - this.permissionService, - this._lastBatteryDialogDate, - this.locationManager, - this._currentUser, - this.locationService) - : super(const HomeViewState()); + this.spaceService, + this._currentSpaceIdController, + this.permissionService, + this._lastBatteryDialogDate, + ) : super(const HomeViewState()); String? get currentSpaceId => _currentSpaceIdController.state; @@ -104,7 +92,6 @@ class HomeViewNotifier extends StateNotifier { state = state.copyWith(selectedSpace: space); currentSpaceId = space.space.id; } - // startLocationTracking(); } void showBatteryOptimizationDialog() async { @@ -140,15 +127,6 @@ class HomeViewNotifier extends StateNotifier { void requestIgnoreBatteryOptimizations() async { await permissionService.requestIgnoreBatteryOptimizations(); } - - void startLocationTracking() async { - final isLocationEnabled = - await permissionService.isLocationPermissionGranted(); - - if (isLocationEnabled) { - locationManager.startService(_currentUser!.id); - } - } } @freezed diff --git a/app/lib/ui/flow/home/map/components/selected_member_detail_view.dart b/app/lib/ui/flow/home/map/components/selected_member_detail_view.dart index 7b77c154..13483696 100644 --- a/app/lib/ui/flow/home/map/components/selected_member_detail_view.dart +++ b/app/lib/ui/flow/home/map/components/selected_member_detail_view.dart @@ -178,18 +178,18 @@ class _SelectedMemberDetailViewState extends State { } void getAddress(ApiLocation? location) async { - if(!mounted) return; - - if (location != null) { - final latLng = LatLng(location.latitude, location.longitude); - final address = await latLng.getAddressFromLocation(); - setState(() { - this.address = address; - }); - } else { - setState(() { - address = ''; - }); + if (mounted) { + if (location != null) { + final latLng = LatLng(location.latitude, location.longitude); + final address = await latLng.getAddressFromLocation(); + setState(() { + this.address = address; + }); + } else { + setState(() { + address = ''; + }); + } } } } diff --git a/data/.flutter-plugins-dependencies b/data/.flutter-plugins-dependencies index bbd4c766..0ca9db2b 100644 --- a/data/.flutter-plugins-dependencies +++ b/data/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"cloud_firestore","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_firestore-4.17.5/","native_build":true,"dependencies":["firebase_core"]},{"name":"cloud_functions","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_functions-4.7.6/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","native_build":true,"dependencies":[]},{"name":"firebase_auth","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_auth-4.20.0/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core-2.32.0/","native_build":true,"dependencies":[]},{"name":"firebase_storage","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage-11.7.7/","native_build":true,"dependencies":["firebase_core"]},{"name":"flutter_background_service_ios","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_background_service_ios-5.0.1/","native_build":true,"dependencies":[]},{"name":"flutter_timezone","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_timezone-1.0.8/","native_build":true,"dependencies":[]},{"name":"geolocator_apple","path":"/home/kaushik/.pub-cache/hosted/pub.dev/geolocator_apple-2.3.7/","native_build":true,"dependencies":[]},{"name":"google_sign_in_ios","path":"/home/kaushik/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.6/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","native_build":true,"dependencies":[]},{"name":"permission_handler_apple","path":"/home/kaushik/.pub-cache/hosted/pub.dev/permission_handler_apple-9.4.5/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.4.0/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"cloud_firestore","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_firestore-4.17.5/","native_build":true,"dependencies":["firebase_core"]},{"name":"cloud_functions","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_functions-4.7.6/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","native_build":true,"dependencies":[]},{"name":"firebase_auth","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_auth-4.20.0/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core-2.32.0/","native_build":true,"dependencies":[]},{"name":"firebase_storage","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage-11.7.7/","native_build":true,"dependencies":["firebase_core"]},{"name":"flutter_background_service_android","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_background_service_android-6.2.3/","native_build":true,"dependencies":[]},{"name":"flutter_timezone","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_timezone-1.0.8/","native_build":true,"dependencies":[]},{"name":"geolocator_android","path":"/home/kaushik/.pub-cache/hosted/pub.dev/geolocator_android-4.6.0/","native_build":true,"dependencies":[]},{"name":"google_sign_in_android","path":"/home/kaushik/.pub-cache/hosted/pub.dev/google_sign_in_android-6.1.24/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","native_build":true,"dependencies":[]},{"name":"permission_handler_android","path":"/home/kaushik/.pub-cache/hosted/pub.dev/permission_handler_android-12.0.7/","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_android-2.2.3/","native_build":true,"dependencies":[]}],"macos":[{"name":"cloud_firestore","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_firestore-4.17.5/","native_build":true,"dependencies":["firebase_core"]},{"name":"cloud_functions","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_functions-4.7.6/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","native_build":true,"dependencies":[]},{"name":"firebase_auth","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_auth-4.20.0/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core-2.32.0/","native_build":true,"dependencies":[]},{"name":"firebase_storage","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage-11.7.7/","native_build":true,"dependencies":["firebase_core"]},{"name":"flutter_timezone","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_timezone-1.0.8/","native_build":true,"dependencies":[]},{"name":"geolocator_apple","path":"/home/kaushik/.pub-cache/hosted/pub.dev/geolocator_apple-2.3.7/","native_build":true,"dependencies":[]},{"name":"google_sign_in_ios","path":"/home/kaushik/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.6/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.4.0/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","native_build":false,"dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","native_build":false,"dependencies":[]},{"name":"path_provider_linux","path":"/home/kaushik/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.3.2/","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"cloud_firestore","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_firestore-4.17.5/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","native_build":false,"dependencies":[]},{"name":"firebase_auth","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_auth-4.20.0/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core-2.32.0/","native_build":true,"dependencies":[]},{"name":"firebase_storage","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage-11.7.7/","native_build":true,"dependencies":["firebase_core"]},{"name":"geolocator_windows","path":"/home/kaushik/.pub-cache/hosted/pub.dev/geolocator_windows-0.2.3/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","native_build":false,"dependencies":[]},{"name":"path_provider_windows","path":"/home/kaushik/.pub-cache/hosted/pub.dev/path_provider_windows-2.2.1/","native_build":false,"dependencies":[]},{"name":"permission_handler_windows","path":"/home/kaushik/.pub-cache/hosted/pub.dev/permission_handler_windows-0.2.1/","native_build":true,"dependencies":[]},{"name":"shared_preferences_windows","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.3.2/","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"cloud_firestore_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_firestore_web-3.12.5/","dependencies":["firebase_core_web"]},{"name":"cloud_functions_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_functions_web-4.9.6/","dependencies":["firebase_core_web"]},{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","dependencies":[]},{"name":"firebase_auth_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_auth_web-5.12.0/","dependencies":["firebase_core_web"]},{"name":"firebase_core_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core_web-2.17.1/","dependencies":[]},{"name":"firebase_storage_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage_web-3.9.7/","dependencies":["firebase_core_web"]},{"name":"flutter_timezone","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_timezone-1.0.8/","dependencies":[]},{"name":"geolocator_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/geolocator_web-4.0.0/","dependencies":[]},{"name":"google_sign_in_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/google_sign_in_web-0.12.4/","dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","dependencies":[]},{"name":"permission_handler_html","path":"/home/kaushik/.pub-cache/hosted/pub.dev/permission_handler_html-0.1.1/","dependencies":[]},{"name":"shared_preferences_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_web-2.3.0/","dependencies":[]}]},"dependencyGraph":[{"name":"cloud_firestore","dependencies":["cloud_firestore_web","firebase_core"]},{"name":"cloud_firestore_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"cloud_functions","dependencies":["cloud_functions_web","firebase_core"]},{"name":"cloud_functions_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"device_info_plus","dependencies":[]},{"name":"firebase_auth","dependencies":["firebase_auth_web","firebase_core"]},{"name":"firebase_auth_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"firebase_core","dependencies":["firebase_core_web"]},{"name":"firebase_core_web","dependencies":[]},{"name":"firebase_storage","dependencies":["firebase_core","firebase_storage_web"]},{"name":"firebase_storage_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"flutter_background_service","dependencies":["flutter_background_service_android","flutter_background_service_ios"]},{"name":"flutter_background_service_android","dependencies":[]},{"name":"flutter_background_service_ios","dependencies":[]},{"name":"flutter_timezone","dependencies":[]},{"name":"geolocator","dependencies":["geolocator_android","geolocator_apple","geolocator_web","geolocator_windows"]},{"name":"geolocator_android","dependencies":[]},{"name":"geolocator_apple","dependencies":[]},{"name":"geolocator_web","dependencies":[]},{"name":"geolocator_windows","dependencies":[]},{"name":"google_sign_in","dependencies":["google_sign_in_android","google_sign_in_ios","google_sign_in_web"]},{"name":"google_sign_in_android","dependencies":[]},{"name":"google_sign_in_ios","dependencies":[]},{"name":"google_sign_in_web","dependencies":[]},{"name":"package_info_plus","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"permission_handler","dependencies":["permission_handler_android","permission_handler_apple","permission_handler_html","permission_handler_windows"]},{"name":"permission_handler_android","dependencies":[]},{"name":"permission_handler_apple","dependencies":[]},{"name":"permission_handler_html","dependencies":[]},{"name":"permission_handler_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]}],"date_created":"2024-07-10 08:40:30.361536","version":"3.22.2"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"cloud_firestore","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_firestore-4.17.5/","native_build":true,"dependencies":["firebase_core"]},{"name":"cloud_functions","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_functions-4.7.6/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","native_build":true,"dependencies":[]},{"name":"firebase_auth","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_auth-4.20.0/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core-2.32.0/","native_build":true,"dependencies":[]},{"name":"firebase_storage","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage-11.7.7/","native_build":true,"dependencies":["firebase_core"]},{"name":"flutter_background_service_ios","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_background_service_ios-5.0.1/","native_build":true,"dependencies":[]},{"name":"flutter_timezone","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_timezone-1.0.8/","native_build":true,"dependencies":[]},{"name":"geolocator_apple","path":"/home/kaushik/.pub-cache/hosted/pub.dev/geolocator_apple-2.3.7/","native_build":true,"dependencies":[]},{"name":"google_sign_in_ios","path":"/home/kaushik/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.6/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","native_build":true,"dependencies":[]},{"name":"permission_handler_apple","path":"/home/kaushik/.pub-cache/hosted/pub.dev/permission_handler_apple-9.4.5/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.4.0/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"cloud_firestore","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_firestore-4.17.5/","native_build":true,"dependencies":["firebase_core"]},{"name":"cloud_functions","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_functions-4.7.6/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","native_build":true,"dependencies":[]},{"name":"firebase_auth","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_auth-4.20.0/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core-2.32.0/","native_build":true,"dependencies":[]},{"name":"firebase_storage","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage-11.7.7/","native_build":true,"dependencies":["firebase_core"]},{"name":"flutter_background_service_android","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_background_service_android-6.2.3/","native_build":true,"dependencies":[]},{"name":"flutter_timezone","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_timezone-1.0.8/","native_build":true,"dependencies":[]},{"name":"geolocator_android","path":"/home/kaushik/.pub-cache/hosted/pub.dev/geolocator_android-4.6.0/","native_build":true,"dependencies":[]},{"name":"google_sign_in_android","path":"/home/kaushik/.pub-cache/hosted/pub.dev/google_sign_in_android-6.1.24/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","native_build":true,"dependencies":[]},{"name":"permission_handler_android","path":"/home/kaushik/.pub-cache/hosted/pub.dev/permission_handler_android-12.0.7/","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_android-2.2.3/","native_build":true,"dependencies":[]}],"macos":[{"name":"cloud_firestore","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_firestore-4.17.5/","native_build":true,"dependencies":["firebase_core"]},{"name":"cloud_functions","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_functions-4.7.6/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","native_build":true,"dependencies":[]},{"name":"firebase_auth","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_auth-4.20.0/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core-2.32.0/","native_build":true,"dependencies":[]},{"name":"firebase_storage","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage-11.7.7/","native_build":true,"dependencies":["firebase_core"]},{"name":"flutter_timezone","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_timezone-1.0.8/","native_build":true,"dependencies":[]},{"name":"geolocator_apple","path":"/home/kaushik/.pub-cache/hosted/pub.dev/geolocator_apple-2.3.7/","native_build":true,"dependencies":[]},{"name":"google_sign_in_ios","path":"/home/kaushik/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.6/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.4.0/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","native_build":false,"dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","native_build":false,"dependencies":[]},{"name":"path_provider_linux","path":"/home/kaushik/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.3.2/","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"cloud_firestore","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_firestore-4.17.5/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","native_build":false,"dependencies":[]},{"name":"firebase_auth","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_auth-4.20.0/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core-2.32.0/","native_build":true,"dependencies":[]},{"name":"firebase_storage","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage-11.7.7/","native_build":true,"dependencies":["firebase_core"]},{"name":"geolocator_windows","path":"/home/kaushik/.pub-cache/hosted/pub.dev/geolocator_windows-0.2.3/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","native_build":false,"dependencies":[]},{"name":"path_provider_windows","path":"/home/kaushik/.pub-cache/hosted/pub.dev/path_provider_windows-2.2.1/","native_build":false,"dependencies":[]},{"name":"permission_handler_windows","path":"/home/kaushik/.pub-cache/hosted/pub.dev/permission_handler_windows-0.2.1/","native_build":true,"dependencies":[]},{"name":"shared_preferences_windows","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.3.2/","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"cloud_firestore_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_firestore_web-3.12.5/","dependencies":["firebase_core_web"]},{"name":"cloud_functions_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/cloud_functions_web-4.9.6/","dependencies":["firebase_core_web"]},{"name":"device_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/device_info_plus-9.1.2/","dependencies":[]},{"name":"firebase_auth_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_auth_web-5.12.0/","dependencies":["firebase_core_web"]},{"name":"firebase_core_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_core_web-2.17.1/","dependencies":[]},{"name":"firebase_storage_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/firebase_storage_web-3.9.7/","dependencies":["firebase_core_web"]},{"name":"flutter_timezone","path":"/home/kaushik/.pub-cache/hosted/pub.dev/flutter_timezone-1.0.8/","dependencies":[]},{"name":"geolocator_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/geolocator_web-4.0.0/","dependencies":[]},{"name":"google_sign_in_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/google_sign_in_web-0.12.4/","dependencies":[]},{"name":"package_info_plus","path":"/home/kaushik/.pub-cache/hosted/pub.dev/package_info_plus-8.0.0/","dependencies":[]},{"name":"permission_handler_html","path":"/home/kaushik/.pub-cache/hosted/pub.dev/permission_handler_html-0.1.1/","dependencies":[]},{"name":"shared_preferences_web","path":"/home/kaushik/.pub-cache/hosted/pub.dev/shared_preferences_web-2.3.0/","dependencies":[]}]},"dependencyGraph":[{"name":"cloud_firestore","dependencies":["cloud_firestore_web","firebase_core"]},{"name":"cloud_firestore_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"cloud_functions","dependencies":["cloud_functions_web","firebase_core"]},{"name":"cloud_functions_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"device_info_plus","dependencies":[]},{"name":"firebase_auth","dependencies":["firebase_auth_web","firebase_core"]},{"name":"firebase_auth_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"firebase_core","dependencies":["firebase_core_web"]},{"name":"firebase_core_web","dependencies":[]},{"name":"firebase_storage","dependencies":["firebase_core","firebase_storage_web"]},{"name":"firebase_storage_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"flutter_background_service","dependencies":["flutter_background_service_android","flutter_background_service_ios"]},{"name":"flutter_background_service_android","dependencies":[]},{"name":"flutter_background_service_ios","dependencies":[]},{"name":"flutter_timezone","dependencies":[]},{"name":"geolocator","dependencies":["geolocator_android","geolocator_apple","geolocator_web","geolocator_windows"]},{"name":"geolocator_android","dependencies":[]},{"name":"geolocator_apple","dependencies":[]},{"name":"geolocator_web","dependencies":[]},{"name":"geolocator_windows","dependencies":[]},{"name":"google_sign_in","dependencies":["google_sign_in_android","google_sign_in_ios","google_sign_in_web"]},{"name":"google_sign_in_android","dependencies":[]},{"name":"google_sign_in_ios","dependencies":[]},{"name":"google_sign_in_web","dependencies":[]},{"name":"package_info_plus","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"permission_handler","dependencies":["permission_handler_android","permission_handler_apple","permission_handler_html","permission_handler_windows"]},{"name":"permission_handler_android","dependencies":[]},{"name":"permission_handler_apple","dependencies":[]},{"name":"permission_handler_html","dependencies":[]},{"name":"permission_handler_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]}],"date_created":"2024-07-10 16:30:02.971381","version":"3.22.2"} \ No newline at end of file diff --git a/data/lib/service/location_manager.dart b/data/lib/service/location_manager.dart index 81e536a4..e943ec8e 100644 --- a/data/lib/service/location_manager.dart +++ b/data/lib/service/location_manager.dart @@ -1,13 +1,8 @@ import 'dart:async'; -import 'dart:convert'; - -import 'package:cloud_firestore/cloud_firestore.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter_background_service/flutter_background_service.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:geolocator/geolocator.dart'; import 'package:permission_handler/permission_handler.dart'; -import 'package:shared_preferences/shared_preferences.dart'; import 'location_service.dart'; @@ -20,8 +15,6 @@ final locationManagerProvider = class LocationManager { final LocationService locationService; - Timer? _timer; - LocationManager(this.locationService); Future isServiceRunning() async { @@ -41,98 +34,7 @@ class LocationManager { return await Geolocator.getCurrentPosition(); } - void startService(String userId) async { - print('XXX start tracking'); - final service = FlutterBackgroundService(); - await service.configure( - androidConfiguration: AndroidConfiguration( - onStart: onStart, - autoStart: true, - isForegroundMode: true, - ), - iosConfiguration: IosConfiguration( - autoStart: true, - onForeground: onStart, - onBackground: onIosBackground, - ), - ); - print('XXX after config'); - service.startService(); - - print('XXX start service'); - // startLocationTracking(userId); - } - - static Future onStart(ServiceInstance service) async { - - WidgetsFlutterBinding.ensureInitialized(); - print("This is exAMPLE"); - - if (service is AndroidServiceInstance) { - service.setForegroundNotificationInfo( - title: "Background Location Service", - content: "Your location is being tracked", - ); - } - - // await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); - // final prefs = await SharedPreferences.getInstance(); - // final locationService = LocationService(FirebaseFirestore.instance); - - String userId = ''; - // final String? encodedUser = prefs.getString("user_account"); - // if(encodedUser != null){ - // final user = jsonDecode(encodedUser); - // userId = user['id']; - // } - - Geolocator.getPositionStream( - locationSettings: const LocationSettings( - accuracy: LocationAccuracy.high, - distanceFilter: locationUpdateDistance, - ), - ).listen((position) async { - print('XXX user id:$userId'); - // locationService.saveCurrentLocation(userId, position.latitude, - // position.longitude, DateTime.now().millisecondsSinceEpoch, 0); - }); - service.on('stopService').listen((event) { - service.stopSelf(); - }); - } - - void startLocationTracking(String userId) { - Geolocator.getPositionStream( - locationSettings: const LocationSettings( - accuracy: LocationAccuracy.high, - distanceFilter: locationUpdateDistance, - ), - ).listen((position) async { - _timer?.cancel(); - _timer = Timer(const Duration(milliseconds: 5000), () { - print('XXX position:$position'); - updateUserLocation(userId, position); - }); - }); - } - - void updateUserLocation(String userId, Position position) async { - await locationService.saveCurrentLocation( - userId, - position.latitude, - position.longitude, - DateTime.now().millisecondsSinceEpoch, - 0, - ); - } - void stopService() { FlutterBackgroundService().invoke("stopService"); } - - static bool onIosBackground(ServiceInstance service) { - WidgetsFlutterBinding.ensureInitialized(); - onStart(service); - return true; - } } diff --git a/data/lib/service/location_service.dart b/data/lib/service/location_service.dart index 781f0aac..91525a34 100644 --- a/data/lib/service/location_service.dart +++ b/data/lib/service/location_service.dart @@ -47,7 +47,6 @@ class LocationService { int? recodedAt, int? userState, ) async { - print('XXX call save location'); final docRef = _locationRef(userId).doc(); final location = ApiLocation( From bbf0c535aa5564e5dc6bcda915939944ab2b4255 Mon Sep 17 00:00:00 2001 From: kaushik Date: Wed, 10 Jul 2024 17:17:45 +0530 Subject: [PATCH 4/6] Fix lint --- app/lib/main.dart | 3 ++- app/pubspec.lock | 2 +- app/pubspec.yaml | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/lib/main.dart b/app/lib/main.dart index dfbc1bc5..31319d2d 100644 --- a/app/lib/main.dart +++ b/app/lib/main.dart @@ -3,6 +3,7 @@ import 'dart:convert'; import 'dart:io'; import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:data/service/location_manager.dart'; import 'package:data/service/location_service.dart'; import 'package:data/storage/preferences_provider.dart'; import 'package:firebase_core/firebase_core.dart'; @@ -104,7 +105,7 @@ void _startLocationUpdates(String userId, LocationService locationService) { Geolocator.getPositionStream( locationSettings: const LocationSettings( accuracy: LocationAccuracy.high, - distanceFilter: 10, + distanceFilter: locationUpdateDistance, ), ).listen((position) { timer?.cancel(); diff --git a/app/pubspec.lock b/app/pubspec.lock index 6e6f5c9e..0befb375 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -202,7 +202,7 @@ packages: source: hosted version: "1.1.1" cloud_firestore: - dependency: transitive + dependency: "direct main" description: name: cloud_firestore sha256: a0f161b92610e078b4962d7e6ebeb66dc9cce0ada3514aeee442f68165d78185 diff --git a/app/pubspec.yaml b/app/pubspec.yaml index 66a78a70..b078da28 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -59,6 +59,7 @@ dependencies: flutter_cache_manager: ^3.3.2 permission_handler: ^11.3.1 flutter_slidable: ^3.1.0 + flutter_background_service: ^5.0.6 # map google_maps_flutter: ^2.3.1 @@ -69,12 +70,12 @@ dependencies: firebase_auth: ^4.20.0 firebase_core: ^2.23.0 firebase_storage: ^11.7.7 + cloud_firestore: ^4.15.5 google_sign_in: ^6.1.6 logger: ^2.3.0 flutter_svg: ^2.0.9 # picker canopas_country_picker: ^0.0.4 - flutter_background_service: ^5.0.6 dev_dependencies: flutter_test: From de308ec6674f48354e42ca91de5b8697d295b7d4 Mon Sep 17 00:00:00 2001 From: kaushik Date: Wed, 10 Jul 2024 18:30:40 +0530 Subject: [PATCH 5/6] Update proper location Coordinates --- app/lib/main.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/lib/main.dart b/app/lib/main.dart index 31319d2d..801f6f01 100644 --- a/app/lib/main.dart +++ b/app/lib/main.dart @@ -12,6 +12,7 @@ import 'package:flutter_background_service/flutter_background_service.dart'; import 'package:flutter_displaymode/flutter_displaymode.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:geolocator/geolocator.dart'; +import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:yourspace_flutter/firebase_options.dart'; @@ -108,12 +109,13 @@ void _startLocationUpdates(String userId, LocationService locationService) { distanceFilter: locationUpdateDistance, ), ).listen((position) { + final location = LatLng(position.latitude, position.longitude); timer?.cancel(); timer = Timer(const Duration(milliseconds: 5000), () { locationService.saveCurrentLocation( userId, - position.latitude, - position.longitude, + location.latitude, + location.longitude, DateTime.now().millisecondsSinceEpoch, 0, ); From aff797d0d120d8db1cded51dcf2cefd620785dca Mon Sep 17 00:00:00 2001 From: kaushik Date: Thu, 18 Jul 2024 10:29:02 +0530 Subject: [PATCH 6/6] Fix conflict --- app/lib/main.dart | 2 +- data/lib/service/location_manager.dart | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/lib/main.dart b/app/lib/main.dart index 801f6f01..fc75849f 100644 --- a/app/lib/main.dart +++ b/app/lib/main.dart @@ -106,7 +106,7 @@ void _startLocationUpdates(String userId, LocationService locationService) { Geolocator.getPositionStream( locationSettings: const LocationSettings( accuracy: LocationAccuracy.high, - distanceFilter: locationUpdateDistance, + distanceFilter: LOCATION_UPDATE_DISTANCE, ), ).listen((position) { final location = LatLng(position.latitude, position.longitude); diff --git a/data/lib/service/location_manager.dart b/data/lib/service/location_manager.dart index e943ec8e..e35d51c0 100644 --- a/data/lib/service/location_manager.dart +++ b/data/lib/service/location_manager.dart @@ -1,3 +1,5 @@ +// ignore_for_file: constant_identifier_names, non_constant_identifier_names + import 'dart:async'; import 'package:flutter_background_service/flutter_background_service.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; @@ -6,8 +8,8 @@ import 'package:permission_handler/permission_handler.dart'; import 'location_service.dart'; -const int locationUpdateInterval = 10000; // milliseconds -const int locationUpdateDistance = 10; // meters +const LOCATION_UPDATE_INTERVAL = 10000; // milliseconds +const LOCATION_UPDATE_DISTANCE = 10; // meters final locationManagerProvider = Provider((ref) => LocationManager(ref.read(locationServiceProvider)));