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
-
-
- 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