From 7891b4dbe19abfc98608940822edcbf003283ef1 Mon Sep 17 00:00:00 2001 From: Supan Adit Pratama Date: Wed, 3 Nov 2021 22:32:24 +0700 Subject: [PATCH] fix: update geolocator, google maps, and remove public my Google API Key --- android/app/src/main/res/values/strings.xml | 2 +- ios/Runner/AppDelegate.swift | 2 +- lib/config.dart | 4 +- lib/page/map_page.dart | 44 +++--- pubspec.lock | 144 +++++++++----------- pubspec.yaml | 6 +- 6 files changed, 90 insertions(+), 112 deletions(-) diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index b3448ee..3218cf1 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -1,5 +1,5 @@ Geo Smart App - AIzaSyCjhBV5aq1gsTCYsr6QCCxYusFlBa3DEMs + YOUR_API_KEY \ No newline at end of file diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index 552e5d0..27be350 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -7,7 +7,7 @@ import Flutter _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { - GMSServices.provideAPIKey("AIzaSyCjhBV5aq1gsTCYsr6QCCxYusFlBa3DEMs") + GMSServices.provideAPIKey("YOUR_API_KEY") GeneratedPluginRegistrant.register(with: self) return super.application(application, didFinishLaunchingWithOptions: launchOptions) } diff --git a/lib/config.dart b/lib/config.dart index e281b25..c6082db 100644 --- a/lib/config.dart +++ b/lib/config.dart @@ -1,5 +1,5 @@ class Config { - static const String api = "http://192.168.1.7:8080"; - static const bool dynamicHostSetting = true; + static const String api = "http://api.geosmart.supanadit.com"; + static const bool dynamicHostSetting = false; static const bool showInterceptor = true; } diff --git a/lib/page/map_page.dart b/lib/page/map_page.dart index d3bcfd6..0971992 100644 --- a/lib/page/map_page.dart +++ b/lib/page/map_page.dart @@ -3,6 +3,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:geolocator/geolocator.dart' as geo; +import 'package:geolocator/geolocator.dart'; import 'package:geosmart/bloc/bloc.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; @@ -27,35 +28,26 @@ class _MapPageState extends State { setState(() { isChecking = true; }); - // geo.Geolocator()..forceAndroidLocationManager = true; - geo.Geolocator().checkGeolocationPermissionStatus().then( - (v) { - isGranted = true; - var geolocator = geo.Geolocator(); - var locationOptions = geo.LocationOptions( - accuracy: geo.LocationAccuracy.high, - ); - - geolocator.getPositionStream(locationOptions).listen( - (geo.Position position) { - if (isTracking && isGranted) { - BlocProvider.of(context).add( - PositionSend( - lat: position.latitude.toString(), - lng: position.longitude.toString(), - ), - ); - } - }, - ); - }, - ).catchError((e) { - isGranted = false; - }).whenComplete(() { + Geolocator.checkPermission().then((value) { setState(() { - isChecking = false; + if (value != LocationPermission.deniedForever) { + setState(() { + isChecking = false; + isGranted = true; + }); + } }); }); + Geolocator.getPositionStream().listen((Position position) { + if (isTracking && isGranted) { + BlocProvider.of(context).add( + PositionSend( + lat: position.latitude.toString(), + lng: position.longitude.toString(), + ), + ); + } + }); } static final CameraPosition _kGooglePlex = CameraPosition( diff --git a/pubspec.lock b/pubspec.lock index 7b96cb9..49d031f 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -8,27 +8,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.3" - archive: - dependency: transitive - description: - name: archive - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.13" - args: - dependency: transitive - description: - name: args - url: "https://pub.dartlang.org" - source: hosted - version: "1.6.0" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.1" + version: "2.4.2" bloc: dependency: transitive description: @@ -43,6 +29,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" charcode: dependency: transitive description: @@ -64,27 +57,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.0.3" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.12" - convert: - dependency: transitive - description: - name: convert - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.1" - crypto: - dependency: transitive - description: - name: crypto - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.4" + version: "1.14.13" cupertino_icons: dependency: "direct main" description: @@ -106,6 +92,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.3" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" ffi: dependency: transitive description: @@ -169,28 +162,28 @@ packages: name: geolocator url: "https://pub.dartlang.org" source: hosted - version: "5.3.2+2" - google_api_availability: + version: "6.1.14" + geolocator_platform_interface: dependency: transitive description: - name: google_api_availability + name: geolocator_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.4" + version: "1.0.9" google_maps_flutter: dependency: "direct main" description: name: google_maps_flutter url: "https://pub.dartlang.org" source: hosted - version: "0.5.28+1" + version: "0.5.33" google_maps_flutter_platform_interface: dependency: transitive description: name: google_maps_flutter_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "1.2.0" http: dependency: "direct main" description: @@ -205,13 +198,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.1.4" - image: - dependency: transitive - description: - name: image - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.12" intl: dependency: transitive description: @@ -219,13 +205,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.16.1" - location_permissions: - dependency: transitive - description: - name: location_permissions - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.0+1" logging: dependency: transitive description: @@ -239,7 +218,7 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.6" + version: "0.12.8" meta: dependency: transitive description: @@ -281,7 +260,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.6.4" + version: "1.7.0" path_provider: dependency: transitive description: @@ -309,7 +288,14 @@ packages: name: path_provider_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "1.0.4" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.4+3" pedantic: dependency: transitive description: @@ -331,13 +317,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.1" - petitparser: - dependency: transitive - description: - name: petitparser - url: "https://pub.dartlang.org" - source: hosted - version: "2.4.0" platform: dependency: transitive description: @@ -366,13 +345,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.3.1" - quiver: - dependency: transitive - description: - name: quiver - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.3" rxdart: dependency: "direct main" description: @@ -407,7 +379,14 @@ packages: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "0.5.7+3" + version: "0.5.12+4" + shared_preferences_linux: + dependency: transitive + description: + name: shared_preferences_linux + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.2+4" shared_preferences_macos: dependency: transitive description: @@ -429,6 +408,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.2+7" + shared_preferences_windows: + dependency: transitive + description: + name: shared_preferences_windows + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.2+3" sky_engine: dependency: transitive description: flutter @@ -447,7 +433,7 @@ packages: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.9.5" stream_channel: dependency: transitive description: @@ -482,14 +468,14 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.15" + version: "0.2.17" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.2.0" vector_math: dependency: transitive description: @@ -525,6 +511,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.4+2" + win32: + dependency: transitive + description: + name: win32 + url: "https://pub.dartlang.org" + source: hosted + version: "1.7.4+1" xdg_directories: dependency: transitive description: @@ -532,13 +525,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.0" - xml: - dependency: transitive - description: - name: xml - url: "https://pub.dartlang.org" - source: hosted - version: "3.6.1" sdks: - dart: ">=2.7.0 <3.0.0" + dart: ">=2.9.0-14.0.dev <3.0.0" flutter: ">=1.16.3 <2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 20f20bb..134bb99 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -28,10 +28,10 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^0.1.3 - geolocator: ^5.3.2+2 + geolocator: ^6.1.14 http: ^0.12.1 - google_maps_flutter: ^0.5.28+1 - shared_preferences: ^0.5.7+3 + google_maps_flutter: ^0.5.33 + shared_preferences: ^0.5.12+4 rxdart: ^0.24.1 dio: ^3.0.9 flutter_bloc: ^6.0.1