From b75b2975019b162e9cb55f81037709d755183287 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Tue, 26 Mar 2024 12:00:32 +0100 Subject: [PATCH 01/20] remove and ignore jetbrains project files --- .gitignore | 4 +- .idea/libraries/Dart_SDK.xml | 28 ----- .idea/libraries/Flutter_Plugins.xml | 7 -- .idea/misc.xml | 5 - .idea/workspace.xml | 73 ----------- example/pubspec.lock | 180 ---------------------------- pubspec.lock | 173 -------------------------- 7 files changed, 3 insertions(+), 467 deletions(-) delete mode 100644 .idea/libraries/Dart_SDK.xml delete mode 100644 .idea/libraries/Flutter_Plugins.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/workspace.xml delete mode 100644 example/pubspec.lock delete mode 100644 pubspec.lock diff --git a/.gitignore b/.gitignore index d8cf8bcb..3fabd172 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,6 @@ build/ example/ios/Flutter/flutter_export_environment.sh .idea/ -.gradle/ \ No newline at end of file +.gradle/ +*.iml +pubspec.lock \ No newline at end of file diff --git a/.idea/libraries/Dart_SDK.xml b/.idea/libraries/Dart_SDK.xml deleted file mode 100644 index 60681106..00000000 --- a/.idea/libraries/Dart_SDK.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Flutter_Plugins.xml b/.idea/libraries/Flutter_Plugins.xml deleted file mode 100644 index b0f69711..00000000 --- a/.idea/libraries/Flutter_Plugins.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 212ae462..00000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index 92e34156..00000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1631561248834 - - - - - - - - - - \ No newline at end of file diff --git a/example/pubspec.lock b/example/pubspec.lock deleted file mode 100644 index fdbff691..00000000 --- a/example/pubspec.lock +++ /dev/null @@ -1,180 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - async: - dependency: transitive - description: - name: async - sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" - url: "https://pub.dev" - source: hosted - version: "2.11.0" - background_location: - dependency: "direct dev" - description: - path: ".." - relative: true - source: path - version: "0.12.0" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" - url: "https://pub.dev" - source: hosted - version: "2.1.1" - characters: - dependency: transitive - description: - name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" - url: "https://pub.dev" - source: hosted - version: "1.3.0" - clock: - dependency: transitive - description: - name: clock - sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf - url: "https://pub.dev" - source: hosted - version: "1.1.1" - collection: - dependency: transitive - description: - name: collection - sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 - url: "https://pub.dev" - source: hosted - version: "1.17.2" - cupertino_icons: - dependency: "direct main" - description: - name: cupertino_icons - sha256: caac504f942f41dfadcf45229ce8c47065b93919a12739f20d6173a883c5ec73 - url: "https://pub.dev" - source: hosted - version: "1.0.2" - fake_async: - dependency: transitive - description: - name: fake_async - sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" - url: "https://pub.dev" - source: hosted - version: "1.3.1" - flutter: - dependency: "direct main" - description: flutter - source: sdk - version: "0.0.0" - flutter_test: - dependency: "direct dev" - description: flutter - source: sdk - version: "0.0.0" - matcher: - dependency: transitive - description: - name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" - url: "https://pub.dev" - source: hosted - version: "0.12.16" - material_color_utilities: - dependency: transitive - description: - name: material_color_utilities - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" - url: "https://pub.dev" - source: hosted - version: "0.5.0" - meta: - dependency: transitive - description: - name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" - url: "https://pub.dev" - source: hosted - version: "1.9.1" - path: - dependency: transitive - description: - name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" - url: "https://pub.dev" - source: hosted - version: "1.8.3" - sky_engine: - dependency: transitive - description: flutter - source: sdk - version: "0.0.99" - source_span: - dependency: transitive - description: - name: source_span - sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" - url: "https://pub.dev" - source: hosted - version: "1.10.0" - stack_trace: - dependency: transitive - description: - name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 - url: "https://pub.dev" - source: hosted - version: "1.11.0" - stream_channel: - dependency: transitive - description: - name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" - url: "https://pub.dev" - source: hosted - version: "2.1.1" - string_scanner: - dependency: transitive - description: - name: string_scanner - sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" - url: "https://pub.dev" - source: hosted - version: "1.2.0" - term_glyph: - dependency: transitive - description: - name: term_glyph - sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 - url: "https://pub.dev" - source: hosted - version: "1.2.1" - test_api: - dependency: transitive - description: - name: test_api - sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" - url: "https://pub.dev" - source: hosted - version: "0.6.0" - vector_math: - dependency: transitive - description: - name: vector_math - sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" - url: "https://pub.dev" - source: hosted - version: "2.1.4" - web: - dependency: transitive - description: - name: web - sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 - url: "https://pub.dev" - source: hosted - version: "0.1.4-beta" -sdks: - dart: ">=3.1.0 <4.0.0" - flutter: ">=3.0.0" diff --git a/pubspec.lock b/pubspec.lock deleted file mode 100644 index b0a157d2..00000000 --- a/pubspec.lock +++ /dev/null @@ -1,173 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - async: - dependency: transitive - description: - name: async - sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" - url: "https://pub.dev" - source: hosted - version: "2.11.0" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" - url: "https://pub.dev" - source: hosted - version: "2.1.1" - characters: - dependency: transitive - description: - name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" - url: "https://pub.dev" - source: hosted - version: "1.3.0" - clock: - dependency: transitive - description: - name: clock - sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf - url: "https://pub.dev" - source: hosted - version: "1.1.1" - collection: - dependency: transitive - description: - name: collection - sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 - url: "https://pub.dev" - source: hosted - version: "1.17.2" - fake_async: - dependency: transitive - description: - name: fake_async - sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" - url: "https://pub.dev" - source: hosted - version: "1.3.1" - flutter: - dependency: "direct main" - description: flutter - source: sdk - version: "0.0.0" - flutter_test: - dependency: "direct dev" - description: flutter - source: sdk - version: "0.0.0" - matcher: - dependency: transitive - description: - name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" - url: "https://pub.dev" - source: hosted - version: "0.12.16" - material_color_utilities: - dependency: transitive - description: - name: material_color_utilities - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" - url: "https://pub.dev" - source: hosted - version: "0.5.0" - meta: - dependency: transitive - description: - name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" - url: "https://pub.dev" - source: hosted - version: "1.9.1" - path: - dependency: transitive - description: - name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" - url: "https://pub.dev" - source: hosted - version: "1.8.3" - pedantic: - dependency: "direct dev" - description: - name: pedantic - sha256: "67fc27ed9639506c856c840ccce7594d0bdcd91bc8d53d6e52359449a1d50602" - url: "https://pub.dev" - source: hosted - version: "1.11.1" - sky_engine: - dependency: transitive - description: flutter - source: sdk - version: "0.0.99" - source_span: - dependency: transitive - description: - name: source_span - sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" - url: "https://pub.dev" - source: hosted - version: "1.10.0" - stack_trace: - dependency: transitive - description: - name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 - url: "https://pub.dev" - source: hosted - version: "1.11.0" - stream_channel: - dependency: transitive - description: - name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" - url: "https://pub.dev" - source: hosted - version: "2.1.1" - string_scanner: - dependency: transitive - description: - name: string_scanner - sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" - url: "https://pub.dev" - source: hosted - version: "1.2.0" - term_glyph: - dependency: transitive - description: - name: term_glyph - sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 - url: "https://pub.dev" - source: hosted - version: "1.2.1" - test_api: - dependency: transitive - description: - name: test_api - sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" - url: "https://pub.dev" - source: hosted - version: "0.6.0" - vector_math: - dependency: transitive - description: - name: vector_math - sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" - url: "https://pub.dev" - source: hosted - version: "2.1.4" - web: - dependency: transitive - description: - name: web - sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 - url: "https://pub.dev" - source: hosted - version: "0.1.4-beta" -sdks: - dart: ">=3.1.0 <4.0.0" - flutter: ">=3.0.0" From f711d84ee6be9d1091d499e68a96a54105d00324 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Tue, 26 Mar 2024 12:00:44 +0100 Subject: [PATCH 02/20] remove deprecated `pedantic` in favor of `flutter_lints` --- analysis_options.yaml | 3 +-- example/analysis_options.yaml | 1 + example/pubspec.yaml | 36 ++--------------------------------- example/test/widget_test.dart | 2 +- pubspec.yaml | 2 +- 5 files changed, 6 insertions(+), 38 deletions(-) create mode 100644 example/analysis_options.yaml diff --git a/analysis_options.yaml b/analysis_options.yaml index 23739e5d..a3be6b82 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,2 +1 @@ -include: package:pedantic/analysis_options.1.9.0.yaml -analyzer: \ No newline at end of file +include: package:flutter_lints/flutter.yaml \ No newline at end of file diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml new file mode 100644 index 00000000..a3be6b82 --- /dev/null +++ b/example/analysis_options.yaml @@ -0,0 +1 @@ +include: package:flutter_lints/flutter.yaml \ No newline at end of file diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 313294b0..7c15f440 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -13,42 +13,10 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter + flutter_lints: ^3.0.1 background_location: path: ../ -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec -# The following section is specific to Flutter. flutter: - # The following line ensures that the Material Icons font is - # included with your application, so that you can use the icons in - # the material Icons class. - uses-material-design: true - # To add assets to your application, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware. - # For details regarding adding assets from package dependencies, see - # https://flutter.dev/assets-and-images/#from-packages - # To add custom fonts to your application, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts from package dependencies, - # see https://flutter.dev/custom-fonts/#from-packages + uses-material-design: true \ No newline at end of file diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart index ac681fe3..77eb54c5 100644 --- a/example/test/widget_test.dart +++ b/example/test/widget_test.dart @@ -8,7 +8,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import '../lib/main.dart'; +import 'package:background_location_example/main.dart'; diff --git a/pubspec.yaml b/pubspec.yaml index cf939696..e9e90797 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -18,7 +18,7 @@ dev_dependencies: flutter_test: sdk: flutter #test: ^1.16.8 - pedantic: ^1.11.1 + flutter_lints: ^3.0.1 flutter: plugin: From 8d77c444935bdba3b6925141315e602154644990 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Tue, 26 Mar 2024 12:04:52 +0100 Subject: [PATCH 03/20] remove and ignore eclipse and vscode project files --- .gitignore | 5 +++- .metadata | 10 -------- .project | 17 -------------- .settings/org.eclipse.buildship.core.prefs | 13 ----------- .vscode/launch.json | 14 ----------- .vscode/settings.json | 3 --- android/.project | 23 ------------------- .../org.eclipse.buildship.core.prefs | 13 ----------- android/.settings/org.eclipse.jdt.core.prefs | 4 ---- background_location.iml | 20 ---------------- example/.metadata | 10 -------- example/android/.project | 17 -------------- .../org.eclipse.buildship.core.prefs | 2 -- 13 files changed, 4 insertions(+), 147 deletions(-) delete mode 100644 .metadata delete mode 100644 .project delete mode 100644 .settings/org.eclipse.buildship.core.prefs delete mode 100644 .vscode/launch.json delete mode 100644 .vscode/settings.json delete mode 100644 android/.project delete mode 100644 android/.settings/org.eclipse.buildship.core.prefs delete mode 100644 android/.settings/org.eclipse.jdt.core.prefs delete mode 100644 background_location.iml delete mode 100644 example/.metadata delete mode 100644 example/android/.project delete mode 100644 example/android/.settings/org.eclipse.buildship.core.prefs diff --git a/.gitignore b/.gitignore index 3fabd172..c16da92c 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,7 @@ example/ios/Flutter/flutter_export_environment.sh .idea/ .gradle/ *.iml -pubspec.lock \ No newline at end of file +pubspec.lock +.metadata +.project +.vscode/ \ No newline at end of file diff --git a/.metadata b/.metadata deleted file mode 100644 index ea562e9a..00000000 --- a/.metadata +++ /dev/null @@ -1,10 +0,0 @@ -# This file tracks properties of this Flutter project. -# Used by Flutter tool to assess capabilities and perform upgrades etc. -# -# This file should be version controlled and should not be manually edited. - -version: - revision: 20e59316b8b8474554b38493b8ca888794b0234a - channel: stable - -project_type: plugin diff --git a/.project b/.project deleted file mode 100644 index 460b88e5..00000000 --- a/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - backgeound_location_ - Project backgeound_location_ created by Buildship. - - - - - org.eclipse.buildship.core.gradleprojectbuilder - - - - - - org.eclipse.buildship.core.gradleprojectnature - - diff --git a/.settings/org.eclipse.buildship.core.prefs b/.settings/org.eclipse.buildship.core.prefs deleted file mode 100644 index 7338097b..00000000 --- a/.settings/org.eclipse.buildship.core.prefs +++ /dev/null @@ -1,13 +0,0 @@ -arguments= -auto.sync=false -build.scans.enabled=false -connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(5.4)) -connection.project.dir= -eclipse.preferences.version=1 -gradle.user.home= -java.home= -jvm.arguments= -offline.mode=false -override.workspace.settings=true -show.console.view=true -show.executions.view=true diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 3e74e507..00000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Flutter", - "request": "launch", - "type": "dart", - "program": "./example/lib/main.dart" - } - ] -} diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index dc3b8952..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "java.configuration.updateBuildConfiguration": "interactive" -} \ No newline at end of file diff --git a/android/.project b/android/.project deleted file mode 100644 index 0abbca39..00000000 --- a/android/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - backgeound_location - Project backgeound_location created by Buildship. - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.buildship.core.gradleprojectbuilder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.buildship.core.gradleprojectnature - - diff --git a/android/.settings/org.eclipse.buildship.core.prefs b/android/.settings/org.eclipse.buildship.core.prefs deleted file mode 100644 index 9c7f4af9..00000000 --- a/android/.settings/org.eclipse.buildship.core.prefs +++ /dev/null @@ -1,13 +0,0 @@ -arguments= -auto.sync=false -build.scans.enabled=false -connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(5.4)) -connection.project.dir=../example/android -eclipse.preferences.version=1 -gradle.user.home= -java.home= -jvm.arguments= -offline.mode=false -override.workspace.settings=true -show.console.view=true -show.executions.view=true diff --git a/android/.settings/org.eclipse.jdt.core.prefs b/android/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index eb950225..00000000 --- a/android/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=13 -org.eclipse.jdt.core.compiler.compliance=13 -org.eclipse.jdt.core.compiler.source=13 diff --git a/background_location.iml b/background_location.iml deleted file mode 100644 index a4d2e266..00000000 --- a/background_location.iml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/example/.metadata b/example/.metadata deleted file mode 100644 index e0236519..00000000 --- a/example/.metadata +++ /dev/null @@ -1,10 +0,0 @@ -# This file tracks properties of this Flutter project. -# Used by Flutter tool to assess capabilities and perform upgrades etc. -# -# This file should be version controlled and should not be manually edited. - -version: - revision: 20e59316b8b8474554b38493b8ca888794b0234a - channel: stable - -project_type: app diff --git a/example/android/.project b/example/android/.project deleted file mode 100644 index 3964dd3f..00000000 --- a/example/android/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - android - Project android created by Buildship. - - - - - org.eclipse.buildship.core.gradleprojectbuilder - - - - - - org.eclipse.buildship.core.gradleprojectnature - - diff --git a/example/android/.settings/org.eclipse.buildship.core.prefs b/example/android/.settings/org.eclipse.buildship.core.prefs deleted file mode 100644 index e8895216..00000000 --- a/example/android/.settings/org.eclipse.buildship.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -connection.project.dir= -eclipse.preferences.version=1 From 4a85134cc8eebbe7e4a17184a0484670ee5045c5 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Tue, 26 Mar 2024 12:16:25 +0100 Subject: [PATCH 04/20] fix lints --- example/lib/main.dart | 42 ++++++++++++++++-------------- example/pubspec.yaml | 1 - example/test/widget_test.dart | 2 +- lib/background_location.dart | 30 +++++++++++---------- pubspec.yaml | 1 - test/background_location_test.dart | 17 ------------ 6 files changed, 39 insertions(+), 54 deletions(-) delete mode 100644 test/background_location_test.dart diff --git a/example/lib/main.dart b/example/lib/main.dart index fa1c342c..dac70217 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,14 +1,16 @@ import 'package:background_location/background_location.dart'; import 'package:flutter/material.dart'; -void main() => runApp(MyApp()); +void main() => runApp(const MyApp()); class MyApp extends StatefulWidget { + const MyApp({Key? key}) : super(key: key); + @override - _MyAppState createState() => _MyAppState(); + MyAppState createState() => MyAppState(); } -class _MyAppState extends State { +class MyAppState extends State { String latitude = 'waiting...'; String longitude = 'waiting...'; String altitude = 'waiting...'; @@ -16,7 +18,7 @@ class _MyAppState extends State { String bearing = 'waiting...'; String speed = 'waiting...'; String time = 'waiting...'; - bool? serviceRunning = null; + bool? serviceRunning; @override void initState() { @@ -33,14 +35,14 @@ class _MyAppState extends State { body: Center( child: ListView( children: [ - locationData('Latitude: ' + latitude), - locationData('Longitude: ' + longitude), - locationData('Altitude: ' + altitude), - locationData('Accuracy: ' + accuracy), - locationData('Bearing: ' + bearing), - locationData('Speed: ' + speed), - locationData('Time: ' + time), - locationData('IsServiceRunning: ' + serviceRunning.toString()), + locationData('Latitude: $latitude'), + locationData('Longitude: $longitude'), + locationData('Altitude: $altitude'), + locationData('Accuracy: $accuracy'), + locationData('Bearing: $bearing'), + locationData('Speed: $speed'), + locationData('Time: $time'), + locationData('IsServiceRunning: $serviceRunning'), ElevatedButton( onPressed: () async { await BackgroundLocation.setAndroidNotification( @@ -63,7 +65,7 @@ class _MyAppState extends State { location.time!.toInt()) .toString(); }); - print('''\n + debugPrint('''\n Latitude: $latitude Longitude: $longitude Altitude: $altitude @@ -75,27 +77,27 @@ class _MyAppState extends State { '''); }); }, - child: Text('Start Location Service')), + child: const Text('Start Location Service')), ElevatedButton( onPressed: () { BackgroundLocation.stopLocationService(); }, - child: Text('Stop Location Service')), + child: const Text('Stop Location Service')), ElevatedButton( onPressed: () { BackgroundLocation.isServiceRunning().then((value) { setState(() { serviceRunning = value; }); - print("Is Running: $value"); + debugPrint("Is Running: $value"); }); }, - child: Text('Check service')), + child: const Text('Check service')), ElevatedButton( onPressed: () { getCurrentLocation(); }, - child: Text('Get Current Location')), + child: const Text('Get Current Location')), ], ), ), @@ -106,7 +108,7 @@ class _MyAppState extends State { Widget locationData(String data) { return Text( data, - style: TextStyle( + style: const TextStyle( fontWeight: FontWeight.bold, fontSize: 18, ), @@ -116,7 +118,7 @@ class _MyAppState extends State { void getCurrentLocation() { BackgroundLocation().getCurrentLocation().then((location) { - print('This is current Location ' + location.toMap().toString()); + debugPrint('This is current Location ${location.toMap()}'); }); } diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 7c15f440..047bce86 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -14,7 +14,6 @@ dev_dependencies: flutter_test: sdk: flutter flutter_lints: ^3.0.1 - background_location: path: ../ diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart index 77eb54c5..7c068e61 100644 --- a/example/test/widget_test.dart +++ b/example/test/widget_test.dart @@ -15,7 +15,7 @@ import 'package:background_location_example/main.dart'; void main() { testWidgets('Verify Platform version', (WidgetTester tester) async { // Build our app and trigger a frame. - await tester.pumpWidget(MyApp()); + await tester.pumpWidget(const MyApp()); // Verify that platform version is retrieved. expect( diff --git a/lib/background_location.dart b/lib/background_location.dart index 2681d5a4..2026380c 100644 --- a/lib/background_location.dart +++ b/lib/background_location.dart @@ -5,10 +5,10 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; /// BackgroundLocation plugin to get background -/// lcoation updates in iOS and Android +/// location updates in iOS and Android class BackgroundLocation { // The channel to be used for communication. - // This channel is also refrenced inside both iOS and Abdroid classes + // This channel is also referenced inside both iOS and Android classes static const MethodChannel _channel = MethodChannel('com.almoullim.background_location/methods'); @@ -53,16 +53,18 @@ class BackgroundLocation { Future getCurrentLocation() async { var completer = Completer(); - var _location = Location(); - await getLocationUpdates((location) { - _location.latitude = location.latitude; - _location.longitude = location.longitude; - _location.accuracy = location.accuracy; - _location.altitude = location.altitude; - _location.bearing = location.bearing; - _location.speed = location.speed; - _location.time = location.time; - completer.complete(_location); + await getLocationUpdates((l) { + final location = Location( + accuracy: l.accuracy, + altitude: l.altitude, + bearing: l.bearing, + isMock: l.isMock, + latitude: l.latitude, + longitude: l.longitude, + speed: l.speed, + time: l.time + ); + completer.complete(location); }); return completer.future; @@ -70,10 +72,10 @@ class BackgroundLocation { - /// Register a function to recive location updates as long as the location + /// Register a function to receive location updates as long as the location /// service has started static getLocationUpdates(Function(Location) location) { - // add a handler on the channel to recive updates from the native classes + // add a handler on the channel to receive updates from the native classes _channel.setMethodCallHandler((MethodCall methodCall) async { if (methodCall.method == 'location') { var locationData = Map.from(methodCall.arguments); diff --git a/pubspec.yaml b/pubspec.yaml index e9e90797..29e6c9e4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,6 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - #test: ^1.16.8 flutter_lints: ^3.0.1 flutter: diff --git a/test/background_location_test.dart b/test/background_location_test.dart deleted file mode 100644 index 9773336e..00000000 --- a/test/background_location_test.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'package:flutter/services.dart'; -import 'package:flutter_test/flutter_test.dart'; -// import 'package:background_location/background_location.dart'; - -void main() { - const channel = MethodChannel('background_location'); - - setUp(() { - channel.setMockMethodCallHandler((MethodCall methodCall) async { - return '42'; - }); - }); - - tearDown(() { - channel.setMockMethodCallHandler(null); - }); -} From f2f5bb3b2a2eae7a5798a56dc8da760f11959aea Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Tue, 26 Mar 2024 12:18:39 +0100 Subject: [PATCH 05/20] format --- example/pubspec.yaml | 4 +-- lib/background_location.dart | 67 +++++++++++++++++++++--------------- 2 files changed, 41 insertions(+), 30 deletions(-) diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 047bce86..0a3732f1 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -9,13 +9,13 @@ dependencies: flutter: sdk: flutter cupertino_icons: ^1.0.2 + background_location: + path: ../ dev_dependencies: flutter_test: sdk: flutter flutter_lints: ^3.0.1 - background_location: - path: ../ flutter: uses-material-design: true \ No newline at end of file diff --git a/lib/background_location.dart b/lib/background_location.dart index 2026380c..469c38db 100644 --- a/lib/background_location.dart +++ b/lib/background_location.dart @@ -24,16 +24,27 @@ class BackgroundLocation { } /// Start receiving location updated - static startLocationService({double distanceFilter = 0.0, bool forceAndroidLocationManager = false}) async { - return await _channel.invokeMethod('start_location_service', - {'distance_filter': distanceFilter, 'force_location_manager': forceAndroidLocationManager}); + static startLocationService({ + double distanceFilter = 0.0, + bool forceAndroidLocationManager = false, + }) async { + return await _channel + .invokeMethod('start_location_service', { + 'distance_filter': distanceFilter, + 'force_location_manager': forceAndroidLocationManager + }); } - static setAndroidNotification( - {String? title, String? message, String? icon}) async { + static setAndroidNotification({ + String? title, + String? message, + String? icon, + }) async { if (Platform.isAndroid) { - return await _channel.invokeMethod('set_android_notification', - {'title': title, 'message': message, 'icon': icon}); + return await _channel.invokeMethod( + 'set_android_notification', + {'title': title, 'message': message, 'icon': icon}, + ); } else { //return Promise.resolve(); } @@ -62,7 +73,7 @@ class BackgroundLocation { latitude: l.latitude, longitude: l.longitude, speed: l.speed, - time: l.time + time: l.time, ); completer.complete(location); }); @@ -70,8 +81,6 @@ class BackgroundLocation { return completer.future; } - - /// Register a function to receive location updates as long as the location /// service has started static getLocationUpdates(Function(Location) location) { @@ -82,14 +91,15 @@ class BackgroundLocation { // Call the user passed function location( Location( - latitude: locationData['latitude'], - longitude: locationData['longitude'], - altitude: locationData['altitude'], - accuracy: locationData['accuracy'], - bearing: locationData['bearing'], - speed: locationData['speed'], - time: locationData['time'], - isMock: locationData['is_mock']), + latitude: locationData['latitude'], + longitude: locationData['longitude'], + altitude: locationData['altitude'], + accuracy: locationData['accuracy'], + bearing: locationData['bearing'], + speed: locationData['speed'], + time: locationData['time'], + isMock: locationData['is_mock'], + ), ); } }); @@ -107,15 +117,16 @@ class Location { double? time; bool? isMock; - Location( - {@required this.longitude, - @required this.latitude, - @required this.altitude, - @required this.accuracy, - @required this.bearing, - @required this.speed, - @required this.time, - @required this.isMock}); + Location({ + @required this.longitude, + @required this.latitude, + @required this.altitude, + @required this.accuracy, + @required this.bearing, + @required this.speed, + @required this.time, + @required this.isMock, + }); toMap() { var obj = { @@ -126,7 +137,7 @@ class Location { 'accuracy': accuracy, 'speed': speed, 'time': time, - 'is_mock': isMock + 'is_mock': isMock, }; return obj; } From 9a420054a31e373cf447c18150c8ab38972bd8aa Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Tue, 26 Mar 2024 12:28:57 +0100 Subject: [PATCH 06/20] type safety, migrate `@required` to `migrate` --- lib/background_location.dart | 94 +++++++++++++++++------------------- 1 file changed, 45 insertions(+), 49 deletions(-) diff --git a/lib/background_location.dart b/lib/background_location.dart index 469c38db..e97cb1f0 100644 --- a/lib/background_location.dart +++ b/lib/background_location.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'dart:io' show Platform; -import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; /// BackgroundLocation plugin to get background @@ -13,29 +12,30 @@ class BackgroundLocation { MethodChannel('com.almoullim.background_location/methods'); /// Stop receiving location updates - static stopLocationService() async { - return await _channel.invokeMethod('stop_location_service'); - } + static stopLocationService() async => + _channel.invokeMethod('stop_location_service'); /// Check if the location update service is running static Future isServiceRunning() async { - var result = await _channel.invokeMethod('is_service_running'); + final result = await _channel.invokeMethod('is_service_running'); return result == true; } /// Start receiving location updated - static startLocationService({ + static Future startLocationService({ double distanceFilter = 0.0, bool forceAndroidLocationManager = false, }) async { - return await _channel - .invokeMethod('start_location_service', { - 'distance_filter': distanceFilter, - 'force_location_manager': forceAndroidLocationManager - }); + return await _channel.invokeMethod( + 'start_location_service', + { + 'distance_filter': distanceFilter, + 'force_location_manager': forceAndroidLocationManager + }, + ); } - static setAndroidNotification({ + static Future setAndroidNotification({ String? title, String? message, String? icon, @@ -50,7 +50,7 @@ class BackgroundLocation { } } - static setAndroidConfiguration(int interval) async { + static Future setAndroidConfiguration(int interval) async { if (Platform.isAndroid) { return await _channel.invokeMethod('set_configuration', { 'interval': interval.toString(), @@ -64,18 +64,17 @@ class BackgroundLocation { Future getCurrentLocation() async { var completer = Completer(); - await getLocationUpdates((l) { - final location = Location( - accuracy: l.accuracy, - altitude: l.altitude, - bearing: l.bearing, - isMock: l.isMock, - latitude: l.latitude, - longitude: l.longitude, - speed: l.speed, - time: l.time, - ); - completer.complete(location); + getLocationUpdates((location) { + completer.complete(Location( + accuracy: location.accuracy, + altitude: location.altitude, + bearing: location.bearing, + isMock: location.isMock, + latitude: location.latitude, + longitude: location.longitude, + speed: location.speed, + time: location.time, + )); }); return completer.future; @@ -83,13 +82,13 @@ class BackgroundLocation { /// Register a function to receive location updates as long as the location /// service has started - static getLocationUpdates(Function(Location) location) { + static void getLocationUpdates(void Function(Location location) callback) { // add a handler on the channel to receive updates from the native classes _channel.setMethodCallHandler((MethodCall methodCall) async { if (methodCall.method == 'location') { - var locationData = Map.from(methodCall.arguments); + final locationData = Map.from(methodCall.arguments); // Call the user passed function - location( + callback( Location( latitude: locationData['latitude'], longitude: locationData['longitude'], @@ -118,27 +117,24 @@ class Location { bool? isMock; Location({ - @required this.longitude, - @required this.latitude, - @required this.altitude, - @required this.accuracy, - @required this.bearing, - @required this.speed, - @required this.time, - @required this.isMock, + required this.longitude, + required this.latitude, + required this.altitude, + required this.accuracy, + required this.bearing, + required this.speed, + required this.time, + required this.isMock, }); - toMap() { - var obj = { - 'latitude': latitude, - 'longitude': longitude, - 'altitude': altitude, - 'bearing': bearing, - 'accuracy': accuracy, - 'speed': speed, - 'time': time, - 'is_mock': isMock, - }; - return obj; - } + Map toMap() => { + 'latitude': latitude, + 'longitude': longitude, + 'altitude': altitude, + 'bearing': bearing, + 'accuracy': accuracy, + 'speed': speed, + 'time': time, + 'is_mock': isMock, + }; } From 99b03294390ddb077dd44172a7c5c9d8fd54b742 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Tue, 26 Mar 2024 12:37:05 +0100 Subject: [PATCH 07/20] migrate package to src/ structure --- lib/background_location.dart | 142 +------------------------------ lib/src/background_location.dart | 112 ++++++++++++++++++++++++ lib/src/location.dart | 33 +++++++ 3 files changed, 147 insertions(+), 140 deletions(-) create mode 100644 lib/src/background_location.dart create mode 100644 lib/src/location.dart diff --git a/lib/background_location.dart b/lib/background_location.dart index e97cb1f0..2393952b 100644 --- a/lib/background_location.dart +++ b/lib/background_location.dart @@ -1,140 +1,2 @@ -import 'dart:async'; -import 'dart:io' show Platform; - -import 'package:flutter/services.dart'; - -/// BackgroundLocation plugin to get background -/// location updates in iOS and Android -class BackgroundLocation { - // The channel to be used for communication. - // This channel is also referenced inside both iOS and Android classes - static const MethodChannel _channel = - MethodChannel('com.almoullim.background_location/methods'); - - /// Stop receiving location updates - static stopLocationService() async => - _channel.invokeMethod('stop_location_service'); - - /// Check if the location update service is running - static Future isServiceRunning() async { - final result = await _channel.invokeMethod('is_service_running'); - return result == true; - } - - /// Start receiving location updated - static Future startLocationService({ - double distanceFilter = 0.0, - bool forceAndroidLocationManager = false, - }) async { - return await _channel.invokeMethod( - 'start_location_service', - { - 'distance_filter': distanceFilter, - 'force_location_manager': forceAndroidLocationManager - }, - ); - } - - static Future setAndroidNotification({ - String? title, - String? message, - String? icon, - }) async { - if (Platform.isAndroid) { - return await _channel.invokeMethod( - 'set_android_notification', - {'title': title, 'message': message, 'icon': icon}, - ); - } else { - //return Promise.resolve(); - } - } - - static Future setAndroidConfiguration(int interval) async { - if (Platform.isAndroid) { - return await _channel.invokeMethod('set_configuration', { - 'interval': interval.toString(), - }); - } else { - //return Promise.resolve(); - } - } - - /// Get the current location once. - Future getCurrentLocation() async { - var completer = Completer(); - - getLocationUpdates((location) { - completer.complete(Location( - accuracy: location.accuracy, - altitude: location.altitude, - bearing: location.bearing, - isMock: location.isMock, - latitude: location.latitude, - longitude: location.longitude, - speed: location.speed, - time: location.time, - )); - }); - - return completer.future; - } - - /// Register a function to receive location updates as long as the location - /// service has started - static void getLocationUpdates(void Function(Location location) callback) { - // add a handler on the channel to receive updates from the native classes - _channel.setMethodCallHandler((MethodCall methodCall) async { - if (methodCall.method == 'location') { - final locationData = Map.from(methodCall.arguments); - // Call the user passed function - callback( - Location( - latitude: locationData['latitude'], - longitude: locationData['longitude'], - altitude: locationData['altitude'], - accuracy: locationData['accuracy'], - bearing: locationData['bearing'], - speed: locationData['speed'], - time: locationData['time'], - isMock: locationData['is_mock'], - ), - ); - } - }); - } -} - -/// about the user current location -class Location { - double? latitude; - double? longitude; - double? altitude; - double? bearing; - double? accuracy; - double? speed; - double? time; - bool? isMock; - - Location({ - required this.longitude, - required this.latitude, - required this.altitude, - required this.accuracy, - required this.bearing, - required this.speed, - required this.time, - required this.isMock, - }); - - Map toMap() => { - 'latitude': latitude, - 'longitude': longitude, - 'altitude': altitude, - 'bearing': bearing, - 'accuracy': accuracy, - 'speed': speed, - 'time': time, - 'is_mock': isMock, - }; -} +export 'src/location.dart'; +export 'src/background_location.dart'; \ No newline at end of file diff --git a/lib/src/background_location.dart b/lib/src/background_location.dart new file mode 100644 index 00000000..523440d1 --- /dev/null +++ b/lib/src/background_location.dart @@ -0,0 +1,112 @@ +import 'dart:async'; +import 'dart:io' show Platform; + +import 'package:background_location/background_location.dart'; +import 'package:flutter/services.dart'; + +/// BackgroundLocation plugin to get background +/// location updates in iOS and Android +class BackgroundLocation { + /// The channel to be used for communication. + /// This channel is also referenced inside both iOS and Android classes + static const MethodChannel _channel = + MethodChannel('com.almoullim.background_location/methods'); + + /// Stop receiving location updates + static stopLocationService() async => + _channel.invokeMethod('stop_location_service'); + + /// Check if the location update service is running + static Future isServiceRunning() async => + await _channel.invokeMethod('is_service_running') ?? false; + + /// Start receiving location updated + static Future startLocationService({ + double distanceFilter = 0.0, + bool forceAndroidLocationManager = false, + }) async { + return await _channel.invokeMethod( + 'start_location_service', + { + 'distance_filter': distanceFilter, + 'force_location_manager': forceAndroidLocationManager + }, + ); + } + + /// Set the notification on android devices. + /// Does nothing if called on other platforms. + static Future setAndroidNotification({ + String? title, + String? message, + String? icon, + }) async { + if (!Platform.isAndroid) return; + + return await _channel.invokeMethod( + 'set_android_notification', + { + 'title': title, + 'message': message, + 'icon': icon, + }, + ); + } + + /// Set the android configuration. + /// Does nothing if called on other platforms. + static Future setAndroidConfiguration(int interval) async { + if (!Platform.isAndroid) return; + + return await _channel.invokeMethod( + 'set_configuration', + { + 'interval': interval.toString(), + }, + ); + } + + /// Get the current location once. + Future getCurrentLocation() async { + var completer = Completer(); + + getLocationUpdates((location) { + completer.complete(Location( + accuracy: location.accuracy, + altitude: location.altitude, + bearing: location.bearing, + isMock: location.isMock, + latitude: location.latitude, + longitude: location.longitude, + speed: location.speed, + time: location.time, + )); + }); + + return completer.future; + } + + /// Register a function to receive location updates as long as the location + /// service has started + static void getLocationUpdates(void Function(Location location) callback) { + // add a handler on the channel to receive updates from the native classes + _channel.setMethodCallHandler((MethodCall methodCall) async { + if (methodCall.method == 'location') { + final locationData = Map.from(methodCall.arguments); + // Call the user passed function + callback( + Location( + latitude: locationData['latitude'], + longitude: locationData['longitude'], + altitude: locationData['altitude'], + accuracy: locationData['accuracy'], + bearing: locationData['bearing'], + speed: locationData['speed'], + time: locationData['time'], + isMock: locationData['is_mock'], + ), + ); + } + }); + } +} diff --git a/lib/src/location.dart b/lib/src/location.dart new file mode 100644 index 00000000..ce3f7011 --- /dev/null +++ b/lib/src/location.dart @@ -0,0 +1,33 @@ +/// Location data +class Location { + double? latitude; + double? longitude; + double? altitude; + double? bearing; + double? accuracy; + double? speed; + double? time; + bool? isMock; + + Location({ + required this.longitude, + required this.latitude, + required this.altitude, + required this.accuracy, + required this.bearing, + required this.speed, + required this.time, + required this.isMock, + }); + + Map toMap() => { + 'latitude': latitude, + 'longitude': longitude, + 'altitude': altitude, + 'bearing': bearing, + 'accuracy': accuracy, + 'speed': speed, + 'time': time, + 'is_mock': isMock, + }; +} From b9be4af5b52742780eaecadfa02e274fa7fd418c Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Tue, 26 Mar 2024 12:37:37 +0100 Subject: [PATCH 08/20] Delete .classpath --- android/.classpath | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 android/.classpath diff --git a/android/.classpath b/android/.classpath deleted file mode 100644 index 32d66919..00000000 --- a/android/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - From 32793b0fbde56112f39c862fc8f9ee650e23783b Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Tue, 26 Mar 2024 12:49:53 +0100 Subject: [PATCH 09/20] add `Location.fromMap` factory --- lib/src/background_location.dart | 45 +++++++++----------------------- lib/src/location.dart | 29 +++++++++++++------- 2 files changed, 32 insertions(+), 42 deletions(-) diff --git a/lib/src/background_location.dart b/lib/src/background_location.dart index 523440d1..175c5aa7 100644 --- a/lib/src/background_location.dart +++ b/lib/src/background_location.dart @@ -24,15 +24,14 @@ class BackgroundLocation { static Future startLocationService({ double distanceFilter = 0.0, bool forceAndroidLocationManager = false, - }) async { - return await _channel.invokeMethod( - 'start_location_service', - { - 'distance_filter': distanceFilter, - 'force_location_manager': forceAndroidLocationManager - }, - ); - } + }) async => + _channel.invokeMethod( + 'start_location_service', + { + 'distance_filter': distanceFilter, + 'force_location_manager': forceAndroidLocationManager + }, + ); /// Set the notification on android devices. /// Does nothing if called on other platforms. @@ -67,20 +66,11 @@ class BackgroundLocation { } /// Get the current location once. - Future getCurrentLocation() async { + Future getCurrentLocation() { var completer = Completer(); getLocationUpdates((location) { - completer.complete(Location( - accuracy: location.accuracy, - altitude: location.altitude, - bearing: location.bearing, - isMock: location.isMock, - latitude: location.latitude, - longitude: location.longitude, - speed: location.speed, - time: location.time, - )); + completer.complete(location); }); return completer.future; @@ -92,20 +82,9 @@ class BackgroundLocation { // add a handler on the channel to receive updates from the native classes _channel.setMethodCallHandler((MethodCall methodCall) async { if (methodCall.method == 'location') { - final locationData = Map.from(methodCall.arguments); + final location = Location.fromMap(methodCall.arguments); // Call the user passed function - callback( - Location( - latitude: locationData['latitude'], - longitude: locationData['longitude'], - altitude: locationData['altitude'], - accuracy: locationData['accuracy'], - bearing: locationData['bearing'], - speed: locationData['speed'], - time: locationData['time'], - isMock: locationData['is_mock'], - ), - ); + callback(location); } }); } diff --git a/lib/src/location.dart b/lib/src/location.dart index ce3f7011..58baf636 100644 --- a/lib/src/location.dart +++ b/lib/src/location.dart @@ -1,15 +1,15 @@ /// Location data class Location { - double? latitude; - double? longitude; - double? altitude; - double? bearing; - double? accuracy; - double? speed; - double? time; - bool? isMock; + final double? latitude; + final double? longitude; + final double? altitude; + final double? bearing; + final double? accuracy; + final double? speed; + final double? time; + final bool? isMock; - Location({ + const Location({ required this.longitude, required this.latitude, required this.altitude, @@ -20,6 +20,17 @@ class Location { required this.isMock, }); + factory Location.fromMap(Map map) => Location( + longitude: map['longitude'] as double?, + latitude: map['latitude'] as double?, + altitude: map['altitude'] as double?, + accuracy: map['accuracy'] as double?, + bearing: map['bearing'] as double?, + speed: map['speed'] as double?, + time: map['time'] as double?, + isMock: map['isMock'] as bool?, + ); + Map toMap() => { 'latitude': latitude, 'longitude': longitude, From ce156695c890140f8d137b4a28d4a20dd27efd81 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Tue, 26 Mar 2024 13:18:06 +0100 Subject: [PATCH 10/20] refactor example app --- example/lib/main.dart | 163 +++++++++++++------------------ lib/src/background_location.dart | 2 +- lib/src/location.dart | 6 +- 3 files changed, 72 insertions(+), 99 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index dac70217..33387b8e 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -11,117 +11,90 @@ class MyApp extends StatefulWidget { } class MyAppState extends State { - String latitude = 'waiting...'; - String longitude = 'waiting...'; - String altitude = 'waiting...'; - String accuracy = 'waiting...'; - String bearing = 'waiting...'; - String speed = 'waiting...'; - String time = 'waiting...'; + Location? _lastLocation; bool? serviceRunning; - @override - void initState() { - super.initState(); - } - @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( - appBar: AppBar( - title: const Text('Background Location Service'), - ), - body: Center( - child: ListView( - children: [ - locationData('Latitude: $latitude'), - locationData('Longitude: $longitude'), - locationData('Altitude: $altitude'), - locationData('Accuracy: $accuracy'), - locationData('Bearing: $bearing'), - locationData('Speed: $speed'), - locationData('Time: $time'), - locationData('IsServiceRunning: $serviceRunning'), - ElevatedButton( - onPressed: () async { - await BackgroundLocation.setAndroidNotification( - title: 'Background service is running', - message: 'Background location in progress', - icon: '@mipmap/ic_launcher', - ); - //await BackgroundLocation.setAndroidConfiguration(1000); - await BackgroundLocation.startLocationService( - distanceFilter: 20); - BackgroundLocation.getLocationUpdates((location) { - setState(() { - latitude = location.latitude.toString(); - longitude = location.longitude.toString(); - accuracy = location.accuracy.toString(); - altitude = location.altitude.toString(); - bearing = location.bearing.toString(); - speed = location.speed.toString(); - time = DateTime.fromMillisecondsSinceEpoch( - location.time!.toInt()) - .toString(); - }); - debugPrint('''\n - Latitude: $latitude - Longitude: $longitude - Altitude: $altitude - Accuracy: $accuracy - Bearing: $bearing - Speed: $speed - Time: $time - IsServiceRunning: $serviceRunning - '''); - }); - }, - child: const Text('Start Location Service')), - ElevatedButton( - onPressed: () { - BackgroundLocation.stopLocationService(); - }, - child: const Text('Stop Location Service')), - ElevatedButton( - onPressed: () { - BackgroundLocation.isServiceRunning().then((value) { - setState(() { - serviceRunning = value; - }); - debugPrint("Is Running: $value"); - }); - }, - child: const Text('Check service')), - ElevatedButton( - onPressed: () { - getCurrentLocation(); - }, - child: const Text('Get Current Location')), - ], - ), + appBar: AppBar(title: const Text('Background Location Service')), + body: ListView( + children: [ + Text( + 'Latitude: ${_lastLocation?.latitude}\n' + 'Longitude: ${_lastLocation?.longitude}\n' + 'Altitude: ${_lastLocation?.altitude}\n' + 'Accuracy: ${_lastLocation?.accuracy}\n' + 'Bearing: ${_lastLocation?.bearing}\n' + 'Speed: ${_lastLocation?.speed}\n' + 'Time: ${_lastLocation?.time}\n' + 'IsServiceRunning: $serviceRunning', + style: const TextStyle( + fontWeight: FontWeight.bold, + fontSize: 18, + ), + textAlign: TextAlign.center, + ), + ElevatedButton( + onPressed: _startLocationService, + child: const Text('Start Location Service')), + ElevatedButton( + onPressed: _stopLocationService, + child: const Text('Stop Location Service')), + ElevatedButton( + onPressed: _checkService, + child: const Text('Check if service is running'), + ), + ElevatedButton( + onPressed: _getCurrentLocation, + child: const Text('Get Current Location'), + ), + ], ), ), ); } - Widget locationData(String data) { - return Text( - data, - style: const TextStyle( - fontWeight: FontWeight.bold, - fontSize: 18, - ), - textAlign: TextAlign.center, - ); + Future _getCurrentLocation() async { + final location = await BackgroundLocation().getCurrentLocation(); + debugPrint('Current Location: ${location.toMap()}'); } - void getCurrentLocation() { - BackgroundLocation().getCurrentLocation().then((location) { - debugPrint('This is current Location ${location.toMap()}'); + Future _stopLocationService() async { + await BackgroundLocation.stopLocationService(); + } + + Future _startLocationService() async { + await BackgroundLocation.setAndroidNotification( + title: 'Background service is running', + message: 'Background location in progress', + icon: '@mipmap/ic_launcher', + ); + //await BackgroundLocation.setAndroidConfiguration(1000); + await BackgroundLocation.startLocationService(distanceFilter: 20); + BackgroundLocation.getLocationUpdates((location) { + debugPrint( + '\n' + 'Latitude: ${location.latitude}\n' + 'Longitude: ${location.longitude}\n' + 'Altitude: ${location.altitude}\n' + 'Accuracy: ${location.accuracy}\n' + 'Bearing: ${location.bearing}\n' + 'Speed: ${location.speed}\n' + 'Time: ${location.time}\n' + 'IsServiceRunning: $serviceRunning', + ); + setState(() => _lastLocation = location); }); } + Future _checkService() async { + final isRunning = await BackgroundLocation.isServiceRunning(); + setState(() => serviceRunning = isRunning); + debugPrint("Is Running: $isRunning"); + } + @override void dispose() { BackgroundLocation.stopLocationService(); diff --git a/lib/src/background_location.dart b/lib/src/background_location.dart index 175c5aa7..07e3d37d 100644 --- a/lib/src/background_location.dart +++ b/lib/src/background_location.dart @@ -13,7 +13,7 @@ class BackgroundLocation { MethodChannel('com.almoullim.background_location/methods'); /// Stop receiving location updates - static stopLocationService() async => + static Future stopLocationService() async => _channel.invokeMethod('stop_location_service'); /// Check if the location update service is running diff --git a/lib/src/location.dart b/lib/src/location.dart index 58baf636..c037f41a 100644 --- a/lib/src/location.dart +++ b/lib/src/location.dart @@ -6,7 +6,7 @@ class Location { final double? bearing; final double? accuracy; final double? speed; - final double? time; + final DateTime time; final bool? isMock; const Location({ @@ -27,7 +27,7 @@ class Location { accuracy: map['accuracy'] as double?, bearing: map['bearing'] as double?, speed: map['speed'] as double?, - time: map['time'] as double?, + time: DateTime.fromMillisecondsSinceEpoch(map['time'] as int), isMock: map['isMock'] as bool?, ); @@ -41,4 +41,4 @@ class Location { 'time': time, 'is_mock': isMock, }; -} +} \ No newline at end of file From b748930bf74691c5c7bee87a232b46e81fe8c112 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Tue, 26 Mar 2024 13:18:19 +0100 Subject: [PATCH 11/20] update gradle to 7.6 --- example/android/gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index 6b665338..02e5f581 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip From 406679c2a7e7d5ccb939dfb1f23e5a25a11641df Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Tue, 26 Mar 2024 13:34:06 +0100 Subject: [PATCH 12/20] fix example app --- example/lib/main.dart | 36 +++++++++++++++++--------------- lib/src/background_location.dart | 16 +++++++++++--- lib/src/location.dart | 2 +- 3 files changed, 33 insertions(+), 21 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 33387b8e..f08efed3 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -12,7 +12,7 @@ class MyApp extends StatefulWidget { class MyAppState extends State { Location? _lastLocation; - bool? serviceRunning; + bool? _serviceRunning; @override Widget build(BuildContext context) { @@ -29,7 +29,7 @@ class MyAppState extends State { 'Bearing: ${_lastLocation?.bearing}\n' 'Speed: ${_lastLocation?.speed}\n' 'Time: ${_lastLocation?.time}\n' - 'IsServiceRunning: $serviceRunning', + 'IsServiceRunning: $_serviceRunning', style: const TextStyle( fontWeight: FontWeight.bold, fontSize: 18, @@ -73,25 +73,27 @@ class MyAppState extends State { ); //await BackgroundLocation.setAndroidConfiguration(1000); await BackgroundLocation.startLocationService(distanceFilter: 20); - BackgroundLocation.getLocationUpdates((location) { - debugPrint( - '\n' - 'Latitude: ${location.latitude}\n' - 'Longitude: ${location.longitude}\n' - 'Altitude: ${location.altitude}\n' - 'Accuracy: ${location.accuracy}\n' - 'Bearing: ${location.bearing}\n' - 'Speed: ${location.speed}\n' - 'Time: ${location.time}\n' - 'IsServiceRunning: $serviceRunning', - ); - setState(() => _lastLocation = location); - }); + BackgroundLocation.getLocationUpdates(onLocationUpdate); + } + + void onLocationUpdate(Location location) { + debugPrint( + '\n' + 'Latitude: ${location.latitude}\n' + 'Longitude: ${location.longitude}\n' + 'Altitude: ${location.altitude}\n' + 'Accuracy: ${location.accuracy}\n' + 'Bearing: ${location.bearing}\n' + 'Speed: ${location.speed}\n' + 'Time: ${location.time}\n' + 'IsServiceRunning: $_serviceRunning', + ); + setState(() => _lastLocation = location); } Future _checkService() async { final isRunning = await BackgroundLocation.isServiceRunning(); - setState(() => serviceRunning = isRunning); + setState(() => _serviceRunning = isRunning); debugPrint("Is Running: $isRunning"); } diff --git a/lib/src/background_location.dart b/lib/src/background_location.dart index 07e3d37d..52adcf4a 100644 --- a/lib/src/background_location.dart +++ b/lib/src/background_location.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'dart:io' show Platform; import 'package:background_location/background_location.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/services.dart'; /// BackgroundLocation plugin to get background @@ -81,10 +82,19 @@ class BackgroundLocation { static void getLocationUpdates(void Function(Location location) callback) { // add a handler on the channel to receive updates from the native classes _channel.setMethodCallHandler((MethodCall methodCall) async { + print('#1'); if (methodCall.method == 'location') { - final location = Location.fromMap(methodCall.arguments); - // Call the user passed function - callback(location); + print('#2'); + try { + final map = methodCall.arguments as Map; + final location = Location.fromMap(map.cast()); + print('#3'); + // Call the user passed function + callback.call(location); + } catch (error, stack) { + debugPrint(error.toString()); + debugPrintStack(stackTrace: stack); + } } }); } diff --git a/lib/src/location.dart b/lib/src/location.dart index c037f41a..a7332dba 100644 --- a/lib/src/location.dart +++ b/lib/src/location.dart @@ -27,7 +27,7 @@ class Location { accuracy: map['accuracy'] as double?, bearing: map['bearing'] as double?, speed: map['speed'] as double?, - time: DateTime.fromMillisecondsSinceEpoch(map['time'] as int), + time: DateTime.fromMillisecondsSinceEpoch((map['time'] as double).toInt()), isMock: map['isMock'] as bool?, ); From e82f6acd7baedf2ff57935ebe6da763db2c57a2e Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Tue, 26 Mar 2024 14:27:34 +0100 Subject: [PATCH 13/20] format android --- android/src/main/AndroidManifest.xml | 18 +-- .../BackgroundLocationPlugin.kt | 10 +- .../BackgroundLocationService.kt | 144 ++++++++++++++---- .../LocationUpdatesService.kt | 121 ++++++++++----- .../almoullim/background_location/Utils.kt | 30 +++- android/src/main/res/values/strings.xml | 10 +- 6 files changed, 240 insertions(+), 93 deletions(-) diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index 2c62b1fc..ee59d3e0 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -1,17 +1,17 @@ + package="com.almoullim.background_location"> - - - + + + + android:name=".LocationUpdatesService" + android:foregroundServiceType="location" + android:enabled="true" + android:exported="false" + android:permission=""/> diff --git a/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationPlugin.kt b/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationPlugin.kt index 9e4dc991..9a63674e 100644 --- a/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationPlugin.kt +++ b/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationPlugin.kt @@ -17,7 +17,10 @@ class BackgroundLocationPlugin : FlutterPlugin, ActivityAware { @SuppressWarnings("deprecation") fun registerWith(registrar: PluginRegistry.Registrar) { val service = BackgroundLocationService.getInstance() - service.onAttachedToEngine(registrar.context(), registrar.messenger()) + service.onAttachedToEngine( + registrar.context(), + registrar.messenger() + ) registrar.addRequestPermissionsResultListener(service) } @@ -27,7 +30,10 @@ class BackgroundLocationPlugin : FlutterPlugin, ActivityAware { override fun onAttachedToEngine(binding: FlutterPluginBinding) { - BackgroundLocationService.getInstance().onAttachedToEngine(binding.applicationContext, binding.binaryMessenger) + BackgroundLocationService.getInstance().onAttachedToEngine( + binding.applicationContext, + binding.binaryMessenger + ) } override fun onDetachedFromEngine(binding: FlutterPluginBinding) { diff --git a/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationService.kt b/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationService.kt index 860c4d4e..5f89f44a 100644 --- a/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationService.kt +++ b/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationService.kt @@ -21,9 +21,11 @@ import io.flutter.plugin.common.MethodCall import io.flutter.plugin.common.PluginRegistry -class BackgroundLocationService: MethodChannel.MethodCallHandler, PluginRegistry.RequestPermissionsResultListener { +class BackgroundLocationService : MethodChannel.MethodCallHandler, + PluginRegistry.RequestPermissionsResultListener { companion object { - const val METHOD_CHANNEL_NAME = "${BackgroundLocationPlugin.PLUGIN_ID}/methods" + const val METHOD_CHANNEL_NAME = + "${BackgroundLocationPlugin.PLUGIN_ID}/methods" private const val REQUEST_PERMISSIONS_REQUEST_CODE = 34 private var instance: BackgroundLocationService? = null @@ -70,7 +72,10 @@ class BackgroundLocationService: MethodChannel.MethodCallHandler, PluginRegistry } } - fun onAttachedToEngine(@NonNull context: Context, @NonNull messenger: BinaryMessenger) { + fun onAttachedToEngine( + @NonNull context: Context, + @NonNull messenger: BinaryMessenger + ) { this.context = context isAttached = true channel = MethodChannel(messenger, METHOD_CHANNEL_NAME) @@ -78,8 +83,10 @@ class BackgroundLocationService: MethodChannel.MethodCallHandler, PluginRegistry receiver = MyReceiver() - LocalBroadcastManager.getInstance(context).registerReceiver(receiver!!, - IntentFilter(LocationUpdatesService.ACTION_BROADCAST)) + LocalBroadcastManager.getInstance(context).registerReceiver( + receiver!!, + IntentFilter(LocationUpdatesService.ACTION_BROADCAST) + ) } fun onDetachedFromEngine() { @@ -91,7 +98,7 @@ class BackgroundLocationService: MethodChannel.MethodCallHandler, PluginRegistry fun setActivity(binding: ActivityPluginBinding?) { this.activity = binding?.activity - if(this.activity != null){ + if (this.activity != null) { if (Utils.requestingLocationUpdates(context!!)) { if (!checkPermissions()) { requestPermissions() @@ -102,21 +109,31 @@ class BackgroundLocationService: MethodChannel.MethodCallHandler, PluginRegistry } } - private fun startLocationService(distanceFilter: Double?, forceLocationManager : Boolean?): Int{ - LocalBroadcastManager.getInstance(context!!).registerReceiver(receiver!!, - IntentFilter(LocationUpdatesService.ACTION_BROADCAST)) + private fun startLocationService( + distanceFilter: Double?, + forceLocationManager: Boolean? + ): Int { + LocalBroadcastManager.getInstance(context!!).registerReceiver( + receiver!!, + IntentFilter(LocationUpdatesService.ACTION_BROADCAST) + ) if (!bound) { val intent = Intent(context, LocationUpdatesService::class.java) intent.putExtra("distance_filter", distanceFilter) intent.putExtra("force_location_manager", forceLocationManager) - context!!.bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE) + context!!.bindService( + intent, + serviceConnection, + Context.BIND_AUTO_CREATE + ) } return 0 } private fun isLocationServiceRunning(): Boolean { - val manager: ActivityManager = context!!.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager + val manager: ActivityManager = + context!!.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager for (service in manager.getRunningServices(Integer.MAX_VALUE)) { if (LocationUpdatesService::class.java.getName() == service.service.getClassName()) { if (service.foreground) @@ -130,7 +147,8 @@ class BackgroundLocationService: MethodChannel.MethodCallHandler, PluginRegistry private fun stopLocationService(): Int { service?.removeLocationUpdates() - LocalBroadcastManager.getInstance(context!!).unregisterReceiver(receiver!!) + LocalBroadcastManager.getInstance(context!!) + .unregisterReceiver(receiver!!) if (bound) { context!!.unbindService(serviceConnection) @@ -140,9 +158,14 @@ class BackgroundLocationService: MethodChannel.MethodCallHandler, PluginRegistry return 0 } - private fun setAndroidNotification(title: String?, message: String?, icon: String?):Int{ + private fun setAndroidNotification( + title: String?, + message: String?, + icon: String? + ): Int { if (title != null) LocationUpdatesService.NOTIFICATION_TITLE = title - if (message != null) LocationUpdatesService.NOTIFICATION_MESSAGE = message + if (message != null) LocationUpdatesService.NOTIFICATION_MESSAGE = + message if (icon != null) LocationUpdatesService.NOTIFICATION_ICON = icon if (service != null) { @@ -152,22 +175,48 @@ class BackgroundLocationService: MethodChannel.MethodCallHandler, PluginRegistry return 0 } - private fun setConfiguration(timeInterval: Long?):Int { + private fun setConfiguration(timeInterval: Long?): Int { if (timeInterval != null) { - LocationUpdatesService.UPDATE_INTERVAL_IN_MILLISECONDS = timeInterval - LocationUpdatesService.FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS = timeInterval/2 + LocationUpdatesService.UPDATE_INTERVAL_IN_MILLISECONDS = + timeInterval + LocationUpdatesService.FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS = + timeInterval / 2 } return 0 } - override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: MethodChannel.Result) { + override fun onMethodCall( + @NonNull call: MethodCall, + @NonNull result: MethodChannel.Result + ) { when (call.method) { "stop_location_service" -> result.success(stopLocationService()) - "start_location_service" -> result.success(startLocationService(call.argument("distance_filter"), call.argument("force_location_manager"))) + "start_location_service" -> result.success( + startLocationService( + call.argument( + "distance_filter" + ), call.argument("force_location_manager") + ) + ) + "is_service_running" -> result.success(isLocationServiceRunning()) - "set_android_notification" -> result.success(setAndroidNotification(call.argument("title"),call.argument("message"),call.argument("icon"))) - "set_configuration" -> result.success(setConfiguration(call.argument("interval")?.toLongOrNull())) + "set_android_notification" -> result.success( + setAndroidNotification( + call.argument("title"), + call.argument("message"), + call.argument("icon") + ) + ) + + "set_configuration" -> result.success( + setConfiguration( + call.argument( + "interval" + )?.toLongOrNull() + ) + ) + else -> result.notImplemented() } } @@ -188,7 +237,10 @@ class BackgroundLocationService: MethodChannel.MethodCallHandler, PluginRegistry * Checks the current permission for `ACCESS_FINE_LOCATION` */ private fun checkPermissions(): Boolean { - return PackageManager.PERMISSION_GRANTED == ActivityCompat.checkSelfPermission(context!!, Manifest.permission.ACCESS_FINE_LOCATION) + return PackageManager.PERMISSION_GRANTED == ActivityCompat.checkSelfPermission( + context!!, + Manifest.permission.ACCESS_FINE_LOCATION + ) } @@ -197,26 +249,40 @@ class BackgroundLocationService: MethodChannel.MethodCallHandler, PluginRegistry * Depending on the current activity, displays a rationale for the request. */ private fun requestPermissions() { - if(activity == null) { + if (activity == null) { return } - val shouldProvideRationale = ActivityCompat.shouldShowRequestPermissionRationale(activity!!, Manifest.permission.ACCESS_FINE_LOCATION) + val shouldProvideRationale = + ActivityCompat.shouldShowRequestPermissionRationale( + activity!!, + Manifest.permission.ACCESS_FINE_LOCATION + ) if (shouldProvideRationale) { - Log.i(BackgroundLocationPlugin.TAG, "Displaying permission rationale to provide additional context.") - Toast.makeText(context, R.string.permission_rationale, Toast.LENGTH_LONG).show() + Log.i( + BackgroundLocationPlugin.TAG, + "Displaying permission rationale to provide additional context." + ) + Toast.makeText( + context, + R.string.permission_rationale, + Toast.LENGTH_LONG + ).show() } else { Log.i(BackgroundLocationPlugin.TAG, "Requesting permission") - ActivityCompat.requestPermissions(activity!!, - arrayOf(Manifest.permission.ACCESS_FINE_LOCATION), - REQUEST_PERMISSIONS_REQUEST_CODE) + ActivityCompat.requestPermissions( + activity!!, + arrayOf(Manifest.permission.ACCESS_FINE_LOCATION), + REQUEST_PERMISSIONS_REQUEST_CODE + ) } } private inner class MyReceiver : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { - val location = intent.getParcelableExtra(LocationUpdatesService.EXTRA_LOCATION) + val location = + intent.getParcelableExtra(LocationUpdatesService.EXTRA_LOCATION) if (location != null) { val locationMap = HashMap() locationMap["latitude"] = location.latitude @@ -236,13 +302,25 @@ class BackgroundLocationService: MethodChannel.MethodCallHandler, PluginRegistry * Handle the response from a permission request * @return true if the result has been handled. */ -override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray): Boolean{ + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ): Boolean { Log.i(BackgroundLocationPlugin.TAG, "onRequestPermissionResult") if (requestCode == REQUEST_PERMISSIONS_REQUEST_CODE) { when { - grantResults!!.isEmpty() -> Log.i(BackgroundLocationPlugin.TAG, "User interaction was cancelled.") + grantResults!!.isEmpty() -> Log.i( + BackgroundLocationPlugin.TAG, + "User interaction was cancelled." + ) + grantResults[0] == PackageManager.PERMISSION_GRANTED -> service?.requestLocationUpdates() - else -> Toast.makeText(context, R.string.permission_denied_explanation, Toast.LENGTH_LONG).show() + else -> Toast.makeText( + context, + R.string.permission_denied_explanation, + Toast.LENGTH_LONG + ).show() } } return true diff --git a/android/src/main/kotlin/com/almoullim/background_location/LocationUpdatesService.kt b/android/src/main/kotlin/com/almoullim/background_location/LocationUpdatesService.kt index 37032eaf..9b51bc63 100644 --- a/android/src/main/kotlin/com/almoullim/background_location/LocationUpdatesService.kt +++ b/android/src/main/kotlin/com/almoullim/background_location/LocationUpdatesService.kt @@ -22,7 +22,8 @@ class LocationUpdatesService : Service() { override fun onBind(intent: Intent?): IBinder { val distanceFilter = intent?.getDoubleExtra("distance_filter", 0.0) if (intent != null) { - forceLocationManager = intent.getBooleanExtra("force_location_manager", false) + forceLocationManager = + intent.getBooleanExtra("force_location_manager", false) } if (distanceFilter != null) { createLocationRequest(distanceFilter) @@ -48,14 +49,17 @@ class LocationUpdatesService : Service() { var NOTIFICATION_MESSAGE = "Background service is running" var NOTIFICATION_ICON = "@mipmap/ic_launcher" - private const val PACKAGE_NAME = "com.google.android.gms.location.sample.locationupdatesforegroundservice" + private const val PACKAGE_NAME = + "com.google.android.gms.location.sample.locationupdatesforegroundservice" private val TAG = LocationUpdatesService::class.java.simpleName private const val CHANNEL_ID = "channel_01" internal const val ACTION_BROADCAST = "$PACKAGE_NAME.broadcast" internal const val EXTRA_LOCATION = "$PACKAGE_NAME.location" - private const val EXTRA_STARTED_FROM_NOTIFICATION = "$PACKAGE_NAME.started_from_notification" + private const val EXTRA_STARTED_FROM_NOTIFICATION = + "$PACKAGE_NAME.started_from_notification" var UPDATE_INTERVAL_IN_MILLISECONDS: Long = 1000 - var FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS = UPDATE_INTERVAL_IN_MILLISECONDS / 2 + var FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS = + UPDATE_INTERVAL_IN_MILLISECONDS / 2 private const val NOTIFICATION_ID = 12345678 private lateinit var broadcastReceiver: BroadcastReceiver @@ -71,22 +75,42 @@ class LocationUpdatesService : Service() { intent.putExtra(EXTRA_STARTED_FROM_NOTIFICATION, true) intent.action = "Localisation" //intent.setClass(this, getMainActivityClass(this)) - val pendingIntent = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - PendingIntent.getActivity(this, 1, intent, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT) - } else { - PendingIntent.getActivity(this, 1, intent, PendingIntent.FLAG_UPDATE_CURRENT) - } + val pendingIntent = + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + PendingIntent.getActivity( + this, + 1, + intent, + PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT + ) + } else { + PendingIntent.getActivity( + this, + 1, + intent, + PendingIntent.FLAG_UPDATE_CURRENT + ) + } val builder = NotificationCompat.Builder(this, "BackgroundLocation") - .setContentTitle(NOTIFICATION_TITLE) - .setOngoing(true) - .setSound(null) - .setPriority(NotificationCompat.PRIORITY_HIGH) - .setSmallIcon(resources.getIdentifier(NOTIFICATION_ICON, "mipmap", packageName)) - .setWhen(System.currentTimeMillis()) - .setStyle(NotificationCompat.BigTextStyle().bigText(NOTIFICATION_MESSAGE)) - .setContentIntent(pendingIntent) + .setContentTitle(NOTIFICATION_TITLE) + .setOngoing(true) + .setSound(null) + .setPriority(NotificationCompat.PRIORITY_HIGH) + .setSmallIcon( + resources.getIdentifier( + NOTIFICATION_ICON, + "mipmap", + packageName + ) + ) + .setWhen(System.currentTimeMillis()) + .setStyle( + NotificationCompat.BigTextStyle() + .bigText(NOTIFICATION_MESSAGE) + ) + .setContentIntent(pendingIntent) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { builder.setChannelId(CHANNEL_ID) @@ -100,13 +124,14 @@ class LocationUpdatesService : Service() { override fun onCreate() { val googleAPIAvailability = GoogleApiAvailability.getInstance() .isGooglePlayServicesAvailable(applicationContext) - + isGoogleApiAvailable = googleAPIAvailability == ConnectionResult.SUCCESS - + if (isGoogleApiAvailable && !this.forceLocationManager) { - mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this) - + mFusedLocationClient = + LocationServices.getFusedLocationProviderClient(this) + mFusedLocationCallback = object : LocationCallback() { override fun onLocationResult(locationResult: LocationResult) { // Smart cast to 'Location' is impossible, because 'locationResult.lastLocation' @@ -119,7 +144,8 @@ class LocationUpdatesService : Service() { } } } else { - mLocationManager = getSystemService(LOCATION_SERVICE) as LocationManager? + mLocationManager = + getSystemService(LOCATION_SERVICE) as LocationManager? mLocationManagerCallback = LocationListener { location -> println(location.toString()) @@ -133,10 +159,15 @@ class LocationUpdatesService : Service() { handlerThread.start() mServiceHandler = Handler(handlerThread.looper) - mNotificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager + mNotificationManager = + getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { val name = "Application Name" - val mChannel = NotificationChannel(CHANNEL_ID, name, NotificationManager.IMPORTANCE_DEFAULT) + val mChannel = NotificationChannel( + CHANNEL_ID, + name, + NotificationManager.IMPORTANCE_DEFAULT + ) mChannel.setSound(null, null) mNotificationManager!!.createNotificationChannel(mChannel) } @@ -161,10 +192,17 @@ class LocationUpdatesService : Service() { Utils.setRequestingLocationUpdates(this, true) try { if (isGoogleApiAvailable && !this.forceLocationManager) { - mFusedLocationClient!!.requestLocationUpdates(mLocationRequest!!, - mFusedLocationCallback!!, Looper.myLooper()) + mFusedLocationClient!!.requestLocationUpdates( + mLocationRequest!!, + mFusedLocationCallback!!, Looper.myLooper() + ) } else { - mLocationManager?.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0L, 0f, mLocationManagerCallback!!) + mLocationManager?.requestLocationUpdates( + LocationManager.GPS_PROVIDER, + 0L, + 0f, + mLocationManagerCallback!! + ) } } catch (unlikely: SecurityException) { Utils.setRequestingLocationUpdates(this, false) @@ -176,7 +214,8 @@ class LocationUpdatesService : Service() { isStarted = true startForeground(NOTIFICATION_ID, notification.build()) } else { - val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager + val notificationManager = + getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager notificationManager.notify(NOTIFICATION_ID, notification.build()) } } @@ -189,15 +228,16 @@ class LocationUpdatesService : Service() { private fun getLastLocation() { try { - if(isGoogleApiAvailable && !this.forceLocationManager) { + if (isGoogleApiAvailable && !this.forceLocationManager) { mFusedLocationClient!!.lastLocation - .addOnCompleteListener { task -> - if (task.isSuccessful && task.result != null) { - mLocation = task.result - } + .addOnCompleteListener { task -> + if (task.isSuccessful && task.result != null) { + mLocation = task.result } + } } else { - mLocation = mLocationManager!!.getLastKnownLocation(LocationManager.GPS_PROVIDER) + mLocation = + mLocationManager!!.getLastKnownLocation(LocationManager.GPS_PROVIDER) } } catch (unlikely: SecurityException) { } @@ -207,14 +247,16 @@ class LocationUpdatesService : Service() { mLocation = location val intent = Intent(ACTION_BROADCAST) intent.putExtra(EXTRA_LOCATION, location) - LocalBroadcastManager.getInstance(applicationContext).sendBroadcast(intent) + LocalBroadcastManager.getInstance(applicationContext) + .sendBroadcast(intent) } private fun createLocationRequest(distanceFilter: Double) { mLocationRequest = LocationRequest() mLocationRequest!!.interval = UPDATE_INTERVAL_IN_MILLISECONDS - mLocationRequest!!.fastestInterval = FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS + mLocationRequest!!.fastestInterval = + FASTEST_UPDATE_INTERVAL_IN_MILLISECONDS mLocationRequest!!.priority = LocationRequest.PRIORITY_HIGH_ACCURACY mLocationRequest!!.smallestDisplacement = distanceFilter.toFloat() } @@ -232,7 +274,9 @@ class LocationUpdatesService : Service() { unregisterReceiver(broadcastReceiver) try { if (isGoogleApiAvailable && !this.forceLocationManager) { - mFusedLocationClient!!.removeLocationUpdates(mFusedLocationCallback!!) + mFusedLocationClient!!.removeLocationUpdates( + mFusedLocationCallback!! + ) } else { mLocationManager!!.removeUpdates(mLocationManagerCallback!!) } @@ -246,7 +290,8 @@ class LocationUpdatesService : Service() { private fun getMainActivityClass(context: Context): Class<*>? { val packageName = context.packageName - val launchIntent = context.packageManager.getLaunchIntentForPackage(packageName) + val launchIntent = + context.packageManager.getLaunchIntentForPackage(packageName) val className = launchIntent?.component?.className ?: return null return try { diff --git a/android/src/main/kotlin/com/almoullim/background_location/Utils.kt b/android/src/main/kotlin/com/almoullim/background_location/Utils.kt index 9473cb67..4a987c02 100644 --- a/android/src/main/kotlin/com/almoullim/background_location/Utils.kt +++ b/android/src/main/kotlin/com/almoullim/background_location/Utils.kt @@ -21,20 +21,34 @@ import android.content.Context internal object Utils { - private const val KEY_REQUESTING_LOCATION_UPDATES = "requesting_location_updates" - private const val SHARED_PREFERENCES_FILE = "${BackgroundLocationPlugin.PLUGIN_ID}_preferences" + private const val KEY_REQUESTING_LOCATION_UPDATES = + "requesting_location_updates" + private const val SHARED_PREFERENCES_FILE = + "${BackgroundLocationPlugin.PLUGIN_ID}_preferences" fun requestingLocationUpdates(context: Context): Boolean { - return context.getSharedPreferences(SHARED_PREFERENCES_FILE, Context.MODE_PRIVATE).getBoolean(KEY_REQUESTING_LOCATION_UPDATES, false) + return context.getSharedPreferences( + SHARED_PREFERENCES_FILE, + Context.MODE_PRIVATE + ).getBoolean(KEY_REQUESTING_LOCATION_UPDATES, false) } - fun setRequestingLocationUpdates(context: Context, requestingLocationUpdates: Boolean) { - context.getSharedPreferences(SHARED_PREFERENCES_FILE, Context.MODE_PRIVATE) - .edit() - .putBoolean(KEY_REQUESTING_LOCATION_UPDATES, requestingLocationUpdates) - .apply() + fun setRequestingLocationUpdates( + context: Context, + requestingLocationUpdates: Boolean + ) { + context.getSharedPreferences( + SHARED_PREFERENCES_FILE, + Context.MODE_PRIVATE + ) + .edit() + .putBoolean( + KEY_REQUESTING_LOCATION_UPDATES, + requestingLocationUpdates + ) + .apply() } } diff --git a/android/src/main/res/values/strings.xml b/android/src/main/res/values/strings.xml index 8199f4ed..3718ea0c 100644 --- a/android/src/main/res/values/strings.xml +++ b/android/src/main/res/values/strings.xml @@ -13,9 +13,13 @@ Location Updates - Location permission is needed for core functionality - Permission was denied, but is needed for core - functionality. + Location permission is needed for core + functionality + + Permission was denied, but is + needed for core + functionality. + Settings OK Request location updates From ebc44804678de5fc71e2c4b6ffb9f96217610d80 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Tue, 26 Mar 2024 14:33:52 +0100 Subject: [PATCH 14/20] small android changes --- .../background_location/BackgroundLocationService.kt | 4 ++-- .../almoullim/background_location/LocationUpdatesService.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationService.kt b/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationService.kt index 5f89f44a..30875101 100644 --- a/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationService.kt +++ b/android/src/main/kotlin/com/almoullim/background_location/BackgroundLocationService.kt @@ -187,8 +187,8 @@ class BackgroundLocationService : MethodChannel.MethodCallHandler, } override fun onMethodCall( - @NonNull call: MethodCall, - @NonNull result: MethodChannel.Result + call: MethodCall, + result: MethodChannel.Result ) { when (call.method) { "stop_location_service" -> result.success(stopLocationService()) diff --git a/android/src/main/kotlin/com/almoullim/background_location/LocationUpdatesService.kt b/android/src/main/kotlin/com/almoullim/background_location/LocationUpdatesService.kt index 9b51bc63..74ee7c1f 100644 --- a/android/src/main/kotlin/com/almoullim/background_location/LocationUpdatesService.kt +++ b/android/src/main/kotlin/com/almoullim/background_location/LocationUpdatesService.kt @@ -239,7 +239,7 @@ class LocationUpdatesService : Service() { mLocation = mLocationManager!!.getLastKnownLocation(LocationManager.GPS_PROVIDER) } - } catch (unlikely: SecurityException) { + } catch (_: SecurityException) { } } From 3bd1eaa494112e6b97208d10620944456fd64220 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Tue, 26 Mar 2024 14:39:05 +0100 Subject: [PATCH 15/20] remove debug log --- lib/src/background_location.dart | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/src/background_location.dart b/lib/src/background_location.dart index 52adcf4a..51fe3699 100644 --- a/lib/src/background_location.dart +++ b/lib/src/background_location.dart @@ -82,13 +82,10 @@ class BackgroundLocation { static void getLocationUpdates(void Function(Location location) callback) { // add a handler on the channel to receive updates from the native classes _channel.setMethodCallHandler((MethodCall methodCall) async { - print('#1'); if (methodCall.method == 'location') { - print('#2'); try { final map = methodCall.arguments as Map; final location = Location.fromMap(map.cast()); - print('#3'); // Call the user passed function callback.call(location); } catch (error, stack) { From 0dbdabb295344716ccdba823940ad2e7c88d6027 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Tue, 26 Mar 2024 14:43:45 +0100 Subject: [PATCH 16/20] check in example app if mounted --- example/lib/main.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index f08efed3..16f489ca 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -88,12 +88,12 @@ class MyAppState extends State { 'Time: ${location.time}\n' 'IsServiceRunning: $_serviceRunning', ); - setState(() => _lastLocation = location); + if (mounted) setState(() => _lastLocation = location); } Future _checkService() async { final isRunning = await BackgroundLocation.isServiceRunning(); - setState(() => _serviceRunning = isRunning); + if (mounted) setState(() => _serviceRunning = isRunning); debugPrint("Is Running: $isRunning"); } From 6755ced897772d1fc3435f547c14934ecef15917 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Tue, 26 Mar 2024 14:48:24 +0100 Subject: [PATCH 17/20] remove distanceFilter in example app --- example/lib/main.dart | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 16f489ca..fe5c5dff 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -72,7 +72,7 @@ class MyAppState extends State { icon: '@mipmap/ic_launcher', ); //await BackgroundLocation.setAndroidConfiguration(1000); - await BackgroundLocation.startLocationService(distanceFilter: 20); + await BackgroundLocation.startLocationService(); BackgroundLocation.getLocationUpdates(onLocationUpdate); } @@ -85,8 +85,7 @@ class MyAppState extends State { 'Accuracy: ${location.accuracy}\n' 'Bearing: ${location.bearing}\n' 'Speed: ${location.speed}\n' - 'Time: ${location.time}\n' - 'IsServiceRunning: $_serviceRunning', + 'Time: ${location.time}', ); if (mounted) setState(() => _lastLocation = location); } From d894f5131e84d14dc9b284f167b6a11d826bf78b Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Tue, 26 Mar 2024 15:23:40 +0100 Subject: [PATCH 18/20] add overrides for toString, == and hashCode --- example/lib/main.dart | 2 +- lib/src/location.dart | 54 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index fe5c5dff..3080e9f7 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -58,7 +58,7 @@ class MyAppState extends State { Future _getCurrentLocation() async { final location = await BackgroundLocation().getCurrentLocation(); - debugPrint('Current Location: ${location.toMap()}'); + debugPrint('Current Location: $location'); } Future _stopLocationService() async { diff --git a/lib/src/location.dart b/lib/src/location.dart index a7332dba..db84e08b 100644 --- a/lib/src/location.dart +++ b/lib/src/location.dart @@ -1,4 +1,7 @@ +import 'package:flutter/cupertino.dart'; + /// Location data +@immutable class Location { final double? latitude; final double? longitude; @@ -20,6 +23,9 @@ class Location { required this.isMock, }); + /// Parse the [Location] from a Map. + /// + /// [time] gets converted from a unix timestamp in milliseconds. factory Location.fromMap(Map map) => Location( longitude: map['longitude'] as double?, latitude: map['latitude'] as double?, @@ -27,10 +33,14 @@ class Location { accuracy: map['accuracy'] as double?, bearing: map['bearing'] as double?, speed: map['speed'] as double?, - time: DateTime.fromMillisecondsSinceEpoch((map['time'] as double).toInt()), + time: DateTime.fromMillisecondsSinceEpoch( + (map['time'] as double).toInt()), isMock: map['isMock'] as bool?, ); + /// Convert the [Location] to a Map. + /// + /// [time] gets converted to a unix timestamp in milliseconds. Map toMap() => { 'latitude': latitude, 'longitude': longitude, @@ -38,7 +48,45 @@ class Location { 'bearing': bearing, 'accuracy': accuracy, 'speed': speed, - 'time': time, + 'time': time.millisecondsSinceEpoch, 'is_mock': isMock, }; -} \ No newline at end of file + + @override + String toString() => 'Location(' + 'latitude: $latitude, ' + 'longitude: $longitude, ' + 'altitude: $altitude, ' + 'bearing: $bearing, ' + 'accuracy: $accuracy, ' + 'speed: $speed, ' + 'time: $time, ' + 'is_mock: $isMock, ' + ')'; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is Location && + runtimeType == other.runtimeType && + latitude == other.latitude && + longitude == other.longitude && + altitude == other.altitude && + bearing == other.bearing && + accuracy == other.accuracy && + speed == other.speed && + time == other.time && + isMock == other.isMock; + + @override + int get hashCode => Object.hash( + latitude, + longitude, + altitude, + bearing, + accuracy, + speed, + time, + isMock, + ); +} From f400a5de7c45e0ba81e664ad1797b6e5f7529fc0 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Thu, 28 Mar 2024 12:30:34 +0100 Subject: [PATCH 19/20] restore .metadata .metadata is from flutter and not eclipse --- .gitignore | 1 - .metadata | 10 ++++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .metadata diff --git a/.gitignore b/.gitignore index c16da92c..79f409eb 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,5 @@ example/ios/Flutter/flutter_export_environment.sh .gradle/ *.iml pubspec.lock -.metadata .project .vscode/ \ No newline at end of file diff --git a/.metadata b/.metadata new file mode 100644 index 00000000..a287b07c --- /dev/null +++ b/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: 20e59316b8b8474554b38493b8ca888794b0234a + channel: stable + +project_type: plugin \ No newline at end of file From 442b2c743d8a1541518de3fc344ddc5f20cc92f4 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Tue, 2 Apr 2024 16:22:52 +0200 Subject: [PATCH 20/20] remove more eclipse project files --- .gitignore | 2 ++ example/android/app/.classpath | 6 ----- example/android/app/.project | 23 ------------------- .../org.eclipse.buildship.core.prefs | 2 -- .../app/.settings/org.eclipse.jdt.core.prefs | 4 ---- 5 files changed, 2 insertions(+), 35 deletions(-) delete mode 100644 example/android/app/.classpath delete mode 100644 example/android/app/.project delete mode 100644 example/android/app/.settings/org.eclipse.buildship.core.prefs delete mode 100644 example/android/app/.settings/org.eclipse.jdt.core.prefs diff --git a/.gitignore b/.gitignore index 79f409eb..8fe934da 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,6 @@ example/ios/Flutter/flutter_export_environment.sh *.iml pubspec.lock .project +.classpath +.settings/ .vscode/ \ No newline at end of file diff --git a/example/android/app/.classpath b/example/android/app/.classpath deleted file mode 100644 index 32d66919..00000000 --- a/example/android/app/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/example/android/app/.project b/example/android/app/.project deleted file mode 100644 index ac485d7c..00000000 --- a/example/android/app/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - app - Project app created by Buildship. - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.buildship.core.gradleprojectbuilder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.buildship.core.gradleprojectnature - - diff --git a/example/android/app/.settings/org.eclipse.buildship.core.prefs b/example/android/app/.settings/org.eclipse.buildship.core.prefs deleted file mode 100644 index b1886adb..00000000 --- a/example/android/app/.settings/org.eclipse.buildship.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -connection.project.dir=.. -eclipse.preferences.version=1 diff --git a/example/android/app/.settings/org.eclipse.jdt.core.prefs b/example/android/app/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index eb950225..00000000 --- a/example/android/app/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=13 -org.eclipse.jdt.core.compiler.compliance=13 -org.eclipse.jdt.core.compiler.source=13