From ac97cfd25730516ba45c77b7763e3fc4beb0d425 Mon Sep 17 00:00:00 2001 From: WilliamVerhaeghe Date: Mon, 11 Sep 2023 09:01:44 +0200 Subject: [PATCH 1/7] Added fromJson/toJson/toString/equals/copyWith methods in BackgroundLocationUpdateData --- CHANGELOG.md | 3 + .../background_location_update_data.dart | 92 +++++++++++++++++++ pubspec.yaml | 2 +- 3 files changed, 96 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80b9d82..ae0c90e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 1.4.2 - 11-09-2023 +- Added fromJson/toJson/toString/equals/copyWith methods in BackgroundLocationUpdateData + ## 1.4.1 - 17-06-2023 - Updates Play Services Location library diff --git a/lib/src/model/background_location_update_data.dart b/lib/src/model/background_location_update_data.dart index aee7d9e..ed22ba4 100644 --- a/lib/src/model/background_location_update_data.dart +++ b/lib/src/model/background_location_update_data.dart @@ -1,3 +1,5 @@ +import 'dart:convert'; + /// BackgroundLocationUpdateData will contain all the data that is send when getting a background location update /// /// latitude & longitude @@ -40,4 +42,94 @@ class BackgroundLocationUpdateData { required this.speed, required this.speedAccuracy, }); + + Map toMap() { + return { + 'lat': lat, + 'lon': lon, + 'horizontalAccuracy': horizontalAccuracy, + 'alt': alt, + 'verticalAccuracy': verticalAccuracy, + 'course': course, + 'courseAccuracy': courseAccuracy, + 'speed': speed, + 'speedAccuracy': speedAccuracy, + }; + } + + factory BackgroundLocationUpdateData.fromMap(Map map) { + return BackgroundLocationUpdateData( + lat: map['lat']?.toDouble() ?? 0.0, + lon: map['lon']?.toDouble() ?? 0.0, + horizontalAccuracy: map['horizontalAccuracy']?.toDouble() ?? 0.0, + alt: map['alt']?.toDouble() ?? 0.0, + verticalAccuracy: map['verticalAccuracy']?.toDouble() ?? 0.0, + course: map['course']?.toDouble() ?? 0.0, + courseAccuracy: map['courseAccuracy']?.toDouble() ?? 0.0, + speed: map['speed']?.toDouble() ?? 0.0, + speedAccuracy: map['speedAccuracy']?.toDouble() ?? 0.0, + ); + } + + String toJson() => json.encode(toMap()); + + factory BackgroundLocationUpdateData.fromJson(String source) => BackgroundLocationUpdateData.fromMap(json.decode(source)); + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + + return other is BackgroundLocationUpdateData && + other.lat == lat && + other.lon == lon && + other.horizontalAccuracy == horizontalAccuracy && + other.alt == alt && + other.verticalAccuracy == verticalAccuracy && + other.course == course && + other.courseAccuracy == courseAccuracy && + other.speed == speed && + other.speedAccuracy == speedAccuracy; + } + + @override + int get hashCode { + return lat.hashCode ^ + lon.hashCode ^ + horizontalAccuracy.hashCode ^ + alt.hashCode ^ + verticalAccuracy.hashCode ^ + course.hashCode ^ + courseAccuracy.hashCode ^ + speed.hashCode ^ + speedAccuracy.hashCode; + } + + @override + String toString() { + return 'BackgroundLocationUpdateData(lat: $lat, lon: $lon, horizontalAccuracy: $horizontalAccuracy, alt: $alt, verticalAccuracy: $verticalAccuracy, course: $course, courseAccuracy: $courseAccuracy, speed: $speed, speedAccuracy: $speedAccuracy)'; + } + + BackgroundLocationUpdateData copyWith({ + double? lat, + double? lon, + double? horizontalAccuracy, + double? alt, + double? verticalAccuracy, + double? course, + double? courseAccuracy, + double? speed, + double? speedAccuracy, + }) { + return BackgroundLocationUpdateData( + lat: lat ?? this.lat, + lon: lon ?? this.lon, + horizontalAccuracy: horizontalAccuracy ?? this.horizontalAccuracy, + alt: alt ?? this.alt, + verticalAccuracy: verticalAccuracy ?? this.verticalAccuracy, + course: course ?? this.course, + courseAccuracy: courseAccuracy ?? this.courseAccuracy, + speed: speed ?? this.speed, + speedAccuracy: speedAccuracy ?? this.speedAccuracy, + ); + } } diff --git a/pubspec.yaml b/pubspec.yaml index acc486d..2f8b809 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: background_location_tracker description: A Flutter plugin that allows you to track the background location for Android & iOS repository: https://github.com/icapps/flutter-background-location-tracker -version: 1.4.1 +version: 1.4.2 environment: sdk: ">=2.12.0 <3.0.0" From acb0e0f7efd5d7dae6e0c54079df7f57839bcdfc Mon Sep 17 00:00:00 2001 From: WilliamVerhaeghe Date: Mon, 11 Sep 2023 09:47:43 +0200 Subject: [PATCH 2/7] Fixed request location issue + formatting --- example/android/build.gradle | 2 +- example/lib/main.dart | 2 +- example/pubspec.lock | 2 +- lib/src/model/background_location_update_data.dart | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/example/android/build.gradle b/example/android/build.gradle index 20dc432..52a2fad 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -26,6 +26,6 @@ subprojects { project.evaluationDependsOn(':app') } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } diff --git a/example/lib/main.dart b/example/lib/main.dart index 21e5e1f..093af97 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -162,7 +162,7 @@ class _MyAppState extends State { } Future _requestLocationPermission() async { - final result = await Permission.locationAlways.request(); + final result = await Permission.location.request(); if (result == PermissionStatus.granted) { print('GRANTED'); // ignore: avoid_print } else { diff --git a/example/pubspec.lock b/example/pubspec.lock index 34d0730..bce2d43 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -23,7 +23,7 @@ packages: path: ".." relative: true source: path - version: "1.4.1" + version: "1.4.2" boolean_selector: dependency: transitive description: diff --git a/lib/src/model/background_location_update_data.dart b/lib/src/model/background_location_update_data.dart index ed22ba4..4f63218 100644 --- a/lib/src/model/background_location_update_data.dart +++ b/lib/src/model/background_location_update_data.dart @@ -73,7 +73,8 @@ class BackgroundLocationUpdateData { String toJson() => json.encode(toMap()); - factory BackgroundLocationUpdateData.fromJson(String source) => BackgroundLocationUpdateData.fromMap(json.decode(source)); + factory BackgroundLocationUpdateData.fromJson(String source) => + BackgroundLocationUpdateData.fromMap(json.decode(source)); @override bool operator ==(Object other) { From 9f8bae0b227f050a9a96ea37245b4d95d23ec614 Mon Sep 17 00:00:00 2001 From: Jordy de Jonghe Date: Thu, 14 Sep 2023 12:00:14 +0200 Subject: [PATCH 3/7] #64: added github actions support --- .github/workflows/analyzer.yml | 18 ++ .github/workflows/test.yml | 25 ++ .travis.yml | 38 --- example/pubspec.lock | 236 +++++++----------- pubspec.lock | 89 +++---- .../test_coverage_filter.dart | 56 +++-- tool/{travis => }/test_coverage_helper.dart | 19 +- tool/test_coverage_validate_percentage.dart | 41 +++ tool/travis/analyze.sh | 3 - tool/travis/test.sh | 30 --- 10 files changed, 247 insertions(+), 308 deletions(-) create mode 100644 .github/workflows/analyzer.yml create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml rename coverage/filter_test_coverage.dart => tool/test_coverage_filter.dart (64%) rename tool/{travis => }/test_coverage_helper.dart (68%) create mode 100644 tool/test_coverage_validate_percentage.dart delete mode 100755 tool/travis/analyze.sh delete mode 100755 tool/travis/test.sh diff --git a/.github/workflows/analyzer.yml b/.github/workflows/analyzer.yml new file mode 100644 index 0000000..f3d2762 --- /dev/null +++ b/.github/workflows/analyzer.yml @@ -0,0 +1,18 @@ +name: Analyzer + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + check_analyzer: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: subosito/flutter-action@v2.8.0 + with: + channel: 'stable' + - run: flutter packages get + - run: flutter analyze \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..c6322ad --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,25 @@ +name: Test + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: subosito/flutter-action@v2.8.0 + with: + channel: 'stable' + - run: flutter packages get + - run: dart run ./tool/test_coverage_create_helper.dart + - run: flutter test --coverage + - run: dart run ./tool/test_coverage_filter.dart + - run: dart run ./tool/test_coverage_validate_percentage.dart + - name: Coveralls + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9cd514a..0000000 --- a/.travis.yml +++ /dev/null @@ -1,38 +0,0 @@ -os: osx -osx_image: xcode12.2 - -before_install: - - chmod +x ./tool/travis/test.sh - - chmod +x ./tool/travis/analyze.sh - -sudo: required - -before_script: - - git clone https://github.com/flutter/flutter.git -b stable ../flutter - - export PATH="$PATH":`pwd`/../flutter/bin - - export PATH="$PATH":`pwd`/../flutter/bin/cache/dart-sdk/bin - - flutter config --no-analytics - - flutter doctor - - export FLUTTER_SDK=`pwd`/../flutter - - gem install coveralls-lcov - - flutter pub global activate dart_style - - flutter packages get || exit -1; - -jobs: - include: - - stage: quality - name: "Tests" - script: ./tool/travis/test.sh - - stage: quality - name: "Analyze" - script: ./tool/travis/analyze.sh - -stages: - - quality - -branches: - only: - - master -cache: - directories: - - $HOME/.pub-cache \ No newline at end of file diff --git a/example/pubspec.lock b/example/pubspec.lock index 34d0730..5430466 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -5,18 +5,16 @@ packages: dependency: transitive description: name: args - sha256: b003c3098049a51720352d219b0bb5f219b60fbfb68e7a4748139a06a5676515 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.3.1" + version: "2.4.1" async: dependency: transitive description: name: async - sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.11.0" + version: "2.9.0" background_location_tracker: dependency: "direct main" description: @@ -28,64 +26,56 @@ packages: dependency: transitive description: name: boolean_selector - sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.0" characters: dependency: transitive description: name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.2.1" clock: dependency: transitive description: name: clock - sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.1.1" collection: dependency: transitive description: name: collection - sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.17.1" + version: "1.16.0" dbus: dependency: transitive description: name: dbus - sha256: "6f07cba3f7b3448d42d015bfd3d53fe12e5b36da2423f23838efc1d5fb31a263" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "0.7.8" fake_async: dependency: transitive description: name: fake_async - sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.3.1" ffi: dependency: transitive description: name: ffi - sha256: a38574032c5f1dd06c4aee541789906c12ccaab8ba01446e800d9c5b79c4a978 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.2" file: dependency: transitive description: name: file - sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "6.1.4" flutter: @@ -97,24 +87,21 @@ packages: dependency: "direct main" description: name: flutter_local_notifications - sha256: "58729fa76729234ff72597b8825876d781d02c94d5d6c6f6958aeb475f5bf00e" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "9.9.0" + version: "9.9.1" flutter_local_notifications_linux: dependency: transitive description: name: flutter_local_notifications_linux - sha256: b472bfc173791b59ede323661eae20f7fff0b6908fea33dd720a6ef5d576bae8 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "0.5.1" flutter_local_notifications_platform_interface: dependency: transitive description: name: flutter_local_notifications_platform_interface - sha256: "21bceee103a66a53b30ea9daf677f990e5b9e89b62f222e60dd241cd08d63d3a" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "5.0.0" flutter_test: @@ -131,202 +118,170 @@ packages: dependency: transitive description: name: js - sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "0.6.7" + version: "0.6.4" matcher: dependency: transitive description: name: matcher - sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "0.12.15" + version: "0.12.12" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "0.2.0" + version: "0.1.5" meta: dependency: transitive description: name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.9.1" + version: "1.8.0" path: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.8.3" + version: "1.8.2" path_provider_linux: dependency: transitive description: name: path_provider_linux - sha256: ab0987bf95bc591da42dffb38c77398fc43309f0b9b894dcc5d6f40c4b26c379 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.7" + version: "2.2.0" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface - sha256: "27dc7a224fcd07444cb5e0e60423ccacea3e13cf00fc5282ac2c918132da931d" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.0.4" + version: "2.1.0" path_provider_windows: dependency: transitive description: name: path_provider_windows - sha256: bcabbe399d4042b8ee687e17548d5d3f527255253b4a639f5f8d2094a9c2b45c - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.3" + version: "2.2.0" permission_handler: dependency: "direct main" description: name: permission_handler - sha256: ae51809c535fd765061c7384a67bc24d304d24cfc455c59e2f6a5cec9a37fc9c - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "10.0.0" + version: "10.4.5" permission_handler_android: dependency: transitive description: name: permission_handler_android - sha256: "692e5dd690cd9e978e1cefa67d97bddd3a7f4748ddac6cd8bbd1a354a6a1869f" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "10.0.0" + version: "10.3.6" permission_handler_apple: dependency: transitive description: name: permission_handler_apple - sha256: "6367799be76d1fe70ffe2df7f025abfe28818b450f550621778995badbebf519" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "9.0.4" + version: "9.1.4" permission_handler_platform_interface: dependency: transitive description: name: permission_handler_platform_interface - sha256: ca16451bfdc6d26693d10b37b2d81370bdf3f0318422f3eecfd6004f5bd7d21f - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "3.7.0" + version: "3.11.5" permission_handler_windows: dependency: transitive description: name: permission_handler_windows - sha256: "40ad5ab4d3c65d75c7f3a069065c77503aae19a1cf01ba246d43489e14f1b90c" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "0.1.0" + version: "0.1.3" petitparser: dependency: transitive description: name: petitparser - sha256: "2ebb289dc4764ec397f5cd3ca9881c6d17196130a7d646ed022a0dd9c2e25a71" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "5.0.0" + version: "5.1.0" platform: dependency: transitive description: name: platform - sha256: "4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "3.1.0" + version: "3.1.1" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - sha256: "075f927ebbab4262ace8d0b283929ac5410c0ac4e7fc123c76429564facfb757" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "2.1.5" process: dependency: transitive description: name: process - sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "4.2.4" shared_preferences: dependency: "direct main" description: name: shared_preferences - sha256: "76917b7d4b9526b2ba416808a7eb9fb2863c1a09cf63ec85f1453da240fa818a" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.0.15" + version: "2.2.0" shared_preferences_android: dependency: transitive description: name: shared_preferences_android - sha256: "853801ce6ba7429ec4e923e37317f32a57c903de50b8c33ffcfbdb7e6f0dd39c" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.0.12" - shared_preferences_ios: + version: "2.2.0" + shared_preferences_foundation: dependency: transitive description: - name: shared_preferences_ios - sha256: "585a14cefec7da8c9c2fb8cd283a3bb726b4155c0952afe6a0caaa7b2272de34" - url: "https://pub.dev" + name: shared_preferences_foundation + url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.3.3" shared_preferences_linux: dependency: transitive description: name: shared_preferences_linux - sha256: "28aefc1261746e7bad3d09799496054beb84e8c4ffcdfed7734e17b4ada459a5" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" - shared_preferences_macos: - dependency: transitive - description: - name: shared_preferences_macos - sha256: fbb94bf296576f49be37a1496d5951796211a8db0aa22cc0d68c46440dad808c - url: "https://pub.dev" - source: hosted - version: "2.0.4" + version: "2.3.0" shared_preferences_platform_interface: dependency: transitive description: name: shared_preferences_platform_interface - sha256: da9431745ede5ece47bc26d5d73a9d3c6936ef6945c101a5aca46f62e52c1cf3 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.3.0" shared_preferences_web: dependency: transitive description: name: shared_preferences_web - sha256: a4b5bc37fe1b368bbc81f953197d55e12f49d0296e7e412dfe2d2d77d6929958 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.0.4" + version: "2.2.0" shared_preferences_windows: dependency: transitive description: name: shared_preferences_windows - sha256: "97f7ab9a7da96d9cf19581f5de520ceb529548498bd6b5e0ccd02d68a0d15eba" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.3.0" sky_engine: dependency: transitive description: flutter @@ -336,90 +291,79 @@ packages: dependency: transitive description: name: source_span - sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.9.1" + version: "1.9.0" stack_trace: dependency: transitive description: name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.11.0" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner - sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.1.1" term_glyph: dependency: transitive description: name: term_glyph - sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.2.1" test_api: dependency: transitive description: name: test_api - sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "0.5.1" + version: "0.4.12" timezone: dependency: transitive description: name: timezone - sha256: "57b35f6e8ef731f18529695bffc62f92c6189fac2e52c12d478dec1931afb66e" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "0.8.0" vector_math: dependency: transitive description: name: vector_math - sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.4" + version: "2.1.2" win32: dependency: transitive description: name: win32 - sha256: "1952a663c0e34fbde55916010d54bbb249bf5f2583113c497602f0ee01c6faa4" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "4.1.4" xdg_directories: dependency: transitive description: name: xdg_directories - sha256: "11541eedefbcaec9de35aa82650b695297ce668662bbd6e3911a7fabdbde589f" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "0.2.0+2" + version: "0.2.0+3" xml: dependency: transitive description: name: xml - sha256: ac0e3f4bf00ba2708c33fbabbbe766300e509f8c82dbd4ab6525039813f7e2fb - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "6.1.0" sdks: - dart: ">=3.0.0-0 <4.0.0" - flutter: ">=3.0.0" + dart: ">=2.18.0 <3.0.0" + flutter: ">=3.3.0" diff --git a/pubspec.lock b/pubspec.lock index 5762bdc..9cf620f 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,48 +5,42 @@ packages: dependency: transitive description: name: async - sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.11.0" + version: "2.9.0" boolean_selector: dependency: transitive description: name: boolean_selector - sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.0" characters: dependency: transitive description: name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.2.1" clock: dependency: transitive description: name: clock - sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.1.1" collection: dependency: transitive description: name: collection - sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.17.1" + version: "1.16.0" fake_async: dependency: transitive description: name: fake_async - sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.3.1" flutter: @@ -59,46 +53,34 @@ packages: description: flutter source: sdk version: "0.0.0" - js: - dependency: transitive - description: - name: js - sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 - url: "https://pub.dev" - source: hosted - version: "0.6.7" matcher: dependency: transitive description: name: matcher - sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "0.12.15" + version: "0.12.12" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "0.2.0" + version: "0.1.5" meta: dependency: transitive description: name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.9.1" + version: "1.8.0" path: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.8.3" + version: "1.8.2" sky_engine: dependency: transitive description: flutter @@ -108,58 +90,51 @@ packages: dependency: transitive description: name: source_span - sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.9.1" + version: "1.9.0" stack_trace: dependency: transitive description: name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.11.0" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner - sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.1.1" term_glyph: dependency: transitive description: name: term_glyph - sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.2.1" test_api: dependency: transitive description: name: test_api - sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "0.5.1" + version: "0.4.12" vector_math: dependency: transitive description: name: vector_math - sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.4" + version: "2.1.2" sdks: - dart: ">=3.0.0-0 <4.0.0" + dart: ">=2.17.0-0 <3.0.0" flutter: ">=2.0.0" diff --git a/coverage/filter_test_coverage.dart b/tool/test_coverage_filter.dart similarity index 64% rename from coverage/filter_test_coverage.dart rename to tool/test_coverage_filter.dart index 1a8e17e..a3ff86a 100644 --- a/coverage/filter_test_coverage.dart +++ b/tool/test_coverage_filter.dart @@ -1,37 +1,37 @@ import 'dart:io'; -void main() { +void main(List args) { printMessage('Start filtering the lcov.info file'); final file = File('coverage/lcov.info'); if (!file.existsSync()) { - printMessage('"lcov.info" does not exist'); + printMessage('${file.path}" does not exist'); return; } const endOfRecord = 'end_of_record'; final sections = []; final lines = file.readAsLinesSync(); LcovSection? currentSection; - lines.forEach((line) { + for (final line in lines) { if (line.endsWith('.dart')) { final filePath = line.replaceAll('SF:', ''); currentSection = LcovSection() ..header = line ..filePath = filePath; } else if (line == endOfRecord) { - final session = currentSection; - if (session != null) { - session.footer = line; - sections.add(session); + final currentSectionTmp = currentSection; + if (currentSectionTmp != null) { + currentSectionTmp.footer = line; + sections.add(currentSectionTmp); } } else { currentSection?.body.add(line); } - }); + } final filteredSections = getFilteredSections(sections); final sb = StringBuffer(); - filteredSections.forEach((section) { + for (final section in filteredSections) { sb.write(section.toString()); - }); + } file.writeAsStringSync(sb.toString()); printMessage('Filtered the lcov.info file'); } @@ -42,12 +42,10 @@ class LcovSection { final body = []; String? footer; - String getBodyString() { - final path = filePath; - if (path == null) { - throw ArgumentError('file path can not be null'); - } - final file = File(path); + String? getBodyString() { + final filePathTmp = filePath; + if (filePathTmp == null) return null; + final file = File(filePathTmp); final content = file.readAsLinesSync(); final sb = StringBuffer(); getFilteredBody(body, content).forEach((item) => sb @@ -64,13 +62,23 @@ class LcovSection { List getFilteredSections(List sections) { return sections.where((section) { - if (section.header?.endsWith('.g.dart') == true) { + final header = section.header; + if (header == null) return false; + if (!header.endsWith('.dart')) { + return false; + } else if (header.endsWith('.g.dart')) { + return false; + } else if (header.endsWith('.config.dart')) { + return false; + } else if (header.endsWith('injectable.dart')) { + return false; + } else if (header.startsWith('SF:lib/util/locale')) { return false; - } else if (section.header?.endsWith('dummy_service.dart') == true) { + } else if (header.startsWith('SF:lib/widget')) { return false; - } else if (section.header?.startsWith('SF:lib/vendor/') == true) { + } else if (header.startsWith('SF:lib/screen')) { return false; - } else if (section.header?.startsWith('SF:lib/util/locale') == true) { + } else if (header.startsWith('SF:lib/navigator')) { return false; } return true; @@ -99,7 +107,13 @@ List getFilteredBody(List body, List lines) { }).toList(); } -const excludedLines = []; +const excludedLines = [ + 'const TranslationWriter._();', + 'const CaseUtil._();', + 'const LocaleGenParser._();', + 'const LocaleGenSbWriter._();', + 'const LocaleGenWriter._();', +]; const excludedStartsWithLines = []; diff --git a/tool/travis/test_coverage_helper.dart b/tool/test_coverage_helper.dart similarity index 68% rename from tool/travis/test_coverage_helper.dart rename to tool/test_coverage_helper.dart index 5e310f7..6f370d3 100755 --- a/tool/travis/test_coverage_helper.dart +++ b/tool/test_coverage_helper.dart @@ -3,33 +3,26 @@ import 'dart:io'; const packageName = 'background_location_tracker'; void main() { - Logger.debug('===='); Logger.debug( 'First create a file with all other files imported so flutter test coverage uses all files'); - Logger.debug('===='); - final testDir = Directory('test'); - if (!testDir.existsSync()) { - testDir.createSync(recursive: true); - } - final imports = Directory('lib').listSync(recursive: true).where((element) { if (Directory(element.path).existsSync()) return false; + if (!element.path.endsWith('.dart')) return false; if (element.path.endsWith('.g.dart')) return false; + if (element.path.endsWith('_web.dart')) return false; return true; }).map((element) { final importPath = element.path.replaceFirst('lib', packageName); - return 'import "package:$importPath";'; + return "import 'package:$importPath';"; }); final testFile = File('test/coverage_helper_test.dart'); if (!testFile.existsSync()) { testFile.createSync(); } - final content = '${imports.join('\n')}\nvoid main(){}'; + final sortedImports = imports.toList()..sort((e1, e2) => e1.compareTo(e2)); + final content = '${sortedImports.join('\n')}\nvoid main(){}'; testFile.writeAsStringSync(content); - - Logger.debug('===='); - Logger.debug('Finished'); - Logger.debug('===='); + Logger.debug('Created the test/coverage_helper_test.dart'); } class Logger { diff --git a/tool/test_coverage_validate_percentage.dart b/tool/test_coverage_validate_percentage.dart new file mode 100644 index 0000000..f22d605 --- /dev/null +++ b/tool/test_coverage_validate_percentage.dart @@ -0,0 +1,41 @@ +import 'dart:io'; + +const minRequiredCoverage = 0; + +void main(List args) { + printMessage('Start checking the lcov.info file'); + final file = File('coverage/lcov.info'); + if (!file.existsSync()) { + printMessage('${file.path}" does not exist'); + return; + } + var totalLines = 0; + var totalLinesCovered = 0; + final lines = file.readAsLinesSync(); + for (final line in lines) { + if (line.startsWith('DA')) { + totalLines++; + } else if (line.startsWith('LH')) { + totalLinesCovered += int.parse(line.replaceAll('LH:', '')); + } + } + final codeCoveragePercentage = (totalLinesCovered / totalLines) * 100; + if (codeCoveragePercentage == 100) { + printMessage('\n100% CODE COVERAGE!!!!\n'); + } else if (codeCoveragePercentage >= minRequiredCoverage) { + printMessage('COVERAGE IS ${codeCoveragePercentage.toStringAsFixed(2)}%\n'); + printMessage( + 'TIS IS ABOVE THE MIN REQUIRED TARGET of $minRequiredCoverage%\n'); + } else { + printMessage('\nCODE COVERAGE IS TO LOW!!\n'); + printMessage('COVERAGE IS ${codeCoveragePercentage.toStringAsFixed(2)}%\n'); + printMessage('AMOUNT OF LINES:$totalLines'); + printMessage('AMOUNT OF COVERED:$totalLinesCovered\n'); + exit(-1); + } +} + +void printMessage(String message) { + // ignore: avoid_print + print(message); +} diff --git a/tool/travis/analyze.sh b/tool/travis/analyze.sh deleted file mode 100755 index d0bc68f..0000000 --- a/tool/travis/analyze.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -flutter analyze || exit -1; \ No newline at end of file diff --git a/tool/travis/test.sh b/tool/travis/test.sh deleted file mode 100755 index 035658d..0000000 --- a/tool/travis/test.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -dart run ./tool/travis/test_coverage_helper.dart || exit -1; - -echo "" -echo "====" -echo "Start testing" -echo "====" -flutter test --coverage || exit -1; -echo "====" -echo "Finished testing" -echo "====" - -echo "" -echo "====" -echo "Start filtering tests" -echo "====" -dart run ./coverage/filter_test_coverage.dart || exit -1; -echo "====" -echo "Finished filtering tests" -echo "====" - -echo "" -echo "====" -echo "Start coveralls upload" -echo "====" -coveralls-lcov coverage/lcov.info -echo "====" -echo "Finished coveralls upload" -echo "====" \ No newline at end of file From 7f0a26183bd5e8208b92266a2cf95b90cf25f5f9 Mon Sep 17 00:00:00 2001 From: Jordy de Jonghe Date: Thu, 14 Sep 2023 12:03:57 +0200 Subject: [PATCH 4/7] #64: fixed naming --- ...test_coverage_helper.dart => test_coverage_create_helper.dart} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tool/{test_coverage_helper.dart => test_coverage_create_helper.dart} (100%) diff --git a/tool/test_coverage_helper.dart b/tool/test_coverage_create_helper.dart similarity index 100% rename from tool/test_coverage_helper.dart rename to tool/test_coverage_create_helper.dart From dc9ee42272d6cdb0c5ef604ba4a28036d39cdc95 Mon Sep 17 00:00:00 2001 From: Jordy de Jonghe Date: Thu, 14 Sep 2023 12:06:18 +0200 Subject: [PATCH 5/7] #64: fixed analyzer --- analysis_options.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 41a5409..ab8e538 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -58,11 +58,10 @@ linter: - hash_and_equals - implementation_imports - invariant_booleans - - iterable_contains_unrelated_type + - collection_methods_unrelated_type - join_return_with_assignment - library_names - library_prefixes - - list_remove_unrelated_type - literal_only_boolean_expressions - no_adjacent_strings_in_list - no_duplicate_case_values From 70dc8e470b9d8afad2aa578bf0da889231b5e5d5 Mon Sep 17 00:00:00 2001 From: WilliamVerhaeghe Date: Thu, 21 Sep 2023 13:30:59 +0200 Subject: [PATCH 6/7] Added tests for BackgroundLocationUpdateData --- example/pubspec.lock | 176 +++++++++++------- pubspec.lock | 89 +++++---- .../background_location_update_data_test.dart | 41 +++- 3 files changed, 200 insertions(+), 106 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index a756083..7d34e9c 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -5,16 +5,18 @@ packages: dependency: transitive description: name: args - url: "https://pub.dartlang.org" + sha256: c372bb384f273f0c2a8aaaa226dad84dc27c8519a691b888725dec59518ad53a + url: "https://pub.dev" source: hosted version: "2.4.1" async: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.9.0" + version: "2.11.0" background_location_tracker: dependency: "direct main" description: @@ -26,56 +28,64 @@ packages: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.3.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted version: "1.1.1" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" + url: "https://pub.dev" source: hosted - version: "1.16.0" + version: "1.17.1" dbus: dependency: transitive description: name: dbus - url: "https://pub.dartlang.org" + sha256: "6f07cba3f7b3448d42d015bfd3d53fe12e5b36da2423f23838efc1d5fb31a263" + url: "https://pub.dev" source: hosted version: "0.7.8" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted version: "1.3.1" ffi: dependency: transitive description: name: ffi - url: "https://pub.dartlang.org" + sha256: ed5337a5660c506388a9f012be0288fb38b49020ce2b45fe1f8b8323fe429f99 + url: "https://pub.dev" source: hosted version: "2.0.2" file: dependency: transitive description: name: file - url: "https://pub.dartlang.org" + sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" + url: "https://pub.dev" source: hosted version: "6.1.4" flutter: @@ -87,21 +97,24 @@ packages: dependency: "direct main" description: name: flutter_local_notifications - url: "https://pub.dartlang.org" + sha256: "57d0012730780fe137260dd180e072c18a73fbeeb924cdc029c18aaa0f338d64" + url: "https://pub.dev" source: hosted version: "9.9.1" flutter_local_notifications_linux: dependency: transitive description: name: flutter_local_notifications_linux - url: "https://pub.dartlang.org" + sha256: b472bfc173791b59ede323661eae20f7fff0b6908fea33dd720a6ef5d576bae8 + url: "https://pub.dev" source: hosted version: "0.5.1" flutter_local_notifications_platform_interface: dependency: transitive description: name: flutter_local_notifications_platform_interface - url: "https://pub.dartlang.org" + sha256: "21bceee103a66a53b30ea9daf677f990e5b9e89b62f222e60dd241cd08d63d3a" + url: "https://pub.dev" source: hosted version: "5.0.0" flutter_test: @@ -118,168 +131,192 @@ packages: dependency: transitive description: name: js - url: "https://pub.dartlang.org" + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" source: hosted - version: "0.6.4" + version: "0.6.7" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" + url: "https://pub.dev" source: hosted - version: "0.12.12" + version: "0.12.15" material_color_utilities: dependency: transitive description: name: material_color_utilities - url: "https://pub.dartlang.org" + sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + url: "https://pub.dev" source: hosted - version: "0.1.5" + version: "0.2.0" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.9.1" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" source: hosted - version: "1.8.2" + version: "1.8.3" path_provider_linux: dependency: transitive description: name: path_provider_linux - url: "https://pub.dartlang.org" + sha256: ba2b77f0c52a33db09fc8caf85b12df691bf28d983e84cf87ff6d693cfa007b3 + url: "https://pub.dev" source: hosted version: "2.2.0" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface - url: "https://pub.dartlang.org" + sha256: bced5679c7df11190e1ddc35f3222c858f328fff85c3942e46e7f5589bf9eb84 + url: "https://pub.dev" source: hosted version: "2.1.0" path_provider_windows: dependency: transitive description: name: path_provider_windows - url: "https://pub.dartlang.org" + sha256: ee0e0d164516b90ae1f970bdf29f726f1aa730d7cfc449ecc74c495378b705da + url: "https://pub.dev" source: hosted version: "2.2.0" permission_handler: dependency: "direct main" description: name: permission_handler - url: "https://pub.dartlang.org" + sha256: bc56bfe9d3f44c3c612d8d393bd9b174eb796d706759f9b495ac254e4294baa5 + url: "https://pub.dev" source: hosted version: "10.4.5" permission_handler_android: dependency: transitive description: name: permission_handler_android - url: "https://pub.dartlang.org" + sha256: "59c6322171c29df93a22d150ad95f3aa19ed86542eaec409ab2691b8f35f9a47" + url: "https://pub.dev" source: hosted version: "10.3.6" permission_handler_apple: dependency: transitive description: name: permission_handler_apple - url: "https://pub.dartlang.org" + sha256: "99e220bce3f8877c78e4ace901082fb29fa1b4ebde529ad0932d8d664b34f3f5" + url: "https://pub.dev" source: hosted version: "9.1.4" permission_handler_platform_interface: dependency: transitive description: name: permission_handler_platform_interface - url: "https://pub.dartlang.org" + sha256: f2343e9fa9c22ae4fd92d4732755bfe452214e7189afcc097380950cf567b4b2 + url: "https://pub.dev" source: hosted version: "3.11.5" permission_handler_windows: dependency: transitive description: name: permission_handler_windows - url: "https://pub.dartlang.org" + sha256: cc074aace208760f1eee6aa4fae766b45d947df85bc831cde77009cdb4720098 + url: "https://pub.dev" source: hosted version: "0.1.3" petitparser: dependency: transitive description: name: petitparser - url: "https://pub.dartlang.org" + sha256: "49392a45ced973e8d94a85fdb21293fbb40ba805fc49f2965101ae748a3683b4" + url: "https://pub.dev" source: hosted version: "5.1.0" platform: dependency: transitive description: name: platform - url: "https://pub.dartlang.org" + sha256: "57c07bf82207aee366dfaa3867b3164e4f03a238a461a11b0e8a3a510d51203d" + url: "https://pub.dev" source: hosted version: "3.1.1" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - url: "https://pub.dartlang.org" + sha256: "43798d895c929056255600343db8f049921cbec94d31ec87f1dc5c16c01935dd" + url: "https://pub.dev" source: hosted version: "2.1.5" process: dependency: transitive description: name: process - url: "https://pub.dartlang.org" + sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09" + url: "https://pub.dev" source: hosted version: "4.2.4" shared_preferences: dependency: "direct main" description: name: shared_preferences - url: "https://pub.dartlang.org" + sha256: "0344316c947ffeb3a529eac929e1978fcd37c26be4e8468628bac399365a3ca1" + url: "https://pub.dev" source: hosted version: "2.2.0" shared_preferences_android: dependency: transitive description: name: shared_preferences_android - url: "https://pub.dartlang.org" + sha256: fe8401ec5b6dcd739a0fe9588802069e608c3fdbfd3c3c93e546cf2f90438076 + url: "https://pub.dev" source: hosted version: "2.2.0" shared_preferences_foundation: dependency: transitive description: name: shared_preferences_foundation - url: "https://pub.dartlang.org" + sha256: d29753996d8eb8f7619a1f13df6ce65e34bc107bef6330739ed76f18b22310ef + url: "https://pub.dev" source: hosted version: "2.3.3" shared_preferences_linux: dependency: transitive description: name: shared_preferences_linux - url: "https://pub.dartlang.org" + sha256: "71d6806d1449b0a9d4e85e0c7a917771e672a3d5dc61149cc9fac871115018e1" + url: "https://pub.dev" source: hosted version: "2.3.0" shared_preferences_platform_interface: dependency: transitive description: name: shared_preferences_platform_interface - url: "https://pub.dartlang.org" + sha256: "23b052f17a25b90ff2b61aad4cc962154da76fb62848a9ce088efe30d7c50ab1" + url: "https://pub.dev" source: hosted version: "2.3.0" shared_preferences_web: dependency: transitive description: name: shared_preferences_web - url: "https://pub.dartlang.org" + sha256: "7347b194fb0bbeb4058e6a4e87ee70350b6b2b90f8ac5f8bd5b3a01548f6d33a" + url: "https://pub.dev" source: hosted version: "2.2.0" shared_preferences_windows: dependency: transitive description: name: shared_preferences_windows - url: "https://pub.dartlang.org" + sha256: f95e6a43162bce43c9c3405f3eb6f39e5b5d11f65fab19196cf8225e2777624d + url: "https://pub.dev" source: hosted version: "2.3.0" sky_engine: @@ -291,79 +328,90 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + url: "https://pub.dev" source: hosted - version: "1.9.0" + version: "1.9.1" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb + url: "https://pub.dev" source: hosted - version: "0.4.12" + version: "0.5.1" timezone: dependency: transitive description: name: timezone - url: "https://pub.dartlang.org" + sha256: "57b35f6e8ef731f18529695bffc62f92c6189fac2e52c12d478dec1931afb66e" + url: "https://pub.dev" source: hosted version: "0.8.0" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.4" win32: dependency: transitive description: name: win32 - url: "https://pub.dartlang.org" + sha256: "5a751eddf9db89b3e5f9d50c20ab8612296e4e8db69009788d6c8b060a84191c" + url: "https://pub.dev" source: hosted version: "4.1.4" xdg_directories: dependency: transitive description: name: xdg_directories - url: "https://pub.dartlang.org" + sha256: bd512f03919aac5f1313eb8249f223bacf4927031bf60b02601f81f687689e86 + url: "https://pub.dev" source: hosted version: "0.2.0+3" xml: dependency: transitive description: name: xml - url: "https://pub.dartlang.org" + sha256: ac0e3f4bf00ba2708c33fbabbbe766300e509f8c82dbd4ab6525039813f7e2fb + url: "https://pub.dev" source: hosted version: "6.1.0" sdks: - dart: ">=2.18.0 <3.0.0" + dart: ">=3.0.0-0 <4.0.0" flutter: ">=3.3.0" diff --git a/pubspec.lock b/pubspec.lock index 9cf620f..5762bdc 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,42 +5,48 @@ packages: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.9.0" + version: "2.11.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.3.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted version: "1.1.1" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" + url: "https://pub.dev" source: hosted - version: "1.16.0" + version: "1.17.1" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted version: "1.3.1" flutter: @@ -53,34 +59,46 @@ packages: description: flutter source: sdk version: "0.0.0" + js: + dependency: transitive + description: + name: js + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" + source: hosted + version: "0.6.7" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" + url: "https://pub.dev" source: hosted - version: "0.12.12" + version: "0.12.15" material_color_utilities: dependency: transitive description: name: material_color_utilities - url: "https://pub.dartlang.org" + sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + url: "https://pub.dev" source: hosted - version: "0.1.5" + version: "0.2.0" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.9.1" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" source: hosted - version: "1.8.2" + version: "1.8.3" sky_engine: dependency: transitive description: flutter @@ -90,51 +108,58 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + url: "https://pub.dev" source: hosted - version: "1.9.0" + version: "1.9.1" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb + url: "https://pub.dev" source: hosted - version: "0.4.12" + version: "0.5.1" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.4" sdks: - dart: ">=2.17.0-0 <3.0.0" + dart: ">=3.0.0-0 <4.0.0" flutter: ">=2.0.0" diff --git a/test/src/model/background_location_update_data_test.dart b/test/src/model/background_location_update_data_test.dart index 18612e6..1121ea5 100644 --- a/test/src/model/background_location_update_data_test.dart +++ b/test/src/model/background_location_update_data_test.dart @@ -25,7 +25,7 @@ void main() { expect(data.speedAccuracy, 0.9); }); - test('Background location update data', () async { + test('Background location update data methods', () async { const data = BackgroundLocationUpdateData( lat: 51.45, lon: 4.5, @@ -37,14 +37,35 @@ void main() { speed: 12.2, speedAccuracy: 0.9, ); - expect(data.lat, 51.45); - expect(data.lon, 4.5); - expect(data.horizontalAccuracy, 1.2); - expect(data.alt, 42.3); - expect(data.verticalAccuracy, 0.3); - expect(data.course, 128.3); - expect(data.courseAccuracy, 14.3); - expect(data.speed, 12.2); - expect(data.speedAccuracy, 0.9); + final json = data.toJson(); + final data2 = BackgroundLocationUpdateData.fromJson(json); + expect(data2.lat, 51.45); + expect(data2.lon, 4.5); + expect(data2.horizontalAccuracy, 1.2); + expect(data2.alt, 42.3); + expect(data2.verticalAccuracy, 0.3); + expect(data2.course, 128.3); + expect(data2.courseAccuracy, 14.3); + expect(data2.speed, 12.2); + expect(data2.speedAccuracy, 0.9); + expect(data == data2, true); + + final data3 = data.copyWith(lat: 51.46); + expect(data3.lat, 51.46); + expect(data2.lon, 4.5); + expect(data2.horizontalAccuracy, 1.2); + expect(data2.alt, 42.3); + expect(data2.verticalAccuracy, 0.3); + expect(data2.course, 128.3); + expect(data2.courseAccuracy, 14.3); + expect(data2.speed, 12.2); + expect(data2.speedAccuracy, 0.9); + expect(data == data3, false); + + expect(data.toString(), + 'BackgroundLocationUpdateData(lat: 51.45, lon: 4.5, horizontalAccuracy: 1.2, alt: 42.3, verticalAccuracy: 0.3, course: 128.3, courseAccuracy: 14.3, speed: 12.2, speedAccuracy: 0.9)'); + + expect(data.hashCode == data2.hashCode, true); + expect(data.hashCode == data3.hashCode, false); }); } From d9dde27c546da2f51831c3d73d6f1b8cb5e1b46f Mon Sep 17 00:00:00 2001 From: WilliamVerhaeghe Date: Thu, 21 Sep 2023 14:09:36 +0200 Subject: [PATCH 7/7] No nullable in fromMap --- .../background_location_update_data.dart | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/src/model/background_location_update_data.dart b/lib/src/model/background_location_update_data.dart index 4f63218..01e9398 100644 --- a/lib/src/model/background_location_update_data.dart +++ b/lib/src/model/background_location_update_data.dart @@ -59,22 +59,21 @@ class BackgroundLocationUpdateData { factory BackgroundLocationUpdateData.fromMap(Map map) { return BackgroundLocationUpdateData( - lat: map['lat']?.toDouble() ?? 0.0, - lon: map['lon']?.toDouble() ?? 0.0, - horizontalAccuracy: map['horizontalAccuracy']?.toDouble() ?? 0.0, - alt: map['alt']?.toDouble() ?? 0.0, - verticalAccuracy: map['verticalAccuracy']?.toDouble() ?? 0.0, - course: map['course']?.toDouble() ?? 0.0, - courseAccuracy: map['courseAccuracy']?.toDouble() ?? 0.0, - speed: map['speed']?.toDouble() ?? 0.0, - speedAccuracy: map['speedAccuracy']?.toDouble() ?? 0.0, + lat: map['lat'].toDouble(), + lon: map['lon'].toDouble(), + horizontalAccuracy: map['horizontalAccuracy'].toDouble(), + alt: map['alt'].toDouble(), + verticalAccuracy: map['verticalAccuracy'].toDouble(), + course: map['course'].toDouble(), + courseAccuracy: map['courseAccuracy'].toDouble(), + speed: map['speed'].toDouble(), + speedAccuracy: map['speedAccuracy'].toDouble(), ); } String toJson() => json.encode(toMap()); - factory BackgroundLocationUpdateData.fromJson(String source) => - BackgroundLocationUpdateData.fromMap(json.decode(source)); + factory BackgroundLocationUpdateData.fromJson(String source) => BackgroundLocationUpdateData.fromMap(json.decode(source)); @override bool operator ==(Object other) {