diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml index a1411e9..05e5bf8 100644 --- a/.idea/libraries/Dart_Packages.xml +++ b/.idea/libraries/Dart_Packages.xml @@ -124,7 +124,7 @@ - @@ -159,28 +159,49 @@ - + + + + + + + + + + + + - - + + + + + + - @@ -229,7 +250,7 @@ - @@ -278,14 +299,14 @@ - - @@ -420,28 +441,31 @@ - + - - - - + + + + + + + - + - - + + diff --git a/Sources/dafl_project_flutter/android/app/build.gradle b/Sources/dafl_project_flutter/android/app/build.gradle index 2fa22ec..fce04cc 100644 --- a/Sources/dafl_project_flutter/android/app/build.gradle +++ b/Sources/dafl_project_flutter/android/app/build.gradle @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion flutter.compileSdkVersion + compileSdkVersion 33 ndkVersion flutter.ndkVersion compileOptions { diff --git a/Sources/dafl_project_flutter/lib/model/location.dart b/Sources/dafl_project_flutter/lib/model/location.dart index edd6797..0f9aafc 100644 --- a/Sources/dafl_project_flutter/lib/model/location.dart +++ b/Sources/dafl_project_flutter/lib/model/location.dart @@ -1,16 +1,22 @@ -import 'package:flutter/foundation.dart'; import 'package:geolocator/geolocator.dart'; import 'package:tuple/tuple.dart'; -class Location{ - static Tuple2 getCurrentLocation() { - Position currentPosition = Position(); - Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.best, forceAndroidLocationManager: true) - .then((Position position) {currentPosition = position;}).catchError((e) { - if (kDebugMode) { - print(e); +class Location { + static Future> getCurrentLocation() async { + LocationPermission permission; + permission = await Geolocator.checkPermission(); + if (permission == LocationPermission.denied) { + permission = await Geolocator.requestPermission(); + if (permission == LocationPermission.deniedForever) { + return Future.error('Location Not Available'); } - }); - return Tuple2(currentPosition.longitude, currentPosition.latitude); + } + Position current = await Geolocator.getCurrentPosition(); + double long = current.longitude; + double lat = current.latitude; + return Tuple2(long,lat); } -} \ No newline at end of file +} + + + diff --git a/Sources/dafl_project_flutter/macos/Flutter/GeneratedPluginRegistrant.swift b/Sources/dafl_project_flutter/macos/Flutter/GeneratedPluginRegistrant.swift index cccf817..977f380 100644 --- a/Sources/dafl_project_flutter/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/Sources/dafl_project_flutter/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,6 +5,8 @@ import FlutterMacOS import Foundation +import geolocator_apple func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + GeolocatorPlugin.register(with: registry.registrar(forPlugin: "GeolocatorPlugin")) } diff --git a/Sources/dafl_project_flutter/pubspec.lock b/Sources/dafl_project_flutter/pubspec.lock index 6a5a06f..d545915 100644 --- a/Sources/dafl_project_flutter/pubspec.lock +++ b/Sources/dafl_project_flutter/pubspec.lock @@ -124,7 +124,7 @@ packages: name: flutter_native_splash url: "https://pub.dartlang.org" source: hosted - version: "2.2.11" + version: "2.2.13" flutter_test: dependency: "direct dev" description: flutter @@ -155,28 +155,49 @@ packages: name: geolocator url: "https://pub.dartlang.org" source: hosted - version: "6.2.1" + version: "9.0.2" + geolocator_android: + dependency: transitive + description: + name: geolocator_android + url: "https://pub.dartlang.org" + source: hosted + version: "4.1.4" + geolocator_apple: + dependency: transitive + description: + name: geolocator_apple + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.3" geolocator_platform_interface: dependency: transitive description: name: geolocator_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.9" + version: "4.0.7" geolocator_web: dependency: transitive description: name: geolocator_web url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "2.1.6" + geolocator_windows: + dependency: transitive + description: + name: geolocator_windows + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.1" graphs: dependency: transitive description: name: graphs url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.2.0" html: dependency: transitive description: @@ -225,7 +246,7 @@ packages: name: lints url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.1" matcher: dependency: transitive description: @@ -274,14 +295,14 @@ packages: name: petitparser url: "https://pub.dartlang.org" source: hosted - version: "5.0.0" + version: "5.1.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "2.1.3" provider: dependency: "direct main" description: diff --git a/Sources/dafl_project_flutter/pubspec.yaml b/Sources/dafl_project_flutter/pubspec.yaml index fc6a0ee..d3934b9 100644 --- a/Sources/dafl_project_flutter/pubspec.yaml +++ b/Sources/dafl_project_flutter/pubspec.yaml @@ -34,7 +34,7 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^1.0.2 + cupertino_icons: ^1.0.5 page_transition: ^2.0.9 provider: ^6.0.4 fluttericon: ^2.0.0 @@ -42,7 +42,7 @@ dependencies: animations: ^2.0.7 fluttertoast: ^8.1.1 vibration: ^1.7.6 - geolocator: ^6.1.1 + geolocator: ^9.0.2 tuple: ^2.0.1 @@ -55,9 +55,9 @@ dev_dependencies: # activated in the `analysis_options.yaml` file located at the root of your # package. See that file for information about deactivating specific lint # rules and activating additional ones. - flutter_lints: ^2.0.0 + flutter_lints: ^2.0.1 flutter_launcher_icons: ^0.10.0 - flutter_native_splash: ^2.2.11 + flutter_native_splash: ^2.2.13 flutter_native_splash: android: true diff --git a/Sources/dafl_project_flutter/windows/flutter/generated_plugin_registrant.cc b/Sources/dafl_project_flutter/windows/flutter/generated_plugin_registrant.cc index 8b6d468..1ece8f2 100644 --- a/Sources/dafl_project_flutter/windows/flutter/generated_plugin_registrant.cc +++ b/Sources/dafl_project_flutter/windows/flutter/generated_plugin_registrant.cc @@ -6,6 +6,9 @@ #include "generated_plugin_registrant.h" +#include void RegisterPlugins(flutter::PluginRegistry* registry) { + GeolocatorWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("GeolocatorWindows")); } diff --git a/Sources/dafl_project_flutter/windows/flutter/generated_plugins.cmake b/Sources/dafl_project_flutter/windows/flutter/generated_plugins.cmake index b93c4c3..7f101a7 100644 --- a/Sources/dafl_project_flutter/windows/flutter/generated_plugins.cmake +++ b/Sources/dafl_project_flutter/windows/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + geolocator_windows ) list(APPEND FLUTTER_FFI_PLUGIN_LIST