From 6f65a0eb17e453babe9597d84b7f804bea403579 Mon Sep 17 00:00:00 2001 From: John Ryan Date: Fri, 19 Mar 2021 16:03:14 -0700 Subject: [PATCH 01/16] Add actions/stale@v3 GitHub Action patched version --- .github/workflows/stale.yml | 19 +++++++++++++++++++ flutter_map.iml | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/stale.yml diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 000000000..ee1a64359 --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,19 @@ +name: 'Close stale issues and PR' +on: + schedule: + - cron: '30 1 * * *' + +jobs: + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v3 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.' + stale-pr-message: 'This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.' + close-issue-message: 'This issue was closed because it has been stalled for 5 days with no activity.' + days-before-stale: 30 + days-before-close: 5 + days-before-pr-close: -1 + diff --git a/flutter_map.iml b/flutter_map.iml index 6048a33bd..e9a86d25d 100644 --- a/flutter_map.iml +++ b/flutter_map.iml @@ -16,4 +16,4 @@ - \ No newline at end of file + From 508ab2ffd4510cad9c7ed9cadaf0b00590c98806 Mon Sep 17 00:00:00 2001 From: escamoteur Date: Wed, 6 Jan 2021 12:45:57 +0100 Subject: [PATCH 02/16] updated to latest master version --- .packages | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 .packages diff --git a/.packages b/.packages new file mode 100644 index 000000000..b85cfee4d --- /dev/null +++ b/.packages @@ -0,0 +1,95 @@ +# Generated by pub on 2021-01-06 12:44:54.032544. +_fe_analyzer_shared:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/_fe_analyzer_shared-12.0.0/lib/ +analyzer:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/analyzer-0.40.5/lib/ +ansicolor:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/ansicolor-1.0.5/lib/ +args:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/args-1.6.0/lib/ +async:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/async-2.5.0-nullsafety.3/lib/ +boolean_selector:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/boolean_selector-2.1.0-nullsafety.3/lib/ +cached_network_image:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/cached_network_image-2.3.3/lib/ +characters:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/characters-1.1.0-nullsafety.5/lib/ +charcode:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/charcode-1.2.0-nullsafety.3/lib/ +cli_util:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/cli_util-0.2.0/lib/ +clock:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/clock-1.1.0-nullsafety.3/lib/ +collection:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/collection-1.15.0-nullsafety.5/lib/ +console_log_handler:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/console_log_handler-1.1.6/lib/ +convert:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/convert-2.1.1/lib/ +coverage:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/coverage-0.14.1/lib/ +crypto:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/crypto-2.1.5/lib/ +fake_async:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/fake_async-1.2.0-nullsafety.3/lib/ +ffi:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/ffi-0.1.3/lib/ +file:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/file-5.2.1/lib/ +flutter:file:///C:/Entwicklung/flutter/packages/flutter/lib/ +flutter_blurhash:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/flutter_blurhash-0.5.0/lib/ +flutter_cache_manager:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/flutter_cache_manager-2.0.0/lib/ +flutter_image:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/flutter_image-3.0.0/lib/ +flutter_test:file:///C:/Entwicklung/flutter/packages/flutter_test/lib/ +glob:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/glob-1.2.0/lib/ +http:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/http-0.12.2/lib/ +http_multi_server:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/http_multi_server-2.2.0/lib/ +http_parser:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/http_parser-3.1.4/lib/ +intl:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/intl-0.16.1/lib/ +io:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/io-0.3.4/lib/ +js:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/js-0.6.3-nullsafety.2/lib/ +latlong:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/latlong-0.6.1/lib/ +lists:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/lists-0.1.6/lib/ +location:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/location-2.5.4/lib/ +logging:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/logging-0.11.4/lib/ +matcher:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/matcher-0.12.10-nullsafety.3/lib/ +meta:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/meta-1.3.0-nullsafety.6/lib/ +mgrs_dart:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/mgrs_dart-1.0.1/lib/ +mime:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/mime-0.9.7/lib/ +node_interop:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/node_interop-1.1.1/lib/ +node_io:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/node_io-1.1.1/lib/ +node_preamble:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/node_preamble-1.4.12/lib/ +octo_image:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/octo_image-0.3.0/lib/ +package_config:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/package_config-1.9.3/lib/ +path:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/path-1.8.0-nullsafety.3/lib/ +path_provider:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/path_provider-1.6.22/lib/ +path_provider_linux:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/path_provider_linux-0.0.1+2/lib/ +path_provider_macos:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/path_provider_macos-0.0.4+4/lib/ +path_provider_platform_interface:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/path_provider_platform_interface-1.0.3/lib/ +path_provider_windows:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/path_provider_windows-0.0.4+1/lib/ +pedantic:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/pedantic-1.10.0-nullsafety.2/lib/ +platform:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/platform-2.2.1/lib/ +plugin_platform_interface:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/plugin_platform_interface-1.0.3/lib/ +pool:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/pool-1.5.0-nullsafety.2/lib/ +positioned_tap_detector:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/positioned_tap_detector-1.0.3/lib/ +process:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/process-3.0.13/lib/ +proj4dart:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/proj4dart-1.0.5/lib/ +pub_semver:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/pub_semver-1.4.4/lib/ +quiver:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/quiver-2.1.4+1/lib/ +rxdart:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/rxdart-0.24.1/lib/ +shelf:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf-0.7.9/lib/ +shelf_packages_handler:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf_packages_handler-2.0.0/lib/ +shelf_static:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf_static-0.2.8/lib/ +shelf_web_socket:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf_web_socket-0.2.3/lib/ +sky_engine:file:///C:/Entwicklung/flutter/bin/cache/pkg/sky_engine/lib/ +source_map_stack_trace:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/source_map_stack_trace-2.1.0-nullsafety.3/lib/ +source_maps:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/source_maps-0.10.10-nullsafety.2/lib/ +source_span:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/source_span-1.8.0-nullsafety.4/lib/ +sqflite:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/ +sqflite_common:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/sqflite_common-1.0.2+1/lib/ +stack_trace:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/stack_trace-1.10.0-nullsafety.6/lib/ +stream_channel:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/stream_channel-2.1.0-nullsafety.3/lib/ +string_scanner:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/string_scanner-1.1.0-nullsafety.3/lib/ +synchronized:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/synchronized-2.2.0+2/lib/ +term_glyph:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/term_glyph-1.2.0-nullsafety.3/lib/ +test:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/test-1.16.0-nullsafety.13/lib/ +test_api:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/test_api-0.2.19-nullsafety.6/lib/ +test_core:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/test_core-0.3.12-nullsafety.12/lib/ +transparent_image:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/transparent_image-1.0.0/lib/ +tuple:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/tuple-1.0.3/lib/ +typed_data:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/typed_data-1.3.0-nullsafety.5/lib/ +unicode:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/unicode-0.2.4/lib/ +uuid:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/uuid-2.2.2/lib/ +validate:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/validate-1.7.0/lib/ +vector_math:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/vector_math-2.1.0-nullsafety.5/lib/ +vm_service:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/vm_service-5.4.0/lib/ +watcher:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/watcher-0.9.7+15/lib/ +web_socket_channel:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/web_socket_channel-1.1.0/lib/ +webkit_inspection_protocol:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/webkit_inspection_protocol-0.7.3/lib/ +win32:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/win32-1.7.3/lib/ +wkt_parser:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/wkt_parser-1.0.7/lib/ +xdg_directories:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/xdg_directories-0.1.2/lib/ +yaml:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/yaml-2.2.1/lib/ +flutter_map:lib/ From c89928b9f3f5e9831bce176dabf353ed35ee1f2c Mon Sep 17 00:00:00 2001 From: escamoteur Date: Mon, 22 Mar 2021 09:03:11 +0100 Subject: [PATCH 03/16] updated dependcies to compile again --- .packages | 156 ++++++++++++++--------------- lib/src/gestures/gestures.dart | 141 +++++++++----------------- lib/src/map/flutter_map_state.dart | 22 ++-- pubspec.yaml | 10 +- 4 files changed, 133 insertions(+), 196 deletions(-) diff --git a/.packages b/.packages index b85cfee4d..cdce571db 100644 --- a/.packages +++ b/.packages @@ -1,95 +1,89 @@ -# Generated by pub on 2021-01-06 12:44:54.032544. -_fe_analyzer_shared:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/_fe_analyzer_shared-12.0.0/lib/ -analyzer:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/analyzer-0.40.5/lib/ -ansicolor:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/ansicolor-1.0.5/lib/ -args:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/args-1.6.0/lib/ -async:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/async-2.5.0-nullsafety.3/lib/ -boolean_selector:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/boolean_selector-2.1.0-nullsafety.3/lib/ -cached_network_image:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/cached_network_image-2.3.3/lib/ -characters:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/characters-1.1.0-nullsafety.5/lib/ -charcode:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/charcode-1.2.0-nullsafety.3/lib/ -cli_util:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/cli_util-0.2.0/lib/ -clock:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/clock-1.1.0-nullsafety.3/lib/ -collection:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/collection-1.15.0-nullsafety.5/lib/ +# This file is deprecated. Tools should instead consume +# `.dart_tools/package_config.json`. +# +# For more info see: https://dart.dev/go/dot-packages-deprecation +# +# Generated by pub on 2021-03-22 09:01:58.930317. +_fe_analyzer_shared:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/_fe_analyzer_shared-18.0.0/lib/ +analyzer:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/analyzer-1.2.0/lib/ +ansicolor:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/ansicolor-1.1.1/lib/ +args:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/args-2.0.0/lib/ +async:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/async-2.5.0/lib/ +boolean_selector:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/boolean_selector-2.1.0/lib/ +build:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/build-1.6.3/lib/ +built_collection:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/built_collection-5.0.0/lib/ +built_value:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/built_value-8.0.3/lib/ +characters:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/characters-1.1.0/lib/ +charcode:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/charcode-1.2.0/lib/ +cli_util:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/cli_util-0.3.0/lib/ +clock:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/clock-1.1.0/lib/ +code_builder:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/code_builder-3.7.0/lib/ +collection:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/collection-1.15.0/lib/ console_log_handler:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/console_log_handler-1.1.6/lib/ -convert:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/convert-2.1.1/lib/ -coverage:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/coverage-0.14.1/lib/ -crypto:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/crypto-2.1.5/lib/ -fake_async:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/fake_async-1.2.0-nullsafety.3/lib/ -ffi:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/ffi-0.1.3/lib/ -file:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/file-5.2.1/lib/ +convert:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/convert-3.0.0/lib/ +coverage:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/coverage-0.15.2/lib/ +crypto:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/crypto-3.0.0/lib/ +dart_style:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/dart_style-1.3.14/lib/ +fake_async:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/fake_async-1.2.0/lib/ +file:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/file-6.1.0/lib/ +fixnum:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/fixnum-1.0.0/lib/ flutter:file:///C:/Entwicklung/flutter/packages/flutter/lib/ -flutter_blurhash:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/flutter_blurhash-0.5.0/lib/ -flutter_cache_manager:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/flutter_cache_manager-2.0.0/lib/ flutter_image:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/flutter_image-3.0.0/lib/ flutter_test:file:///C:/Entwicklung/flutter/packages/flutter_test/lib/ -glob:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/glob-1.2.0/lib/ -http:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/http-0.12.2/lib/ -http_multi_server:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/http_multi_server-2.2.0/lib/ -http_parser:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/http_parser-3.1.4/lib/ -intl:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/intl-0.16.1/lib/ -io:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/io-0.3.4/lib/ -js:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/js-0.6.3-nullsafety.2/lib/ +flutter_web_plugins:file:///C:/Entwicklung/flutter/packages/flutter_web_plugins/lib/ +glob:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/glob-2.0.0/lib/ +http_multi_server:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/http_multi_server-3.0.0/lib/ +http_parser:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/http_parser-4.0.0/lib/ +intl:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/intl-0.17.0/lib/ +io:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/io-1.0.0/lib/ +js:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/js-0.6.3/lib/ latlong:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/latlong-0.6.1/lib/ lists:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/lists-0.1.6/lib/ -location:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/location-2.5.4/lib/ +location:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/location-4.1.1/lib/ +location_platform_interface:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/location_platform_interface-2.1.0/lib/ +location_web:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/location_web-3.0.0/lib/ logging:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/logging-0.11.4/lib/ -matcher:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/matcher-0.12.10-nullsafety.3/lib/ -meta:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/meta-1.3.0-nullsafety.6/lib/ +matcher:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/matcher-0.12.10/lib/ +meta:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/meta-1.3.0/lib/ mgrs_dart:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/mgrs_dart-1.0.1/lib/ -mime:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/mime-0.9.7/lib/ -node_interop:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/node_interop-1.1.1/lib/ -node_io:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/node_io-1.1.1/lib/ -node_preamble:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/node_preamble-1.4.12/lib/ -octo_image:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/octo_image-0.3.0/lib/ -package_config:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/package_config-1.9.3/lib/ -path:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/path-1.8.0-nullsafety.3/lib/ -path_provider:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/path_provider-1.6.22/lib/ -path_provider_linux:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/path_provider_linux-0.0.1+2/lib/ -path_provider_macos:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/path_provider_macos-0.0.4+4/lib/ -path_provider_platform_interface:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/path_provider_platform_interface-1.0.3/lib/ -path_provider_windows:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/path_provider_windows-0.0.4+1/lib/ -pedantic:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/pedantic-1.10.0-nullsafety.2/lib/ -platform:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/platform-2.2.1/lib/ -plugin_platform_interface:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/plugin_platform_interface-1.0.3/lib/ -pool:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/pool-1.5.0-nullsafety.2/lib/ -positioned_tap_detector:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/positioned_tap_detector-1.0.3/lib/ -process:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/process-3.0.13/lib/ +mime:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/mime-1.0.0/lib/ +mockito:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/mockito-5.0.2/lib/ +node_preamble:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/node_preamble-1.4.13/lib/ +package_config:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/package_config-2.0.0/lib/ +path:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/path-1.8.0/lib/ +pedantic:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/pedantic-1.11.0/lib/ +plugin_platform_interface:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/plugin_platform_interface-2.0.0/lib/ +pool:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/pool-1.5.0/lib/ +positioned_tap_detector_2:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/positioned_tap_detector_2-1.0.0/lib/ proj4dart:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/proj4dart-1.0.5/lib/ -pub_semver:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/pub_semver-1.4.4/lib/ -quiver:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/quiver-2.1.4+1/lib/ -rxdart:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/rxdart-0.24.1/lib/ -shelf:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf-0.7.9/lib/ -shelf_packages_handler:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf_packages_handler-2.0.0/lib/ -shelf_static:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf_static-0.2.8/lib/ -shelf_web_socket:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf_web_socket-0.2.3/lib/ +pub_semver:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/pub_semver-2.0.0/lib/ +quiver:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/quiver-3.0.0/lib/ +shelf:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf-1.1.0/lib/ +shelf_packages_handler:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf_packages_handler-3.0.0/lib/ +shelf_static:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf_static-1.0.0/lib/ +shelf_web_socket:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf_web_socket-1.0.1/lib/ sky_engine:file:///C:/Entwicklung/flutter/bin/cache/pkg/sky_engine/lib/ -source_map_stack_trace:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/source_map_stack_trace-2.1.0-nullsafety.3/lib/ -source_maps:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/source_maps-0.10.10-nullsafety.2/lib/ -source_span:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/source_span-1.8.0-nullsafety.4/lib/ -sqflite:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/sqflite-1.3.2+1/lib/ -sqflite_common:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/sqflite_common-1.0.2+1/lib/ -stack_trace:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/stack_trace-1.10.0-nullsafety.6/lib/ -stream_channel:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/stream_channel-2.1.0-nullsafety.3/lib/ -string_scanner:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/string_scanner-1.1.0-nullsafety.3/lib/ -synchronized:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/synchronized-2.2.0+2/lib/ -term_glyph:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/term_glyph-1.2.0-nullsafety.3/lib/ -test:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/test-1.16.0-nullsafety.13/lib/ -test_api:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/test_api-0.2.19-nullsafety.6/lib/ -test_core:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/test_core-0.3.12-nullsafety.12/lib/ -transparent_image:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/transparent_image-1.0.0/lib/ -tuple:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/tuple-1.0.3/lib/ -typed_data:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/typed_data-1.3.0-nullsafety.5/lib/ +source_gen:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/source_gen-0.9.10+3/lib/ +source_map_stack_trace:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/source_map_stack_trace-2.1.0/lib/ +source_maps:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/source_maps-0.10.10/lib/ +source_span:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/source_span-1.8.0/lib/ +stack_trace:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/stack_trace-1.10.0/lib/ +stream_channel:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/stream_channel-2.1.0/lib/ +string_scanner:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/string_scanner-1.1.0/lib/ +term_glyph:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/term_glyph-1.2.0/lib/ +test:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/test-1.16.5/lib/ +test_api:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/test_api-0.2.19/lib/ +test_core:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/test_core-0.3.15/lib/ +transparent_image:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/transparent_image-2.0.0/lib/ +tuple:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/tuple-2.0.0/lib/ +typed_data:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/typed_data-1.3.0/lib/ unicode:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/unicode-0.2.4/lib/ -uuid:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/uuid-2.2.2/lib/ validate:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/validate-1.7.0/lib/ -vector_math:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/vector_math-2.1.0-nullsafety.5/lib/ -vm_service:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/vm_service-5.4.0/lib/ -watcher:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/watcher-0.9.7+15/lib/ -web_socket_channel:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/web_socket_channel-1.1.0/lib/ -webkit_inspection_protocol:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/webkit_inspection_protocol-0.7.3/lib/ -win32:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/win32-1.7.3/lib/ +vector_math:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/vector_math-2.1.0/lib/ +vm_service:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/vm_service-6.1.0+1/lib/ +watcher:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/watcher-1.0.0/lib/ +web_socket_channel:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/web_socket_channel-2.0.0/lib/ +webkit_inspection_protocol:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/webkit_inspection_protocol-0.7.5/lib/ wkt_parser:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/wkt_parser-1.0.7/lib/ -xdg_directories:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/xdg_directories-0.1.2/lib/ -yaml:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/yaml-2.2.1/lib/ +yaml:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/yaml-3.1.0/lib/ flutter_map:lib/ diff --git a/lib/src/gestures/gestures.dart b/lib/src/gestures/gestures.dart index d491efc6d..d179ed8a5 100644 --- a/lib/src/gestures/gestures.dart +++ b/lib/src/gestures/gestures.dart @@ -9,8 +9,7 @@ import 'package:flutter_map/src/map/map.dart'; import 'package:latlong/latlong.dart'; import 'package:positioned_tap_detector_2/positioned_tap_detector_2.dart'; -abstract class MapGestureMixin extends State - with TickerProviderStateMixin { +abstract class MapGestureMixin extends State with TickerProviderStateMixin { static const double _kMinFlingVelocity = 800.0; var _dragMode = false; @@ -63,10 +62,9 @@ abstract class MapGestureMixin extends State _flingController = AnimationController(vsync: this) ..addListener(_handleFlingAnimation) ..addStatusListener(_flingAnimationStatusListener); - _doubleTapController = - AnimationController(vsync: this, duration: Duration(milliseconds: 200)) - ..addListener(_handleDoubleTapZoomAnimation) - ..addStatusListener(_doubleTapZoomStatusListener); + _doubleTapController = AnimationController(vsync: this, duration: Duration(milliseconds: 200)) + ..addListener(_handleDoubleTapZoomAnimation) + ..addStatusListener(_doubleTapZoomStatusListener); } @override @@ -76,8 +74,7 @@ abstract class MapGestureMixin extends State final oldFlags = oldWidget.options.interactiveFlags; final flags = options.interactiveFlags; - final oldGestures = - _getMultiFingerGestureFlags(mapOptions: oldWidget.options); + final oldGestures = _getMultiFingerGestureFlags(mapOptions: oldWidget.options); final gestures = _getMultiFingerGestureFlags(); if (flags != oldFlags || gestures != oldGestures) { @@ -92,8 +89,7 @@ abstract class MapGestureMixin extends State if (_rotationStarted && !(InteractiveFlag.hasFlag(flags, InteractiveFlag.rotate) && - MultiFingerGesture.hasFlag( - gestures, MultiFingerGesture.rotate))) { + MultiFingerGesture.hasFlag(gestures, MultiFingerGesture.rotate))) { _rotationStarted = false; if (_gestureWinner == MultiFingerGesture.rotate) { @@ -111,8 +107,7 @@ abstract class MapGestureMixin extends State if (_pinchZoomStarted && !(InteractiveFlag.hasFlag(flags, InteractiveFlag.pinchZoom) && - MultiFingerGesture.hasFlag( - gestures, MultiFingerGesture.pinchZoom))) { + MultiFingerGesture.hasFlag(gestures, MultiFingerGesture.pinchZoom))) { _pinchZoomStarted = false; emitMapEventMoveEnd = true; @@ -123,8 +118,7 @@ abstract class MapGestureMixin extends State if (_pinchMoveStarted && !(InteractiveFlag.hasFlag(flags, InteractiveFlag.pinchMove) && - MultiFingerGesture.hasFlag( - gestures, MultiFingerGesture.pinchMove))) { + MultiFingerGesture.hasFlag(gestures, MultiFingerGesture.pinchMove))) { _pinchMoveStarted = false; emitMapEventMoveEnd = true; @@ -133,8 +127,7 @@ abstract class MapGestureMixin extends State } } - if (_dragStarted && - !InteractiveFlag.hasFlag(flags, InteractiveFlag.drag)) { + if (_dragStarted && !InteractiveFlag.hasFlag(flags, InteractiveFlag.drag)) { _dragStarted = false; emitMapEventMoveEnd = true; } @@ -151,8 +144,7 @@ abstract class MapGestureMixin extends State } } - void _yieldMultiFingerGestureWinner( - int gestureWinner, bool resetStartVariables) { + void _yieldMultiFingerGestureWinner(int gestureWinner, bool resetStartVariables) { _gestureWinner = gestureWinner; if (resetStartVariables) { @@ -186,8 +178,7 @@ abstract class MapGestureMixin extends State _flingController.stop(); mapState.emitMapEvent( - MapEventFlingAnimationEnd( - center: mapState.center, zoom: mapState.zoom, source: source), + MapEventFlingAnimationEnd(center: mapState.center, zoom: mapState.zoom, source: source), ); } } @@ -197,8 +188,7 @@ abstract class MapGestureMixin extends State _doubleTapController.stop(); mapState.emitMapEvent( - MapEventDoubleTapZoomEnd( - center: mapState.center, zoom: mapState.zoom, source: source), + MapEventDoubleTapZoomEnd(center: mapState.center, zoom: mapState.zoom, source: source), ); } } @@ -206,9 +196,7 @@ abstract class MapGestureMixin extends State void handleScaleStart(ScaleStartDetails details) { _dragMode = _pointerCounter == 1; - final eventSource = _dragMode - ? MapEventSource.dragStart - : MapEventSource.multiFingerGestureStart; + final eventSource = _dragMode ? MapEventSource.dragStart : MapEventSource.multiFingerGestureStart; closeFlingAnimationController(eventSource); closeDoubleTapController(eventSource); @@ -234,8 +222,7 @@ abstract class MapGestureMixin extends State return; } - final eventSource = - _dragMode ? MapEventSource.onDrag : MapEventSource.onMultiFinger; + final eventSource = _dragMode ? MapEventSource.onDrag : MapEventSource.onMultiFinger; final flags = options.interactiveFlags; final focalOffset = details.localFocalPoint; @@ -273,34 +260,26 @@ abstract class MapGestureMixin extends State ); } } else { - final hasIntPinchMove = - InteractiveFlag.hasFlag(flags, InteractiveFlag.pinchMove); - final hasIntPinchZoom = - InteractiveFlag.hasFlag(flags, InteractiveFlag.pinchZoom); - final hasIntRotate = - InteractiveFlag.hasFlag(flags, InteractiveFlag.rotate); + final hasIntPinchMove = InteractiveFlag.hasFlag(flags, InteractiveFlag.pinchMove); + final hasIntPinchZoom = InteractiveFlag.hasFlag(flags, InteractiveFlag.pinchZoom); + final hasIntRotate = InteractiveFlag.hasFlag(flags, InteractiveFlag.rotate); if (hasIntPinchMove || hasIntPinchZoom || hasIntRotate) { final hasGestureRace = options.enableMultiFingerGestureRace; if (hasGestureRace && _gestureWinner == MultiFingerGesture.none) { if (hasIntPinchZoom && - (_getZoomForScale(_mapZoomStart, details.scale) - _mapZoomStart) - .abs() >= - options.pinchZoomThreshold) { + (_getZoomForScale(_mapZoomStart, details.scale) - _mapZoomStart).abs() >= options.pinchZoomThreshold) { if (options.debugMultiFingerGestureWinner) { print('Multi Finger Gesture winner: Pinch Zoom'); } _yieldMultiFingerGestureWinner(MultiFingerGesture.pinchZoom, true); - } else if (hasIntRotate && - currentRotation.abs() >= options.rotationThreshold) { + } else if (hasIntRotate && currentRotation.abs() >= options.rotationThreshold) { if (options.debugMultiFingerGestureWinner) { print('Multi Finger Gesture winner: Rotate'); } _yieldMultiFingerGestureWinner(MultiFingerGesture.rotate, true); - } else if (hasIntPinchMove && - (_focalStartLocal - focalOffset).distance >= - options.pinchMoveThreshold) { + } else if (hasIntPinchMove && (_focalStartLocal - focalOffset).distance >= options.pinchMoveThreshold) { if (options.debugMultiFingerGestureWinner) { print('Multi Finger Gesture winner: Pinch Move'); } @@ -311,12 +290,9 @@ abstract class MapGestureMixin extends State if (!hasGestureRace || _gestureWinner != MultiFingerGesture.none) { final gestures = _getMultiFingerGestureFlags(); - final hasGesturePinchMove = MultiFingerGesture.hasFlag( - gestures, MultiFingerGesture.pinchMove); - final hasGesturePinchZoom = MultiFingerGesture.hasFlag( - gestures, MultiFingerGesture.pinchZoom); - final hasGestureRotate = - MultiFingerGesture.hasFlag(gestures, MultiFingerGesture.rotate); + final hasGesturePinchMove = MultiFingerGesture.hasFlag(gestures, MultiFingerGesture.pinchMove); + final hasGesturePinchZoom = MultiFingerGesture.hasFlag(gestures, MultiFingerGesture.pinchZoom); + final hasGestureRotate = MultiFingerGesture.hasFlag(gestures, MultiFingerGesture.rotate); final hasMove = hasIntPinchMove && hasGesturePinchMove; final hasZoom = hasIntPinchZoom && hasGesturePinchZoom; @@ -327,8 +303,7 @@ abstract class MapGestureMixin extends State if (hasMove || hasZoom) { double newZoom; if (hasZoom) { - newZoom = _getZoomForScale( - _mapZoomStart, details.scale + _scaleCorrector); + newZoom = _getZoomForScale(_mapZoomStart, details.scale + _scaleCorrector); if (!_pinchZoomStarted) { if (newZoom != _mapZoomStart) { @@ -369,11 +344,9 @@ abstract class MapGestureMixin extends State if (_pinchMoveStarted) { final oldCenterPt = mapState.project(mapState.center, newZoom); - final localDistanceOffset = - _rotateOffset(_lastFocalLocal - focalOffset); + final localDistanceOffset = _rotateOffset(_lastFocalLocal - focalOffset); - final newCenterPt = - oldCenterPt + _offsetToPoint(localDistanceOffset); + final newCenterPt = oldCenterPt + _offsetToPoint(localDistanceOffset); newCenter = mapState.unproject(newCenterPt, newZoom); } else { newCenter = mapState.center; @@ -435,8 +408,7 @@ abstract class MapGestureMixin extends State return; } - final eventSource = - _dragMode ? MapEventSource.dragEnd : MapEventSource.multiFingerEnd; + final eventSource = _dragMode ? MapEventSource.dragEnd : MapEventSource.multiFingerEnd; if (_rotationStarted) { _rotationStarted = false; @@ -460,8 +432,7 @@ abstract class MapGestureMixin extends State ); } - var hasFling = InteractiveFlag.hasFlag( - options.interactiveFlags, InteractiveFlag.flingAnimation); + var hasFling = InteractiveFlag.hasFlag(options.interactiveFlags, InteractiveFlag.flingAnimation); var magnitude = details.velocity.pixelsPerSecond.distance; if (magnitude < _kMinFlingVelocity || !hasFling) { @@ -479,9 +450,7 @@ abstract class MapGestureMixin extends State } var direction = details.velocity.pixelsPerSecond / magnitude; - var distance = - (Offset.zero & Size(mapState.originalSize.x, mapState.originalSize.y)) - .shortestSide; + var distance = (Offset.zero & Size(mapState.originalSize.x, mapState.originalSize.y)).shortestSide; var _flingOffset = _focalStartLocal - _lastFocalLocal; _flingAnimation = Tween( @@ -538,8 +507,7 @@ abstract class MapGestureMixin extends State LatLng _offsetToCrs(Offset offset) { final focalStartPt = mapState.project(mapState.center, mapState.zoom); - final point = (_offsetToPoint(offset) - (mapState.originalSize / 2.0)) - .rotate(mapState.rotationRad); + final point = (_offsetToPoint(offset) - (mapState.originalSize / 2.0)).rotate(mapState.rotationRad); var newCenterPt = focalStartPt + point; return mapState.unproject(newCenterPt, mapState.zoom); @@ -555,29 +523,23 @@ abstract class MapGestureMixin extends State closeFlingAnimationController(MapEventSource.doubleTap); closeDoubleTapController(MapEventSource.doubleTap); - if (InteractiveFlag.hasFlag( - options.interactiveFlags, InteractiveFlag.doubleTapZoom)) { + if (InteractiveFlag.hasFlag(options.interactiveFlags, InteractiveFlag.doubleTapZoom)) { final centerPos = _pointToOffset(mapState.originalSize) / 2.0; final newZoom = _getZoomForScale(mapState.zoom, 2.0); - final focalDelta = _getDoubleTapFocalDelta( - centerPos, tapPosition.relative, newZoom - mapState.zoom); + final focalDelta = _getDoubleTapFocalDelta(centerPos, tapPosition.relative, newZoom - mapState.zoom); final newCenter = _offsetToCrs(centerPos + focalDelta); _startDoubleTapAnimation(newZoom, newCenter); } } - Offset _getDoubleTapFocalDelta( - Offset centerPos, Offset tapPos, double zoomDiff) { + Offset _getDoubleTapFocalDelta(Offset centerPos, Offset tapPos, double zoomDiff) { final tapDelta = tapPos - centerPos; final zoomScale = 1 / math.pow(2, zoomDiff); // The map center offset within which double-tap won't cause zooming to // previously invisible area final maxDelta = centerPos * (1 - zoomScale); - final tappedOutExtent = - tapDelta.dx.abs() > maxDelta.dx || tapDelta.dy.abs() > maxDelta.dy; - return tappedOutExtent - ? _projectDeltaOnBounds(tapDelta, maxDelta) - : tapDelta; + final tappedOutExtent = tapDelta.dx.abs() > maxDelta.dx || tapDelta.dy.abs() > maxDelta.dy; + return tappedOutExtent ? _projectDeltaOnBounds(tapDelta, maxDelta) : tapDelta; } Offset _projectDeltaOnBounds(Offset delta, Offset maxDelta) { @@ -590,10 +552,9 @@ abstract class MapGestureMixin extends State _doubleTapZoomAnimation = Tween(begin: mapState.zoom, end: newZoom) .chain(CurveTween(curve: Curves.fastOutSlowIn)) .animate(_doubleTapController); - _doubleTapCenterAnimation = - LatLngTween(begin: mapState.center, end: newCenter) - .chain(CurveTween(curve: Curves.fastOutSlowIn)) - .animate(_doubleTapController); + _doubleTapCenterAnimation = LatLngTween(begin: mapState.center, end: newCenter) + .chain(CurveTween(curve: Curves.fastOutSlowIn)) + .animate(_doubleTapController); _doubleTapController.forward(from: 0.0); } @@ -601,16 +562,12 @@ abstract class MapGestureMixin extends State if (status == AnimationStatus.forward) { mapState.emitMapEvent( MapEventDoubleTapZoomStart( - center: mapState.center, - zoom: mapState.zoom, - source: MapEventSource.doubleTapZoomAnimationController), + center: mapState.center, zoom: mapState.zoom, source: MapEventSource.doubleTapZoomAnimationController), ); } else if (status == AnimationStatus.completed) { mapState.emitMapEvent( MapEventDoubleTapZoomEnd( - center: mapState.center, - zoom: mapState.zoom, - source: MapEventSource.doubleTapZoomAnimationController), + center: mapState.center, zoom: mapState.zoom, source: MapEventSource.doubleTapZoomAnimationController), ); } } @@ -628,8 +585,7 @@ abstract class MapGestureMixin extends State _doubleTapHoldMaxDelay?.cancel(); if (++_tapUpCounter == 1) { - _doubleTapHoldMaxDelay = - Timer(const Duration(milliseconds: 350), _resetDoubleTapHold); + _doubleTapHoldMaxDelay = Timer(const Duration(milliseconds: 350), _resetDoubleTapHold); } } @@ -666,9 +622,7 @@ abstract class MapGestureMixin extends State _flingAnimationStarted = false; mapState.emitMapEvent( MapEventFlingAnimationEnd( - center: mapState.center, - zoom: mapState.zoom, - source: MapEventSource.flingAnimationController), + center: mapState.center, zoom: mapState.zoom, source: MapEventSource.flingAnimationController), ); } } @@ -678,14 +632,12 @@ abstract class MapGestureMixin extends State _flingAnimationStarted = true; mapState.emitMapEvent( MapEventFlingAnimationStart( - center: mapState.center, - zoom: mapState.zoom, - source: MapEventSource.flingAnimationController), + center: mapState.center, zoom: mapState.zoom, source: MapEventSource.flingAnimationController), ); } - var newCenterPoint = mapState.project(_mapCenterStart) + - _offsetToPoint(_flingAnimation.value).rotate(mapState.rotationRad); + var newCenterPoint = + mapState.project(_mapCenterStart) + _offsetToPoint(_flingAnimation.value).rotate(mapState.rotationRad); var newCenter = mapState.unproject(newCenterPoint); mapState.move( @@ -705,8 +657,7 @@ abstract class MapGestureMixin extends State } double _getZoomForScale(double startZoom, double scale) { - var resultZoom = - scale == 1.0 ? startZoom : startZoom + math.log(scale) / math.ln2; + var resultZoom = scale == 1.0 ? startZoom : startZoom + math.log(scale) / math.ln2; return mapState.fitZoomToBounds(resultZoom); } diff --git a/lib/src/map/flutter_map_state.dart b/lib/src/map/flutter_map_state.dart index 0b5503f80..fa188b422 100644 --- a/lib/src/map/flutter_map_state.dart +++ b/lib/src/map/flutter_map_state.dart @@ -21,8 +21,7 @@ class FlutterMapState extends MapGestureMixin { @override MapState mapState; - FlutterMapState(MapController mapController) - : mapController = mapController ?? MapController(); + FlutterMapState(MapController mapController) : mapController = mapController ?? MapController(); @override void didUpdateWidget(FlutterMap oldWidget) { @@ -70,8 +69,7 @@ class FlutterMapState extends MapGestureMixin { @override Widget build(BuildContext context) { _disposeStreamGroups(); - return LayoutBuilder( - builder: (BuildContext context, BoxConstraints constraints) { + return LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) { mapState.setOriginalSize(constraints.maxWidth, constraints.maxHeight); var size = mapState.size; @@ -106,11 +104,8 @@ class FlutterMapState extends MapGestureMixin { angle: mapState.rotationRad, child: Stack( children: [ - if (widget.children != null && - widget.children.isNotEmpty) - ...widget.children, - if (widget.layers != null && - widget.layers.isNotEmpty) + if (widget.children != null && widget.children.isNotEmpty) ...widget.children, + if (widget.layers != null && widget.layers.isNotEmpty) ...widget.layers.map( (layer) => _createLayer(layer, options.plugins), ) @@ -120,11 +115,9 @@ class FlutterMapState extends MapGestureMixin { ), Stack( children: [ - if (widget.nonRotatedChildren != null && - widget.nonRotatedChildren.isNotEmpty) + if (widget.nonRotatedChildren != null && widget.nonRotatedChildren.isNotEmpty) ...widget.nonRotatedChildren, - if (widget.nonRotatedLayers != null && - widget.nonRotatedLayers.isNotEmpty) + if (widget.nonRotatedLayers != null && widget.nonRotatedLayers.isNotEmpty) ...widget.nonRotatedLayers.map( (layer) => _createLayer(layer, options.plugins), ) @@ -147,8 +140,7 @@ class FlutterMapState extends MapGestureMixin { } } if (options is TileLayerOptions) { - return TileLayer( - options: options, mapState: mapState, stream: _merge(options)); + return TileLayer(options: options, mapState: mapState, stream: _merge(options)); } if (options is MarkerLayerOptions) { return MarkerLayer(options, mapState, _merge(options)); diff --git a/pubspec.yaml b/pubspec.yaml index 473f541e3..13a93e1d7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,10 +10,10 @@ environment: dependencies: flutter: sdk: flutter - tuple: ^1.0.2 + tuple: ^2.0.0 latlong: ^0.6.1 positioned_tap_detector_2: ^1.0.0 - transparent_image: ^1.0.0 + transparent_image: ^2.0.0 async: ^2.1.0 flutter_image: ^3.0.0 vector_math: ^2.0.0 @@ -23,8 +23,8 @@ dependencies: dev_dependencies: pedantic: ^1.11.0 - location: ^2.5.0 + location: ^4.1.1 flutter_test: sdk: flutter - test: ^1.9.0 - mockito: ^4.1.4 + test: ^1.16.5 + mockito: ^5.0.2 From 4119d2e2eb09507780aa134d35d3a2a472e4151d Mon Sep 17 00:00:00 2001 From: escamoteur Date: Mon, 22 Mar 2021 10:25:44 +0100 Subject: [PATCH 04/16] updated latlong import --- .packages | 9 +- CHANGELOG.md | 2 +- .../lib/pages/animated_map_controller.dart | 2 +- example/lib/pages/circle.dart | 2 +- example/lib/pages/custom_crs/custom_crs.dart | 2 +- example/lib/pages/esri.dart | 2 +- example/lib/pages/home.dart | 2 +- example/lib/pages/interactive_test_page.dart | 2 +- example/lib/pages/live_location.dart | 2 +- example/lib/pages/map_controller.dart | 2 +- example/lib/pages/marker_anchor.dart | 2 +- example/lib/pages/moving_markers.dart | 2 +- example/lib/pages/offline_map.dart | 2 +- example/lib/pages/on_tap.dart | 2 +- example/lib/pages/overlay_image.dart | 2 +- example/lib/pages/plugin_api.dart | 2 +- example/lib/pages/plugin_scalebar.dart | 2 +- example/lib/pages/plugin_zoombuttons.dart | 2 +- example/lib/pages/polyline.dart | 2 +- example/lib/pages/scalebar_utils.dart | 5 +- example/lib/pages/sliding_map.dart | 2 +- example/lib/pages/tap_to_add.dart | 2 +- example/lib/pages/tile_builder_example.dart | 2 +- .../lib/pages/tile_loading_error_handle.dart | 2 +- example/lib/pages/widgets.dart | 2 +- example/lib/pages/wms_tile_layer.dart | 2 +- example/lib/test_app.dart | 2 +- lib/flutter_map.dart | 2 +- lib/src/core/center_zoom.dart | 2 +- lib/src/geo/crs/crs.dart | 2 +- lib/src/geo/latlng_bounds.dart | 3 +- lib/src/gestures/gestures.dart | 143 ++++++++++++------ lib/src/gestures/latlng_tween.dart | 2 +- lib/src/gestures/map_events.dart | 2 +- lib/src/layer/circle_layer.dart | 2 +- lib/src/layer/marker_layer.dart | 2 +- lib/src/layer/polygon_layer.dart | 2 +- lib/src/layer/polyline_layer.dart | 2 +- lib/src/layer/tile_layer.dart | 2 +- lib/src/map/flutter_map_state.dart | 22 ++- lib/src/map/map.dart | 2 +- pubspec.yaml | 7 +- test/flutter_map_test.dart | 2 +- 43 files changed, 161 insertions(+), 102 deletions(-) diff --git a/.packages b/.packages index cdce571db..c8543ee3b 100644 --- a/.packages +++ b/.packages @@ -3,10 +3,9 @@ # # For more info see: https://dart.dev/go/dot-packages-deprecation # -# Generated by pub on 2021-03-22 09:01:58.930317. +# Generated by pub on 2021-03-22 10:22:41.937805. _fe_analyzer_shared:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/_fe_analyzer_shared-18.0.0/lib/ analyzer:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/analyzer-1.2.0/lib/ -ansicolor:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/ansicolor-1.1.1/lib/ args:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/args-2.0.0/lib/ async:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/async-2.5.0/lib/ boolean_selector:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/boolean_selector-2.1.0/lib/ @@ -19,7 +18,6 @@ cli_util:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.or clock:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/clock-1.1.0/lib/ code_builder:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/code_builder-3.7.0/lib/ collection:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/collection-1.15.0/lib/ -console_log_handler:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/console_log_handler-1.1.6/lib/ convert:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/convert-3.0.0/lib/ coverage:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/coverage-0.15.2/lib/ crypto:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/crypto-3.0.0/lib/ @@ -28,7 +26,7 @@ fake_async:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang. file:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/file-6.1.0/lib/ fixnum:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/fixnum-1.0.0/lib/ flutter:file:///C:/Entwicklung/flutter/packages/flutter/lib/ -flutter_image:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/flutter_image-3.0.0/lib/ +flutter_image:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/git/flutter_image-b3d792066477efc57c7baa57098cfc3a0164de41/lib/ flutter_test:file:///C:/Entwicklung/flutter/packages/flutter_test/lib/ flutter_web_plugins:file:///C:/Entwicklung/flutter/packages/flutter_web_plugins/lib/ glob:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/glob-2.0.0/lib/ @@ -37,7 +35,7 @@ http_parser:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang intl:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/intl-0.17.0/lib/ io:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/io-1.0.0/lib/ js:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/js-0.6.3/lib/ -latlong:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/latlong-0.6.1/lib/ +latlong2:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/latlong2-0.8.0/lib/ lists:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/lists-0.1.6/lib/ location:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/location-4.1.1/lib/ location_platform_interface:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/location_platform_interface-2.1.0/lib/ @@ -78,7 +76,6 @@ transparent_image:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.da tuple:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/tuple-2.0.0/lib/ typed_data:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/typed_data-1.3.0/lib/ unicode:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/unicode-0.2.4/lib/ -validate:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/validate-1.7.0/lib/ vector_math:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/vector_math-2.1.0/lib/ vm_service:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/vm_service-6.1.0+1/lib/ watcher:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/watcher-1.0.0/lib/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c360bd6a..157f6aece 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -249,7 +249,7 @@ release! - Set Dart SDK to 2 ## [0.0.11] - 8/2/2018 -- upgrade to latlong from 0.4.0 to 0.5.3 +- upgrade to latlong2 from 0.4.0 to 0.5.3 ## [0.0.11] - 7/31/2018 - fix LICENSE spelling error diff --git a/example/lib/pages/animated_map_controller.dart b/example/lib/pages/animated_map_controller.dart index e5d9eab46..f18074cb0 100644 --- a/example/lib/pages/animated_map_controller.dart +++ b/example/lib/pages/animated_map_controller.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; import '../widgets/drawer.dart'; diff --git a/example/lib/pages/circle.dart b/example/lib/pages/circle.dart index 723776bf2..01eb386c7 100644 --- a/example/lib/pages/circle.dart +++ b/example/lib/pages/circle.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; import '../widgets/drawer.dart'; diff --git a/example/lib/pages/custom_crs/custom_crs.dart b/example/lib/pages/custom_crs/custom_crs.dart index f37ab02d7..95dc14189 100644 --- a/example/lib/pages/custom_crs/custom_crs.dart +++ b/example/lib/pages/custom_crs/custom_crs.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map/plugin_api.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; import 'package:proj4dart/proj4dart.dart' as proj4; import '../../widgets/drawer.dart'; diff --git a/example/lib/pages/esri.dart b/example/lib/pages/esri.dart index d316b0b88..7976e133e 100644 --- a/example/lib/pages/esri.dart +++ b/example/lib/pages/esri.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; import '../widgets/drawer.dart'; diff --git a/example/lib/pages/home.dart b/example/lib/pages/home.dart index 621a3fbc3..9e4146ed3 100644 --- a/example/lib/pages/home.dart +++ b/example/lib/pages/home.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; import '../widgets/drawer.dart'; diff --git a/example/lib/pages/interactive_test_page.dart b/example/lib/pages/interactive_test_page.dart index f76af65c9..c3c684de4 100644 --- a/example/lib/pages/interactive_test_page.dart +++ b/example/lib/pages/interactive_test_page.dart @@ -2,7 +2,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; import '../widgets/drawer.dart'; diff --git a/example/lib/pages/live_location.dart b/example/lib/pages/live_location.dart index 707208aa6..e5d14b017 100644 --- a/example/lib/pages/live_location.dart +++ b/example/lib/pages/live_location.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_map/flutter_map.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; import 'package:location/location.dart'; import '../widgets/drawer.dart'; diff --git a/example/lib/pages/map_controller.dart b/example/lib/pages/map_controller.dart index b21f360c3..676b642ee 100644 --- a/example/lib/pages/map_controller.dart +++ b/example/lib/pages/map_controller.dart @@ -2,7 +2,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; import 'package:location/location.dart'; import '../widgets/drawer.dart'; diff --git a/example/lib/pages/marker_anchor.dart b/example/lib/pages/marker_anchor.dart index 522abf71a..e59435561 100644 --- a/example/lib/pages/marker_anchor.dart +++ b/example/lib/pages/marker_anchor.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; import '../widgets/drawer.dart'; diff --git a/example/lib/pages/moving_markers.dart b/example/lib/pages/moving_markers.dart index 8719d4e65..c561db011 100644 --- a/example/lib/pages/moving_markers.dart +++ b/example/lib/pages/moving_markers.dart @@ -2,7 +2,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; import '../widgets/drawer.dart'; diff --git a/example/lib/pages/offline_map.dart b/example/lib/pages/offline_map.dart index c2e75a496..868bde97d 100644 --- a/example/lib/pages/offline_map.dart +++ b/example/lib/pages/offline_map.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; import '../widgets/drawer.dart'; diff --git a/example/lib/pages/on_tap.dart b/example/lib/pages/on_tap.dart index 557a7b7a7..8aba3db83 100644 --- a/example/lib/pages/on_tap.dart +++ b/example/lib/pages/on_tap.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; import '../widgets/drawer.dart'; diff --git a/example/lib/pages/overlay_image.dart b/example/lib/pages/overlay_image.dart index 38ce7615d..79816db2b 100644 --- a/example/lib/pages/overlay_image.dart +++ b/example/lib/pages/overlay_image.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; import '../widgets/drawer.dart'; diff --git a/example/lib/pages/plugin_api.dart b/example/lib/pages/plugin_api.dart index 50af71834..da894a06b 100644 --- a/example/lib/pages/plugin_api.dart +++ b/example/lib/pages/plugin_api.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/plugin_api.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; import '../widgets/drawer.dart'; diff --git a/example/lib/pages/plugin_scalebar.dart b/example/lib/pages/plugin_scalebar.dart index cfcb8c2e6..2780456b6 100644 --- a/example/lib/pages/plugin_scalebar.dart +++ b/example/lib/pages/plugin_scalebar.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/plugin_api.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; import '../widgets/drawer.dart'; import 'scale_layer_plugin_option.dart'; diff --git a/example/lib/pages/plugin_zoombuttons.dart b/example/lib/pages/plugin_zoombuttons.dart index e48886668..e2b24686b 100644 --- a/example/lib/pages/plugin_zoombuttons.dart +++ b/example/lib/pages/plugin_zoombuttons.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/plugin_api.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; import '../widgets/drawer.dart'; import 'zoombuttons_plugin_option.dart'; diff --git a/example/lib/pages/polyline.dart b/example/lib/pages/polyline.dart index 8fd1ee355..5d17a336b 100644 --- a/example/lib/pages/polyline.dart +++ b/example/lib/pages/polyline.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; import '../widgets/drawer.dart'; diff --git a/example/lib/pages/scalebar_utils.dart b/example/lib/pages/scalebar_utils.dart index 1f7b232e8..f888e2e8d 100644 --- a/example/lib/pages/scalebar_utils.dart +++ b/example/lib/pages/scalebar_utils.dart @@ -1,7 +1,8 @@ import 'dart:math'; -import 'package:latlong/latlong.dart'; -const double piOver180 = PI / 180.0; +import 'package:latlong2/latlong.dart'; + +const double piOver180 = pi / 180.0; double toDegrees(double radians) { return radians / piOver180; } diff --git a/example/lib/pages/sliding_map.dart b/example/lib/pages/sliding_map.dart index 249578dd3..d9286803c 100644 --- a/example/lib/pages/sliding_map.dart +++ b/example/lib/pages/sliding_map.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; import '../widgets/drawer.dart'; diff --git a/example/lib/pages/tap_to_add.dart b/example/lib/pages/tap_to_add.dart index 81ec190b0..0cfbdd0ac 100644 --- a/example/lib/pages/tap_to_add.dart +++ b/example/lib/pages/tap_to_add.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; import '../widgets/drawer.dart'; diff --git a/example/lib/pages/tile_builder_example.dart b/example/lib/pages/tile_builder_example.dart index 2dc974440..44cf6d2ca 100644 --- a/example/lib/pages/tile_builder_example.dart +++ b/example/lib/pages/tile_builder_example.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; import '../widgets/drawer.dart'; diff --git a/example/lib/pages/tile_loading_error_handle.dart b/example/lib/pages/tile_loading_error_handle.dart index 85d39ad39..9ff249af9 100644 --- a/example/lib/pages/tile_loading_error_handle.dart +++ b/example/lib/pages/tile_loading_error_handle.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; import '../widgets/drawer.dart'; diff --git a/example/lib/pages/widgets.dart b/example/lib/pages/widgets.dart index a72d7f23f..0c7da07f7 100644 --- a/example/lib/pages/widgets.dart +++ b/example/lib/pages/widgets.dart @@ -2,7 +2,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_map/plugin_api.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; import '../pages/zoombuttons_plugin_option.dart'; import '../widgets/drawer.dart'; diff --git a/example/lib/pages/wms_tile_layer.dart b/example/lib/pages/wms_tile_layer.dart index 70bf91130..480103f7e 100644 --- a/example/lib/pages/wms_tile_layer.dart +++ b/example/lib/pages/wms_tile_layer.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; import '../widgets/drawer.dart'; diff --git a/example/lib/test_app.dart b/example/lib/test_app.dart index 86a0a2456..830cb98b9 100644 --- a/example/lib/test_app.dart +++ b/example/lib/test_app.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; void main() { runApp(TestApp()); diff --git a/lib/flutter_map.dart b/lib/flutter_map.dart index d6bf937e0..6b0f17e36 100644 --- a/lib/flutter_map.dart +++ b/lib/flutter_map.dart @@ -12,7 +12,7 @@ import 'package:flutter_map/src/gestures/multi_finger_gesture.dart'; import 'package:flutter_map/src/map/flutter_map_state.dart'; import 'package:flutter_map/src/map/map.dart'; import 'package:flutter_map/src/plugins/plugin.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; export 'package:flutter_map/src/core/point.dart'; export 'package:flutter_map/src/geo/crs/crs.dart'; diff --git a/lib/src/core/center_zoom.dart b/lib/src/core/center_zoom.dart index a725d6fe8..334abf8dc 100644 --- a/lib/src/core/center_zoom.dart +++ b/lib/src/core/center_zoom.dart @@ -1,4 +1,4 @@ -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; class CenterZoom { final LatLng center; diff --git a/lib/src/geo/crs/crs.dart b/lib/src/geo/crs/crs.dart index 024f779e4..e66e14de9 100644 --- a/lib/src/geo/crs/crs.dart +++ b/lib/src/geo/crs/crs.dart @@ -2,7 +2,7 @@ import 'dart:math' as math; import 'package:flutter_map/src/core/bounds.dart'; import 'package:flutter_map/src/core/point.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; import 'package:meta/meta.dart'; import 'package:proj4dart/proj4dart.dart' as proj4; import 'package:tuple/tuple.dart'; diff --git a/lib/src/geo/latlng_bounds.dart b/lib/src/geo/latlng_bounds.dart index 143366755..7e0f0a0e7 100644 --- a/lib/src/geo/latlng_bounds.dart +++ b/lib/src/geo/latlng_bounds.dart @@ -1,5 +1,6 @@ import 'dart:math' as math; -import 'package:latlong/latlong.dart'; + +import 'package:latlong2/latlong.dart'; class LatLngBounds { LatLng _sw; diff --git a/lib/src/gestures/gestures.dart b/lib/src/gestures/gestures.dart index d179ed8a5..30cf88d53 100644 --- a/lib/src/gestures/gestures.dart +++ b/lib/src/gestures/gestures.dart @@ -6,10 +6,11 @@ import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map/src/gestures/interactive_flag.dart'; import 'package:flutter_map/src/gestures/latlng_tween.dart'; import 'package:flutter_map/src/map/map.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; import 'package:positioned_tap_detector_2/positioned_tap_detector_2.dart'; -abstract class MapGestureMixin extends State with TickerProviderStateMixin { +abstract class MapGestureMixin extends State + with TickerProviderStateMixin { static const double _kMinFlingVelocity = 800.0; var _dragMode = false; @@ -62,9 +63,10 @@ abstract class MapGestureMixin extends State with TickerProviderStat _flingController = AnimationController(vsync: this) ..addListener(_handleFlingAnimation) ..addStatusListener(_flingAnimationStatusListener); - _doubleTapController = AnimationController(vsync: this, duration: Duration(milliseconds: 200)) - ..addListener(_handleDoubleTapZoomAnimation) - ..addStatusListener(_doubleTapZoomStatusListener); + _doubleTapController = + AnimationController(vsync: this, duration: Duration(milliseconds: 200)) + ..addListener(_handleDoubleTapZoomAnimation) + ..addStatusListener(_doubleTapZoomStatusListener); } @override @@ -74,7 +76,8 @@ abstract class MapGestureMixin extends State with TickerProviderStat final oldFlags = oldWidget.options.interactiveFlags; final flags = options.interactiveFlags; - final oldGestures = _getMultiFingerGestureFlags(mapOptions: oldWidget.options); + final oldGestures = + _getMultiFingerGestureFlags(mapOptions: oldWidget.options); final gestures = _getMultiFingerGestureFlags(); if (flags != oldFlags || gestures != oldGestures) { @@ -89,7 +92,8 @@ abstract class MapGestureMixin extends State with TickerProviderStat if (_rotationStarted && !(InteractiveFlag.hasFlag(flags, InteractiveFlag.rotate) && - MultiFingerGesture.hasFlag(gestures, MultiFingerGesture.rotate))) { + MultiFingerGesture.hasFlag( + gestures, MultiFingerGesture.rotate))) { _rotationStarted = false; if (_gestureWinner == MultiFingerGesture.rotate) { @@ -107,7 +111,8 @@ abstract class MapGestureMixin extends State with TickerProviderStat if (_pinchZoomStarted && !(InteractiveFlag.hasFlag(flags, InteractiveFlag.pinchZoom) && - MultiFingerGesture.hasFlag(gestures, MultiFingerGesture.pinchZoom))) { + MultiFingerGesture.hasFlag( + gestures, MultiFingerGesture.pinchZoom))) { _pinchZoomStarted = false; emitMapEventMoveEnd = true; @@ -118,7 +123,8 @@ abstract class MapGestureMixin extends State with TickerProviderStat if (_pinchMoveStarted && !(InteractiveFlag.hasFlag(flags, InteractiveFlag.pinchMove) && - MultiFingerGesture.hasFlag(gestures, MultiFingerGesture.pinchMove))) { + MultiFingerGesture.hasFlag( + gestures, MultiFingerGesture.pinchMove))) { _pinchMoveStarted = false; emitMapEventMoveEnd = true; @@ -127,7 +133,8 @@ abstract class MapGestureMixin extends State with TickerProviderStat } } - if (_dragStarted && !InteractiveFlag.hasFlag(flags, InteractiveFlag.drag)) { + if (_dragStarted && + !InteractiveFlag.hasFlag(flags, InteractiveFlag.drag)) { _dragStarted = false; emitMapEventMoveEnd = true; } @@ -144,7 +151,8 @@ abstract class MapGestureMixin extends State with TickerProviderStat } } - void _yieldMultiFingerGestureWinner(int gestureWinner, bool resetStartVariables) { + void _yieldMultiFingerGestureWinner( + int gestureWinner, bool resetStartVariables) { _gestureWinner = gestureWinner; if (resetStartVariables) { @@ -178,7 +186,8 @@ abstract class MapGestureMixin extends State with TickerProviderStat _flingController.stop(); mapState.emitMapEvent( - MapEventFlingAnimationEnd(center: mapState.center, zoom: mapState.zoom, source: source), + MapEventFlingAnimationEnd( + center: mapState.center, zoom: mapState.zoom, source: source), ); } } @@ -188,7 +197,8 @@ abstract class MapGestureMixin extends State with TickerProviderStat _doubleTapController.stop(); mapState.emitMapEvent( - MapEventDoubleTapZoomEnd(center: mapState.center, zoom: mapState.zoom, source: source), + MapEventDoubleTapZoomEnd( + center: mapState.center, zoom: mapState.zoom, source: source), ); } } @@ -196,7 +206,9 @@ abstract class MapGestureMixin extends State with TickerProviderStat void handleScaleStart(ScaleStartDetails details) { _dragMode = _pointerCounter == 1; - final eventSource = _dragMode ? MapEventSource.dragStart : MapEventSource.multiFingerGestureStart; + final eventSource = _dragMode + ? MapEventSource.dragStart + : MapEventSource.multiFingerGestureStart; closeFlingAnimationController(eventSource); closeDoubleTapController(eventSource); @@ -222,7 +234,8 @@ abstract class MapGestureMixin extends State with TickerProviderStat return; } - final eventSource = _dragMode ? MapEventSource.onDrag : MapEventSource.onMultiFinger; + final eventSource = + _dragMode ? MapEventSource.onDrag : MapEventSource.onMultiFinger; final flags = options.interactiveFlags; final focalOffset = details.localFocalPoint; @@ -260,26 +273,34 @@ abstract class MapGestureMixin extends State with TickerProviderStat ); } } else { - final hasIntPinchMove = InteractiveFlag.hasFlag(flags, InteractiveFlag.pinchMove); - final hasIntPinchZoom = InteractiveFlag.hasFlag(flags, InteractiveFlag.pinchZoom); - final hasIntRotate = InteractiveFlag.hasFlag(flags, InteractiveFlag.rotate); + final hasIntPinchMove = + InteractiveFlag.hasFlag(flags, InteractiveFlag.pinchMove); + final hasIntPinchZoom = + InteractiveFlag.hasFlag(flags, InteractiveFlag.pinchZoom); + final hasIntRotate = + InteractiveFlag.hasFlag(flags, InteractiveFlag.rotate); if (hasIntPinchMove || hasIntPinchZoom || hasIntRotate) { final hasGestureRace = options.enableMultiFingerGestureRace; if (hasGestureRace && _gestureWinner == MultiFingerGesture.none) { if (hasIntPinchZoom && - (_getZoomForScale(_mapZoomStart, details.scale) - _mapZoomStart).abs() >= options.pinchZoomThreshold) { + (_getZoomForScale(_mapZoomStart, details.scale) - _mapZoomStart) + .abs() >= + options.pinchZoomThreshold) { if (options.debugMultiFingerGestureWinner) { print('Multi Finger Gesture winner: Pinch Zoom'); } _yieldMultiFingerGestureWinner(MultiFingerGesture.pinchZoom, true); - } else if (hasIntRotate && currentRotation.abs() >= options.rotationThreshold) { + } else if (hasIntRotate && + currentRotation.abs() >= options.rotationThreshold) { if (options.debugMultiFingerGestureWinner) { print('Multi Finger Gesture winner: Rotate'); } _yieldMultiFingerGestureWinner(MultiFingerGesture.rotate, true); - } else if (hasIntPinchMove && (_focalStartLocal - focalOffset).distance >= options.pinchMoveThreshold) { + } else if (hasIntPinchMove && + (_focalStartLocal - focalOffset).distance >= + options.pinchMoveThreshold) { if (options.debugMultiFingerGestureWinner) { print('Multi Finger Gesture winner: Pinch Move'); } @@ -290,9 +311,12 @@ abstract class MapGestureMixin extends State with TickerProviderStat if (!hasGestureRace || _gestureWinner != MultiFingerGesture.none) { final gestures = _getMultiFingerGestureFlags(); - final hasGesturePinchMove = MultiFingerGesture.hasFlag(gestures, MultiFingerGesture.pinchMove); - final hasGesturePinchZoom = MultiFingerGesture.hasFlag(gestures, MultiFingerGesture.pinchZoom); - final hasGestureRotate = MultiFingerGesture.hasFlag(gestures, MultiFingerGesture.rotate); + final hasGesturePinchMove = MultiFingerGesture.hasFlag( + gestures, MultiFingerGesture.pinchMove); + final hasGesturePinchZoom = MultiFingerGesture.hasFlag( + gestures, MultiFingerGesture.pinchZoom); + final hasGestureRotate = + MultiFingerGesture.hasFlag(gestures, MultiFingerGesture.rotate); final hasMove = hasIntPinchMove && hasGesturePinchMove; final hasZoom = hasIntPinchZoom && hasGesturePinchZoom; @@ -303,7 +327,8 @@ abstract class MapGestureMixin extends State with TickerProviderStat if (hasMove || hasZoom) { double newZoom; if (hasZoom) { - newZoom = _getZoomForScale(_mapZoomStart, details.scale + _scaleCorrector); + newZoom = _getZoomForScale( + _mapZoomStart, details.scale + _scaleCorrector); if (!_pinchZoomStarted) { if (newZoom != _mapZoomStart) { @@ -344,9 +369,11 @@ abstract class MapGestureMixin extends State with TickerProviderStat if (_pinchMoveStarted) { final oldCenterPt = mapState.project(mapState.center, newZoom); - final localDistanceOffset = _rotateOffset(_lastFocalLocal - focalOffset); + final localDistanceOffset = + _rotateOffset(_lastFocalLocal - focalOffset); - final newCenterPt = oldCenterPt + _offsetToPoint(localDistanceOffset); + final newCenterPt = + oldCenterPt + _offsetToPoint(localDistanceOffset); newCenter = mapState.unproject(newCenterPt, newZoom); } else { newCenter = mapState.center; @@ -408,7 +435,8 @@ abstract class MapGestureMixin extends State with TickerProviderStat return; } - final eventSource = _dragMode ? MapEventSource.dragEnd : MapEventSource.multiFingerEnd; + final eventSource = + _dragMode ? MapEventSource.dragEnd : MapEventSource.multiFingerEnd; if (_rotationStarted) { _rotationStarted = false; @@ -432,7 +460,8 @@ abstract class MapGestureMixin extends State with TickerProviderStat ); } - var hasFling = InteractiveFlag.hasFlag(options.interactiveFlags, InteractiveFlag.flingAnimation); + var hasFling = InteractiveFlag.hasFlag( + options.interactiveFlags, InteractiveFlag.flingAnimation); var magnitude = details.velocity.pixelsPerSecond.distance; if (magnitude < _kMinFlingVelocity || !hasFling) { @@ -450,7 +479,9 @@ abstract class MapGestureMixin extends State with TickerProviderStat } var direction = details.velocity.pixelsPerSecond / magnitude; - var distance = (Offset.zero & Size(mapState.originalSize.x, mapState.originalSize.y)).shortestSide; + var distance = + (Offset.zero & Size(mapState.originalSize.x, mapState.originalSize.y)) + .shortestSide; var _flingOffset = _focalStartLocal - _lastFocalLocal; _flingAnimation = Tween( @@ -507,7 +538,8 @@ abstract class MapGestureMixin extends State with TickerProviderStat LatLng _offsetToCrs(Offset offset) { final focalStartPt = mapState.project(mapState.center, mapState.zoom); - final point = (_offsetToPoint(offset) - (mapState.originalSize / 2.0)).rotate(mapState.rotationRad); + final point = (_offsetToPoint(offset) - (mapState.originalSize / 2.0)) + .rotate(mapState.rotationRad); var newCenterPt = focalStartPt + point; return mapState.unproject(newCenterPt, mapState.zoom); @@ -523,23 +555,29 @@ abstract class MapGestureMixin extends State with TickerProviderStat closeFlingAnimationController(MapEventSource.doubleTap); closeDoubleTapController(MapEventSource.doubleTap); - if (InteractiveFlag.hasFlag(options.interactiveFlags, InteractiveFlag.doubleTapZoom)) { + if (InteractiveFlag.hasFlag( + options.interactiveFlags, InteractiveFlag.doubleTapZoom)) { final centerPos = _pointToOffset(mapState.originalSize) / 2.0; final newZoom = _getZoomForScale(mapState.zoom, 2.0); - final focalDelta = _getDoubleTapFocalDelta(centerPos, tapPosition.relative, newZoom - mapState.zoom); + final focalDelta = _getDoubleTapFocalDelta( + centerPos, tapPosition.relative, newZoom - mapState.zoom); final newCenter = _offsetToCrs(centerPos + focalDelta); _startDoubleTapAnimation(newZoom, newCenter); } } - Offset _getDoubleTapFocalDelta(Offset centerPos, Offset tapPos, double zoomDiff) { + Offset _getDoubleTapFocalDelta( + Offset centerPos, Offset tapPos, double zoomDiff) { final tapDelta = tapPos - centerPos; final zoomScale = 1 / math.pow(2, zoomDiff); // The map center offset within which double-tap won't cause zooming to // previously invisible area final maxDelta = centerPos * (1 - zoomScale); - final tappedOutExtent = tapDelta.dx.abs() > maxDelta.dx || tapDelta.dy.abs() > maxDelta.dy; - return tappedOutExtent ? _projectDeltaOnBounds(tapDelta, maxDelta) : tapDelta; + final tappedOutExtent = + tapDelta.dx.abs() > maxDelta.dx || tapDelta.dy.abs() > maxDelta.dy; + return tappedOutExtent + ? _projectDeltaOnBounds(tapDelta, maxDelta) + : tapDelta; } Offset _projectDeltaOnBounds(Offset delta, Offset maxDelta) { @@ -552,9 +590,10 @@ abstract class MapGestureMixin extends State with TickerProviderStat _doubleTapZoomAnimation = Tween(begin: mapState.zoom, end: newZoom) .chain(CurveTween(curve: Curves.fastOutSlowIn)) .animate(_doubleTapController); - _doubleTapCenterAnimation = LatLngTween(begin: mapState.center, end: newCenter) - .chain(CurveTween(curve: Curves.fastOutSlowIn)) - .animate(_doubleTapController); + _doubleTapCenterAnimation = + LatLngTween(begin: mapState.center, end: newCenter) + .chain(CurveTween(curve: Curves.fastOutSlowIn)) + .animate(_doubleTapController); _doubleTapController.forward(from: 0.0); } @@ -562,12 +601,16 @@ abstract class MapGestureMixin extends State with TickerProviderStat if (status == AnimationStatus.forward) { mapState.emitMapEvent( MapEventDoubleTapZoomStart( - center: mapState.center, zoom: mapState.zoom, source: MapEventSource.doubleTapZoomAnimationController), + center: mapState.center, + zoom: mapState.zoom, + source: MapEventSource.doubleTapZoomAnimationController), ); } else if (status == AnimationStatus.completed) { mapState.emitMapEvent( MapEventDoubleTapZoomEnd( - center: mapState.center, zoom: mapState.zoom, source: MapEventSource.doubleTapZoomAnimationController), + center: mapState.center, + zoom: mapState.zoom, + source: MapEventSource.doubleTapZoomAnimationController), ); } } @@ -585,7 +628,8 @@ abstract class MapGestureMixin extends State with TickerProviderStat _doubleTapHoldMaxDelay?.cancel(); if (++_tapUpCounter == 1) { - _doubleTapHoldMaxDelay = Timer(const Duration(milliseconds: 350), _resetDoubleTapHold); + _doubleTapHoldMaxDelay = + Timer(const Duration(milliseconds: 350), _resetDoubleTapHold); } } @@ -622,7 +666,9 @@ abstract class MapGestureMixin extends State with TickerProviderStat _flingAnimationStarted = false; mapState.emitMapEvent( MapEventFlingAnimationEnd( - center: mapState.center, zoom: mapState.zoom, source: MapEventSource.flingAnimationController), + center: mapState.center, + zoom: mapState.zoom, + source: MapEventSource.flingAnimationController), ); } } @@ -632,12 +678,14 @@ abstract class MapGestureMixin extends State with TickerProviderStat _flingAnimationStarted = true; mapState.emitMapEvent( MapEventFlingAnimationStart( - center: mapState.center, zoom: mapState.zoom, source: MapEventSource.flingAnimationController), + center: mapState.center, + zoom: mapState.zoom, + source: MapEventSource.flingAnimationController), ); } - var newCenterPoint = - mapState.project(_mapCenterStart) + _offsetToPoint(_flingAnimation.value).rotate(mapState.rotationRad); + var newCenterPoint = mapState.project(_mapCenterStart) + + _offsetToPoint(_flingAnimation.value).rotate(mapState.rotationRad); var newCenter = mapState.unproject(newCenterPoint); mapState.move( @@ -657,7 +705,8 @@ abstract class MapGestureMixin extends State with TickerProviderStat } double _getZoomForScale(double startZoom, double scale) { - var resultZoom = scale == 1.0 ? startZoom : startZoom + math.log(scale) / math.ln2; + var resultZoom = + scale == 1.0 ? startZoom : startZoom + math.log(scale) / math.ln2; return mapState.fitZoomToBounds(resultZoom); } diff --git a/lib/src/gestures/latlng_tween.dart b/lib/src/gestures/latlng_tween.dart index f1e376b15..e815b1b1c 100644 --- a/lib/src/gestures/latlng_tween.dart +++ b/lib/src/gestures/latlng_tween.dart @@ -1,6 +1,6 @@ import 'package:flutter/animation.dart'; import 'package:flutter/foundation.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; class LatLngTween extends Tween { LatLngTween({@required LatLng begin, @required LatLng end}) diff --git a/lib/src/gestures/map_events.dart b/lib/src/gestures/map_events.dart index 3ab472844..656ce8ee2 100644 --- a/lib/src/gestures/map_events.dart +++ b/lib/src/gestures/map_events.dart @@ -1,4 +1,4 @@ -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; enum MapEventSource { mapController, diff --git a/lib/src/layer/circle_layer.dart b/lib/src/layer/circle_layer.dart index 0f79d95f0..7bebde3dc 100644 --- a/lib/src/layer/circle_layer.dart +++ b/lib/src/layer/circle_layer.dart @@ -3,7 +3,7 @@ import 'dart:ui'; import 'package:flutter/widgets.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map/src/map/map.dart'; -import 'package:latlong/latlong.dart' hide Path; +import 'package:latlong2/latlong.dart' hide Path; class CircleLayerOptions extends LayerOptions { final List circles; diff --git a/lib/src/layer/marker_layer.dart b/lib/src/layer/marker_layer.dart index c23978fab..af95be987 100644 --- a/lib/src/layer/marker_layer.dart +++ b/lib/src/layer/marker_layer.dart @@ -2,7 +2,7 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map/src/core/bounds.dart'; import 'package:flutter_map/src/map/map.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; class MarkerLayerOptions extends LayerOptions { final List markers; diff --git a/lib/src/layer/polygon_layer.dart b/lib/src/layer/polygon_layer.dart index 40739677e..f46956b81 100644 --- a/lib/src/layer/polygon_layer.dart +++ b/lib/src/layer/polygon_layer.dart @@ -4,7 +4,7 @@ import 'dart:ui'; import 'package:flutter/widgets.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map/src/map/map.dart'; -import 'package:latlong/latlong.dart' hide Path; // conflict with Path from UI +import 'package:latlong2/latlong.dart' hide Path; // conflict with Path from UI class PolygonLayerOptions extends LayerOptions { final List polygons; diff --git a/lib/src/layer/polyline_layer.dart b/lib/src/layer/polyline_layer.dart index b5d286bae..8ab7ff5de 100644 --- a/lib/src/layer/polyline_layer.dart +++ b/lib/src/layer/polyline_layer.dart @@ -4,7 +4,7 @@ import 'dart:ui' as ui; import 'package:flutter/widgets.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map/src/map/map.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; class PolylineLayerOptions extends LayerOptions { final List polylines; diff --git a/lib/src/layer/tile_layer.dart b/lib/src/layer/tile_layer.dart index 8033578ce..fbbb3c0e4 100644 --- a/lib/src/layer/tile_layer.dart +++ b/lib/src/layer/tile_layer.dart @@ -11,7 +11,7 @@ import 'package:flutter_map/src/geo/crs/crs.dart'; import 'package:flutter_map/src/layer/tile_builder/tile_builder.dart'; import 'package:flutter_map/src/layer/tile_provider/tile_provider.dart'; import 'package:flutter_map/src/map/map.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; import 'package:tuple/tuple.dart'; import 'layer.dart'; diff --git a/lib/src/map/flutter_map_state.dart b/lib/src/map/flutter_map_state.dart index fa188b422..0b5503f80 100644 --- a/lib/src/map/flutter_map_state.dart +++ b/lib/src/map/flutter_map_state.dart @@ -21,7 +21,8 @@ class FlutterMapState extends MapGestureMixin { @override MapState mapState; - FlutterMapState(MapController mapController) : mapController = mapController ?? MapController(); + FlutterMapState(MapController mapController) + : mapController = mapController ?? MapController(); @override void didUpdateWidget(FlutterMap oldWidget) { @@ -69,7 +70,8 @@ class FlutterMapState extends MapGestureMixin { @override Widget build(BuildContext context) { _disposeStreamGroups(); - return LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) { + return LayoutBuilder( + builder: (BuildContext context, BoxConstraints constraints) { mapState.setOriginalSize(constraints.maxWidth, constraints.maxHeight); var size = mapState.size; @@ -104,8 +106,11 @@ class FlutterMapState extends MapGestureMixin { angle: mapState.rotationRad, child: Stack( children: [ - if (widget.children != null && widget.children.isNotEmpty) ...widget.children, - if (widget.layers != null && widget.layers.isNotEmpty) + if (widget.children != null && + widget.children.isNotEmpty) + ...widget.children, + if (widget.layers != null && + widget.layers.isNotEmpty) ...widget.layers.map( (layer) => _createLayer(layer, options.plugins), ) @@ -115,9 +120,11 @@ class FlutterMapState extends MapGestureMixin { ), Stack( children: [ - if (widget.nonRotatedChildren != null && widget.nonRotatedChildren.isNotEmpty) + if (widget.nonRotatedChildren != null && + widget.nonRotatedChildren.isNotEmpty) ...widget.nonRotatedChildren, - if (widget.nonRotatedLayers != null && widget.nonRotatedLayers.isNotEmpty) + if (widget.nonRotatedLayers != null && + widget.nonRotatedLayers.isNotEmpty) ...widget.nonRotatedLayers.map( (layer) => _createLayer(layer, options.plugins), ) @@ -140,7 +147,8 @@ class FlutterMapState extends MapGestureMixin { } } if (options is TileLayerOptions) { - return TileLayer(options: options, mapState: mapState, stream: _merge(options)); + return TileLayer( + options: options, mapState: mapState, stream: _merge(options)); } if (options is MarkerLayerOptions) { return MarkerLayer(options, mapState, _merge(options)); diff --git a/lib/src/map/map.dart b/lib/src/map/map.dart index a9c01bf50..b8f534d27 100644 --- a/lib/src/map/map.dart +++ b/lib/src/map/map.dart @@ -7,7 +7,7 @@ import 'package:flutter_map/src/core/bounds.dart'; import 'package:flutter_map/src/core/center_zoom.dart'; import 'package:flutter_map/src/core/point.dart'; import 'package:flutter_map/src/map/map_state_widget.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; class MapControllerImpl implements MapController { final Completer _readyCompleter = Completer(); diff --git a/pubspec.yaml b/pubspec.yaml index 13a93e1d7..b2f8c68cf 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,11 +11,14 @@ dependencies: flutter: sdk: flutter tuple: ^2.0.0 - latlong: ^0.6.1 + latlong2: ^0.8.0 positioned_tap_detector_2: ^1.0.0 transparent_image: ^2.0.0 async: ^2.1.0 - flutter_image: ^3.0.0 + flutter_image: + git: + url: "https://github.com/flutter/flutter_image" + ref: null-safety vector_math: ^2.0.0 proj4dart: ^1.0.4 meta: ^1.1.0 diff --git a/test/flutter_map_test.dart b/test/flutter_map_test.dart index 81a9d2118..1d7920157 100644 --- a/test/flutter_map_test.dart +++ b/test/flutter_map_test.dart @@ -4,7 +4,7 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:latlong/latlong.dart'; +import 'package:latlong2/latlong.dart'; import 'package:mockito/mockito.dart'; class MockHttpClientResponse extends Mock implements HttpClientResponse { From 049837ac6bb0a54393291a21738e80318525cf53 Mon Sep 17 00:00:00 2001 From: escamoteur Date: Mon, 22 Mar 2021 17:34:34 +0100 Subject: [PATCH 05/16] migrated to unsound null safety --- .packages | 2 +- .../lib/pages/animated_map_controller.dart | 2 +- example/lib/pages/custom_crs/custom_crs.dart | 9 +- example/lib/pages/interactive_test_page.dart | 6 +- example/lib/pages/live_location.dart | 23 +- example/lib/pages/map_controller.dart | 12 +- example/lib/pages/marker_anchor.dart | 2 +- example/lib/pages/moving_markers.dart | 6 +- example/lib/pages/plugin_api.dart | 4 +- .../lib/pages/scale_layer_plugin_option.dart | 36 +-- example/lib/pages/tile_builder_example.dart | 2 +- .../lib/pages/tile_loading_error_handle.dart | 2 +- example/lib/pages/widgets.dart | 6 +- .../lib/pages/zoombuttons_plugin_option.dart | 22 +- example/pubspec.yaml | 4 +- lib/flutter_map.dart | 94 +++---- lib/src/core/bounds.dart | 2 + lib/src/core/center_zoom.dart | 2 +- lib/src/core/point.dart | 6 +- lib/src/core/util.dart | 12 +- lib/src/geo/crs/crs.dart | 105 ++++---- lib/src/geo/latlng_bounds.dart | 78 +++--- lib/src/gestures/gestures.dart | 44 ++-- lib/src/gestures/latlng_tween.dart | 6 +- lib/src/gestures/map_events.dart | 119 +++++---- lib/src/layer/circle_layer.dart | 28 +- lib/src/layer/group_layer.dart | 10 +- lib/src/layer/layer.dart | 4 +- lib/src/layer/marker_layer.dart | 25 +- lib/src/layer/overlay_image_layer.dart | 14 +- lib/src/layer/polygon_layer.dart | 32 +-- lib/src/layer/polyline_layer.dart | 46 ++-- lib/src/layer/tile_layer.dart | 249 +++++++++--------- .../layer/tile_provider/tile_provider.dart | 6 +- lib/src/map/flutter_map_state.dart | 37 ++- lib/src/map/map.dart | 119 ++++----- lib/src/map/map_state_widget.dart | 8 +- pubspec.yaml | 7 +- test/flutter_map_test.dart | 6 +- 39 files changed, 615 insertions(+), 582 deletions(-) diff --git a/.packages b/.packages index c8543ee3b..2b85cc504 100644 --- a/.packages +++ b/.packages @@ -3,7 +3,7 @@ # # For more info see: https://dart.dev/go/dot-packages-deprecation # -# Generated by pub on 2021-03-22 10:22:41.937805. +# Generated by pub on 2021-03-22 15:51:25.463978. _fe_analyzer_shared:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/_fe_analyzer_shared-18.0.0/lib/ analyzer:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/analyzer-1.2.0/lib/ args:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/args-2.0.0/lib/ diff --git a/example/lib/pages/animated_map_controller.dart b/example/lib/pages/animated_map_controller.dart index f18074cb0..4deb55ce1 100644 --- a/example/lib/pages/animated_map_controller.dart +++ b/example/lib/pages/animated_map_controller.dart @@ -29,7 +29,7 @@ class AnimatedMapControllerPageState extends State static LatLng paris = LatLng(48.8566, 2.3522); static LatLng dublin = LatLng(53.3498, -6.2603); - MapController mapController; + late MapController mapController; @override void initState() { diff --git a/example/lib/pages/custom_crs/custom_crs.dart b/example/lib/pages/custom_crs/custom_crs.dart index 95dc14189..e124656de 100644 --- a/example/lib/pages/custom_crs/custom_crs.dart +++ b/example/lib/pages/custom_crs/custom_crs.dart @@ -14,18 +14,18 @@ class CustomCrsPage extends StatefulWidget { } class _CustomCrsPageState extends State { - Proj4Crs epsg3413CRS; + late Proj4Crs epsg3413CRS; - double maxZoom; + double? maxZoom; // Define start center proj4.Point point = proj4.Point(x: 65.05166470332148, y: -19.171744826394896); String initText = 'Map centered to'; - proj4.Projection epsg4326; + late proj4.Projection epsg4326; - proj4.Projection epsg3413; + late proj4.Projection epsg3413; @override void initState() { @@ -37,6 +37,7 @@ class _CustomCrsPageState extends State { // EPSG:3413 is a user-defined projection from a valid Proj4 definition string // From: http://epsg.io/3413, proj definition: http://epsg.io/3413.proj4 // Find Projection by name or define it if not exists + // TODO the warning here will go away as soon as proj4 is migrated to null safety epsg3413 = proj4.Projection('EPSG:3413') ?? proj4.Projection.add('EPSG:3413', '+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs'); diff --git a/example/lib/pages/interactive_test_page.dart b/example/lib/pages/interactive_test_page.dart index c3c684de4..7bc127622 100644 --- a/example/lib/pages/interactive_test_page.dart +++ b/example/lib/pages/interactive_test_page.dart @@ -16,12 +16,12 @@ class InteractiveTestPage extends StatefulWidget { } class _InteractiveTestPageState extends State { - MapController mapController; + late MapController mapController; // Enable pinchZoom and doubleTapZoomBy by default int flags = InteractiveFlag.pinchZoom | InteractiveFlag.doubleTapZoom; - StreamSubscription subscription; + late StreamSubscription subscription; @override void initState() { @@ -159,7 +159,7 @@ class _InteractiveTestPageState extends State { } return Text( - 'Current event: ${snapshot.data.runtimeType}\nSource: ${snapshot.data.source}', + 'Current event: ${snapshot.data.runtimeType}\nSource: ${snapshot.data!.source}', textAlign: TextAlign.center, ); }, diff --git a/example/lib/pages/live_location.dart b/example/lib/pages/live_location.dart index e5d14b017..1566131d1 100644 --- a/example/lib/pages/live_location.dart +++ b/example/lib/pages/live_location.dart @@ -14,13 +14,13 @@ class LiveLocationPage extends StatefulWidget { } class _LiveLocationPageState extends State { - LocationData _currentLocation; - MapController _mapController; + LocationData? _currentLocation; + late MapController _mapController; bool _liveUpdate = false; bool _permission = false; - String _serviceError = ''; + String? _serviceError = ''; var interActiveFlags = InteractiveFlag.all; @@ -35,11 +35,11 @@ class _LiveLocationPageState extends State { void initLocationService() async { await _locationService.changeSettings( - accuracy: LocationAccuracy.HIGH, + accuracy: LocationAccuracy.high, interval: 1000, ); - LocationData location; + LocationData? location; bool serviceEnabled; bool serviceRequestResult; @@ -48,13 +48,12 @@ class _LiveLocationPageState extends State { if (serviceEnabled) { var permission = await _locationService.requestPermission(); - _permission = permission == PermissionStatus.GRANTED; + _permission = permission == PermissionStatus.granted; if (_permission) { location = await _locationService.getLocation(); _currentLocation = location; - _locationService - .onLocationChanged() + _locationService.onLocationChanged .listen((LocationData result) async { if (mounted) { setState(() { @@ -63,8 +62,8 @@ class _LiveLocationPageState extends State { // If Live Update is enabled, move map center if (_liveUpdate) { _mapController.move( - LatLng(_currentLocation.latitude, - _currentLocation.longitude), + LatLng(_currentLocation!.latitude!, + _currentLocation!.longitude!), _mapController.zoom); } }); @@ -97,7 +96,7 @@ class _LiveLocationPageState extends State { // by default or store previous location value to show. if (_currentLocation != null) { currentLatLng = - LatLng(_currentLocation.latitude, _currentLocation.longitude); + LatLng(_currentLocation!.latitude!, _currentLocation!.longitude!); } else { currentLatLng = LatLng(0, 0); } @@ -125,7 +124,7 @@ class _LiveLocationPageState extends State { children: [ Padding( padding: EdgeInsets.only(top: 8.0, bottom: 8.0), - child: _serviceError.isEmpty + child: _serviceError!.isEmpty ? Text('This is a map that is showing ' '(${currentLatLng.latitude}, ${currentLatLng.longitude}).') : Text( diff --git a/example/lib/pages/map_controller.dart b/example/lib/pages/map_controller.dart index 676b642ee..433084247 100644 --- a/example/lib/pages/map_controller.dart +++ b/example/lib/pages/map_controller.dart @@ -21,7 +21,7 @@ class MapControllerPageState extends State { static LatLng paris = LatLng(48.8566, 2.3522); static LatLng dublin = LatLng(53.3498, -6.2603); - MapController mapController; + late MapController mapController; double rotation = 0.0; @override @@ -119,7 +119,7 @@ class MapControllerPageState extends State { Builder(builder: (BuildContext context) { return MaterialButton( onPressed: () { - final bounds = mapController.bounds; + final bounds = mapController.bounds!; ScaffoldMessenger.of(context).showSnackBar(SnackBar( content: Text( @@ -178,8 +178,8 @@ class MapControllerPageState extends State { class CurrentLocation extends StatefulWidget { const CurrentLocation({ - Key key, - @required this.mapController, + Key? key, + required this.mapController, }) : super(key: key); final MapController mapController; @@ -192,7 +192,7 @@ class _CurrentLocationState extends State { int _eventKey = 0; var icon = Icons.gps_not_fixed; - StreamSubscription mapEventSubscription; + late StreamSubscription mapEventSubscription; @override void initState() { @@ -229,7 +229,7 @@ class _CurrentLocationState extends State { try { var currentLocation = await location.getLocation(); var moved = widget.mapController.move( - LatLng(currentLocation.latitude, currentLocation.longitude), + LatLng(currentLocation.latitude!, currentLocation.longitude!), 18, id: _eventKey.toString(), ); diff --git a/example/lib/pages/marker_anchor.dart b/example/lib/pages/marker_anchor.dart index e59435561..8f5c4e482 100644 --- a/example/lib/pages/marker_anchor.dart +++ b/example/lib/pages/marker_anchor.dart @@ -13,7 +13,7 @@ class MarkerAnchorPage extends StatefulWidget { } class MarkerAnchorPageState extends State { - AnchorPos anchorPos; + late AnchorPos anchorPos; @override void initState() { diff --git a/example/lib/pages/moving_markers.dart b/example/lib/pages/moving_markers.dart index c561db011..f92046bf3 100644 --- a/example/lib/pages/moving_markers.dart +++ b/example/lib/pages/moving_markers.dart @@ -16,8 +16,8 @@ class MovingMarkersPage extends StatefulWidget { } class _MovingMarkersPageState extends State { - Marker _marker; - Timer _timer; + Marker? _marker; + late Timer _timer; int _markerIndex = 0; @override @@ -62,7 +62,7 @@ class _MovingMarkersPageState extends State { urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', subdomains: ['a', 'b', 'c']), - MarkerLayerOptions(markers: [_marker]) + MarkerLayerOptions(markers: [_marker!]) ], ), ), diff --git a/example/lib/pages/plugin_api.dart b/example/lib/pages/plugin_api.dart index da894a06b..7c87fe600 100644 --- a/example/lib/pages/plugin_api.dart +++ b/example/lib/pages/plugin_api.dart @@ -46,9 +46,9 @@ class PluginPage extends StatelessWidget { class MyCustomPluginOptions extends LayerOptions { final String text; MyCustomPluginOptions({ - Key key, + Key? key, this.text = '', - Stream rebuild, + Stream? rebuild, }) : super(key: key, rebuild: rebuild); } diff --git a/example/lib/pages/scale_layer_plugin_option.dart b/example/lib/pages/scale_layer_plugin_option.dart index 14bdf1201..99e83025f 100644 --- a/example/lib/pages/scale_layer_plugin_option.dart +++ b/example/lib/pages/scale_layer_plugin_option.dart @@ -8,18 +8,18 @@ import 'package:flutter_map/plugin_api.dart'; import './scalebar_utils.dart' as util; class ScaleLayerPluginOption extends LayerOptions { - TextStyle textStyle; + TextStyle? textStyle; Color lineColor; double lineWidth; - final EdgeInsets padding; + final EdgeInsets? padding; ScaleLayerPluginOption({ - Key key, + Key? key, this.textStyle, this.lineColor = Colors.white, this.lineWidth = 2, this.padding, - Stream rebuild, + Stream? rebuild, }) : super(key: key, rebuild: rebuild); } @@ -84,7 +84,7 @@ class ScaleLayer extends StatelessWidget { var displayDistance = distance > 999 ? '${(distance / 1000).toStringAsFixed(0)} km' : '${distance.toStringAsFixed(0)} m'; - double width = (end.x - start.x); + var width = (end.x - (start.x as double)); return CustomPaint( painter: ScalePainter( @@ -103,36 +103,38 @@ class ScalePainter extends CustomPainter { ScalePainter(this.width, this.text, {this.padding, this.textStyle, this.lineWidth, this.lineColor}); final double width; - final EdgeInsets padding; + final EdgeInsets? padding; final String text; - TextStyle textStyle; - double lineWidth; - Color lineColor; + TextStyle? textStyle; + double? lineWidth; + Color? lineColor; @override void paint(ui.Canvas canvas, ui.Size size) { final paint = Paint() - ..color = lineColor + ..color = lineColor! ..strokeCap = StrokeCap.square - ..strokeWidth = lineWidth; + ..strokeWidth = lineWidth!; var sizeForStartEnd = 4; - var paddingLeft = padding == null ? 0 : padding.left + sizeForStartEnd / 2; - var paddingTop = padding == null ? 0 : padding.top; + var paddingLeft = padding == null ? 0 : padding!.left + sizeForStartEnd / 2; + var paddingTop = padding == null ? 0 : padding!.top; var textSpan = TextSpan(style: textStyle, text: text); var textPainter = TextPainter(text: textSpan, textDirection: TextDirection.ltr)..layout(); - textPainter.paint(canvas, - Offset(width / 2 - textPainter.width / 2 + paddingLeft, paddingTop)); + textPainter.paint( + canvas, + Offset(width / 2 - textPainter.width / 2 + paddingLeft, + paddingTop as double)); paddingTop += textPainter.height; - var p1 = Offset(paddingLeft, sizeForStartEnd + paddingTop); + var p1 = Offset(paddingLeft as double, sizeForStartEnd + paddingTop); var p2 = Offset(paddingLeft + width, sizeForStartEnd + paddingTop); // draw start line canvas.drawLine(Offset(paddingLeft, paddingTop), Offset(paddingLeft, sizeForStartEnd + paddingTop), paint); // draw middle line - var middleX = width / 2 + paddingLeft - lineWidth / 2; + var middleX = width / 2 + paddingLeft - lineWidth! / 2; canvas.drawLine(Offset(middleX, paddingTop + sizeForStartEnd / 2), Offset(middleX, sizeForStartEnd + paddingTop), paint); // draw end line diff --git a/example/lib/pages/tile_builder_example.dart b/example/lib/pages/tile_builder_example.dart index 44cf6d2ca..bdf5f5b55 100644 --- a/example/lib/pages/tile_builder_example.dart +++ b/example/lib/pages/tile_builder_example.dart @@ -43,7 +43,7 @@ class _TileBuilderPageState extends State { tile.loaded == null ? 'Loading' // sometimes result is negative which shouldn't happen, abs() corrects it - : '${(tile.loaded.millisecond - tile.loadStarted.millisecond).abs()} ms', + : '${(tile.loaded!.millisecond - tile.loadStarted.millisecond).abs()} ms', style: Theme.of(context).textTheme.headline5, ), ], diff --git a/example/lib/pages/tile_loading_error_handle.dart b/example/lib/pages/tile_loading_error_handle.dart index 9ff249af9..03c2392c0 100644 --- a/example/lib/pages/tile_loading_error_handle.dart +++ b/example/lib/pages/tile_loading_error_handle.dart @@ -48,7 +48,7 @@ class _TileLoadingErrorHandleState extends State { tileProvider: NonCachingNetworkTileProvider(), errorTileCallback: (Tile tile, error) { if (_needLoadingError) { - WidgetsBinding.instance.addPostFrameCallback((_) { + WidgetsBinding.instance!.addPostFrameCallback((_) { ScaffoldMessenger.of(context).showSnackBar(SnackBar( duration: Duration(seconds: 1), content: Text( diff --git a/example/lib/pages/widgets.dart b/example/lib/pages/widgets.dart index 0c7da07f7..458a26a10 100644 --- a/example/lib/pages/widgets.dart +++ b/example/lib/pages/widgets.dart @@ -74,8 +74,8 @@ class MovingWithoutRefreshAllMapMarkers extends StatefulWidget { class _MovingWithoutRefreshAllMapMarkersState extends State { - Marker _marker; - Timer _timer; + Marker? _marker; + Timer? _timer; int _markerIndex = 0; @override @@ -99,7 +99,7 @@ class _MovingWithoutRefreshAllMapMarkersState @override Widget build(BuildContext context) { return MarkerLayerWidget( - options: MarkerLayerOptions(markers: [_marker]), + options: MarkerLayerOptions(markers: [_marker!]), ); } } diff --git a/example/lib/pages/zoombuttons_plugin_option.dart b/example/lib/pages/zoombuttons_plugin_option.dart index 9f27b7021..944324ce6 100644 --- a/example/lib/pages/zoombuttons_plugin_option.dart +++ b/example/lib/pages/zoombuttons_plugin_option.dart @@ -8,15 +8,15 @@ class ZoomButtonsPluginOption extends LayerOptions { final bool mini; final double padding; final Alignment alignment; - final Color zoomInColor; - final Color zoomInColorIcon; - final Color zoomOutColor; - final Color zoomOutColorIcon; + final Color? zoomInColor; + final Color? zoomInColorIcon; + final Color? zoomOutColor; + final Color? zoomOutColorIcon; final IconData zoomInIcon; final IconData zoomOutIcon; ZoomButtonsPluginOption({ - Key key, + Key? key, this.minZoom = 1, this.maxZoom = 18, this.mini = true, @@ -28,7 +28,7 @@ class ZoomButtonsPluginOption extends LayerOptions { this.zoomOutColor, this.zoomOutColorIcon, this.zoomOutIcon = Icons.zoom_out, - Stream rebuild, + Stream? rebuild, }) : super(key: key, rebuild: rebuild); } @@ -76,13 +76,14 @@ class ZoomButtons extends StatelessWidget { backgroundColor: zoomButtonsOpts.zoomInColor ?? Theme.of(context).primaryColor, onPressed: () { - var bounds = map.getBounds(); + var bounds = map.getBounds()!; var centerZoom = map.getBoundsCenterZoom(bounds, options); var zoom = centerZoom.zoom + 1; if (zoom < zoomButtonsOpts.minZoom) { zoom = zoomButtonsOpts.minZoom as double; } else { - map.move(centerZoom.center, zoom); + map.move(centerZoom.center, zoom, + source: MapEventSource.custom); } }, child: Icon(zoomButtonsOpts.zoomInIcon, @@ -98,13 +99,14 @@ class ZoomButtons extends StatelessWidget { backgroundColor: zoomButtonsOpts.zoomOutColor ?? Theme.of(context).primaryColor, onPressed: () { - var bounds = map.getBounds(); + var bounds = map.getBounds()!; var centerZoom = map.getBoundsCenterZoom(bounds, options); var zoom = centerZoom.zoom - 1; if (zoom > zoomButtonsOpts.maxZoom) { zoom = zoomButtonsOpts.maxZoom as double; } else { - map.move(centerZoom.center, zoom); + map.move(centerZoom.center, zoom, + source: MapEventSource.custom); } }, child: Icon(zoomButtonsOpts.zoomOutIcon, diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 1589dd712..1f6fcc7db 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: ">=2.7.0 <3.0.0" + sdk: '>=2.12.0 <3.0.0' dependencies: flutter: @@ -28,7 +28,7 @@ dependencies: cupertino_icons: ^1.0.2 flutter_map: path: ../ - location: ^2.5.0 + location: ^4.1.1 dev_dependencies: pedantic: ^1.11.0 diff --git a/lib/flutter_map.dart b/lib/flutter_map.dart index 6b0f17e36..4679b5ac1 100644 --- a/lib/flutter_map.dart +++ b/lib/flutter_map.dart @@ -66,18 +66,17 @@ class FlutterMap extends StatefulWidget { final MapOptions options; /// A [MapController], used to control the map. - final MapControllerImpl _mapController; + final MapControllerImpl? _mapController; FlutterMap({ - Key key, - @required this.options, + Key? key, + required this.options, this.layers = const [], this.nonRotatedLayers = const [], this.children = const [], this.nonRotatedChildren = const [], - MapController mapController, - }) : assert(options != null, 'MapOptions cannot be null!'), - _mapController = mapController, + MapController? mapController, + }) : _mapController = mapController as MapControllerImpl?, super(key: key); @override @@ -101,7 +100,7 @@ abstract class MapController { /// returns `true` if move was success (for example it won't be success if /// navigating to same place with same zoom or if center is out of bounds and /// [MapOptions.slideOnBoundaries] isn't enabled) - bool move(LatLng center, double zoom, {String id}); + bool move(LatLng center, double zoom, {String? id}); /// Sets the map rotation to a certain degrees angle (in decimal). /// @@ -112,16 +111,16 @@ abstract class MapController { /// /// returns `true` if rotate was success (it won't be success if rotate is /// same as the old rotate) - bool rotate(double degree, {String id}); + bool rotate(double degree, {String? id}); /// Calls [move] and [rotate] together however layers will rebuild just once /// instead of twice MoveAndRotateResult moveAndRotate(LatLng center, double zoom, double degree, - {String id}); + {String? id}); /// Fits the map bounds. Optional constraints can be defined /// through the [options] parameter. - void fitBounds(LatLngBounds bounds, {FitBoundsOptions options}); + void fitBounds(LatLngBounds bounds, {FitBoundsOptions? options}); bool get ready; @@ -129,7 +128,7 @@ abstract class MapController { LatLng get center; - LatLngBounds get bounds; + LatLngBounds? get bounds; double get zoom; @@ -219,38 +218,38 @@ class MapOptions { /// gestures will take effect see [MultiFingerGesture] for custom settings final int pinchMoveWinGestures; - final double minZoom; - final double maxZoom; + final double? minZoom; + final double? maxZoom; @deprecated final bool debug; // TODO no usage outside of constructor. Marked for removal? @Deprecated('use interactiveFlags instead') - final bool interactive; + final bool? interactive; /// see [InteractiveFlag] for custom settings final int interactiveFlags; final bool allowPanning; - final TapCallback onTap; - final LongPressCallback onLongPress; - final PositionCallback onPositionChanged; + final TapCallback? onTap; + final LongPressCallback? onLongPress; + final PositionCallback? onPositionChanged; final List plugins; final bool slideOnBoundaries; - final Size screenSize; + final Size? screenSize; final bool adaptiveBoundaries; - final MapController controller; + final MapController? controller; final LatLng center; - final LatLngBounds bounds; + final LatLngBounds? bounds; final FitBoundsOptions boundsOptions; - final LatLng swPanBoundary; - final LatLng nePanBoundary; + final LatLng? swPanBoundary; + final LatLng? nePanBoundary; - _SafeArea _safeAreaCache; - double _safeAreaZoom; + _SafeArea? _safeAreaCache; + double? _safeAreaZoom; MapOptions({ this.crs = const Epsg3857(), - LatLng center, + LatLng? center, this.bounds, this.boundsOptions = const FitBoundsOptions(), this.zoom = 13.0, @@ -272,7 +271,7 @@ class MapOptions { // TODO: Change when [interactive] is removed. // Change this to [this.interactiveFlags = InteractiveFlag.all] and remove // [interactiveFlags] from initializer list - int interactiveFlags, + int? interactiveFlags, this.allowPanning = true, this.onTap, this.onLongPress, @@ -300,18 +299,18 @@ class MapOptions { } //if there is a pan boundary, do not cross - bool isOutOfBounds(LatLng center) { + bool isOutOfBounds(LatLng? center) { if (adaptiveBoundaries) { - return !_safeArea.contains(center); + return !_safeArea!.contains(center); } if (swPanBoundary != null && nePanBoundary != null) { if (center == null) { return true; - } else if (center.latitude < swPanBoundary.latitude || - center.latitude > nePanBoundary.latitude) { + } else if (center.latitude < swPanBoundary!.latitude || + center.latitude > nePanBoundary!.latitude) { return true; - } else if (center.longitude < swPanBoundary.longitude || - center.longitude > nePanBoundary.longitude) { + } else if (center.longitude < swPanBoundary!.longitude || + center.longitude > nePanBoundary!.longitude) { return true; } } @@ -320,25 +319,26 @@ class MapOptions { LatLng containPoint(LatLng point, LatLng fallback) { if (adaptiveBoundaries) { - return _safeArea.containPoint(point, fallback); + return _safeArea!.containPoint(point, fallback); } else { return LatLng( - point.latitude.clamp(swPanBoundary.latitude, nePanBoundary.latitude), - point.longitude.clamp(swPanBoundary.longitude, nePanBoundary.longitude), + point.latitude.clamp(swPanBoundary!.latitude, nePanBoundary!.latitude), + point.longitude + .clamp(swPanBoundary!.longitude, nePanBoundary!.longitude), ); } } - _SafeArea get _safeArea { + _SafeArea? get _safeArea { final controllerZoom = _getControllerZoom(); if (controllerZoom != _safeAreaZoom || _safeAreaCache == null) { _safeAreaZoom = controllerZoom; final halfScreenHeight = _calculateScreenHeightInDegrees() / 2; final halfScreenWidth = _calculateScreenWidthInDegrees() / 2; - final southWestLatitude = swPanBoundary.latitude + halfScreenHeight; - final southWestLongitude = swPanBoundary.longitude + halfScreenWidth; - final northEastLatitude = nePanBoundary.latitude - halfScreenHeight; - final northEastLongitude = nePanBoundary.longitude - halfScreenWidth; + final southWestLatitude = swPanBoundary!.latitude + halfScreenHeight; + final southWestLongitude = swPanBoundary!.longitude + halfScreenWidth; + final northEastLatitude = nePanBoundary!.latitude - halfScreenHeight; + final northEastLongitude = nePanBoundary!.longitude - halfScreenWidth; _safeAreaCache = _SafeArea( LatLng( southWestLatitude, @@ -356,19 +356,19 @@ class MapOptions { double _calculateScreenWidthInDegrees() { final zoom = _getControllerZoom(); final degreesPerPixel = 360 / pow(2, zoom + 8); - return screenSize.width * degreesPerPixel; + return screenSize!.width * degreesPerPixel; } double _calculateScreenHeightInDegrees() => - screenSize.height * 170.102258 / pow(2, _getControllerZoom() + 8); + screenSize!.height * 170.102258 / pow(2, _getControllerZoom() + 8); - double _getControllerZoom() => controller.ready ? controller.zoom : zoom; + double _getControllerZoom() => controller!.ready ? controller!.zoom : zoom; } class FitBoundsOptions { final EdgeInsets padding; final double maxZoom; - final double zoom; + final double? zoom; const FitBoundsOptions({ this.padding = const EdgeInsets.all(0.0), @@ -379,9 +379,9 @@ class FitBoundsOptions { /// Position's type for [PositionCallback]. class MapPosition { - final LatLng center; - final LatLngBounds bounds; - final double zoom; + final LatLng? center; + final LatLngBounds? bounds; + final double? zoom; final bool hasGesture; MapPosition({this.center, this.bounds, this.zoom, this.hasGesture = false}); diff --git a/lib/src/core/bounds.dart b/lib/src/core/bounds.dart index 5111ac3d7..c77f729ba 100644 --- a/lib/src/core/bounds.dart +++ b/lib/src/core/bounds.dart @@ -1,4 +1,5 @@ import 'dart:math' as math; + import 'package:flutter_map/src/core/point.dart'; /// Rectangular bound delimited by orthogonal lines passing through two @@ -20,6 +21,7 @@ class Bounds { Bounds extend(CustomPoint point) { CustomPoint newMin; CustomPoint newMax; + // TODO had this any functionality before? if (min == null && max == null) { newMin = point; newMax = point; diff --git a/lib/src/core/center_zoom.dart b/lib/src/core/center_zoom.dart index 334abf8dc..527768d47 100644 --- a/lib/src/core/center_zoom.dart +++ b/lib/src/core/center_zoom.dart @@ -3,5 +3,5 @@ import 'package:latlong2/latlong.dart'; class CenterZoom { final LatLng center; final double zoom; - CenterZoom({this.center, this.zoom}); + CenterZoom({required this.center, required this.zoom}); } diff --git a/lib/src/core/point.dart b/lib/src/core/point.dart index de28370b1..604c68993 100644 --- a/lib/src/core/point.dart +++ b/lib/src/core/point.dart @@ -1,7 +1,7 @@ import 'dart:math' as math; class CustomPoint extends math.Point { - const CustomPoint(num x, num y) : super(x, y); + const CustomPoint(num x, num y) : super(x as T, y as T); CustomPoint operator /(num /*T|int*/ factor) { return CustomPoint(x / factor, y / factor); @@ -39,8 +39,8 @@ class CustomPoint extends math.Point { } CustomPoint round() { - var x = this.x is double ? this.x.round() : this.x; - var y = this.y is double ? this.y.round() : this.y; + num x = this.x is double ? this.x.round() : this.x; + num y = this.y is double ? this.y.round() : this.y; return CustomPoint(x, y); } diff --git a/lib/src/core/util.dart b/lib/src/core/util.dart index 004a281b7..c670a459c 100644 --- a/lib/src/core/util.dart +++ b/lib/src/core/util.dart @@ -9,7 +9,7 @@ var _templateRe = RegExp(r'\{ *([\w_-]+) *\}'); /// Throws an [Exception] if any placeholder remains unresolved. String template(String str, Map data) { return str.replaceAllMapped(_templateRe, (Match match) { - var value = data[match.group(1)]; + var value = data[match.group(1)!]; if (value == null) { throw Exception('No value provided for variable ${match.group(1)}'); } else { @@ -18,7 +18,7 @@ String template(String str, Map data) { }); } -double wrapNum(double x, Tuple2 range, [bool includeMax]) { +double wrapNum(double x, Tuple2 range, [bool? includeMax]) { var max = range.item2; var min = range.item1; var d = max - min; @@ -26,18 +26,18 @@ double wrapNum(double x, Tuple2 range, [bool includeMax]) { } StreamTransformer throttleStreamTransformerWithTrailingCall( - Duration duration) { - Timer timer; + Duration? duration) { + Timer? timer; T recentData; var trailingCall = false; - void Function(T data, EventSink sink) throttleHandler; + late void Function(T data, EventSink sink) throttleHandler; throttleHandler = (T data, EventSink sink) { recentData = data; if (timer == null) { sink.add(recentData); - timer = Timer(duration, () { + timer = Timer(duration!, () { timer = null; if (trailingCall) { diff --git a/lib/src/geo/crs/crs.dart b/lib/src/geo/crs/crs.dart index e66e14de9..d6b3578bb 100644 --- a/lib/src/geo/crs/crs.dart +++ b/lib/src/geo/crs/crs.dart @@ -34,7 +34,7 @@ abstract class Crs { } /// Converts a map point to the sphere coordinate (at a certain zoom). - LatLng pointToLatLng(CustomPoint point, double zoom) { + LatLng? pointToLatLng(CustomPoint point, double zoom) { var scale = this.scale(zoom); var untransformedPoint = transformation.untransform(point, scale.toDouble()); @@ -56,10 +56,10 @@ abstract class Crs { } /// Rescales the bounds to a given zoom value. - Bounds getProjectedBounds(double zoom) { + Bounds? getProjectedBounds(double zoom) { if (infinite) return null; - var b = projection.bounds; + var b = projection.bounds!; var s = scale(zoom); var min = transformation.transform(b.min, s.toDouble()); var max = transformation.transform(b.max, s.toDouble()); @@ -68,9 +68,9 @@ abstract class Crs { bool get infinite; - Tuple2 get wrapLng; + Tuple2? get wrapLng; - Tuple2 get wrapLat; + Tuple2? get wrapLat; } // Custom CRS for non geographical maps @@ -93,10 +93,10 @@ class CrsSimple extends Crs { bool get infinite => false; @override - Tuple2 get wrapLat => null; + Tuple2? get wrapLat => null; @override - Tuple2 get wrapLng => null; + Tuple2? get wrapLng => null; } abstract class Earth extends Crs { @@ -107,7 +107,7 @@ abstract class Earth extends Crs { final Tuple2 wrapLng = const Tuple2(-180.0, 180.0); @override - final Tuple2 wrapLat = null; + final Tuple2? wrapLat = null; const Earth() : super(); } @@ -167,42 +167,37 @@ class Proj4Crs extends Crs { final bool infinite; @override - final Tuple2 wrapLat = null; + final Tuple2? wrapLat = null; @override - final Tuple2 wrapLng = null; + final Tuple2? wrapLng = null; - final List _transformations; + final List? _transformations; final List _scales; Proj4Crs._({ - @required this.code, - @required this.projection, - @required this.transformation, - @required this.infinite, - @required List transformations, - @required List scales, - }) : assert(null != code), - assert(null != projection), - assert(null != transformation || null != transformations), - assert(null != infinite), - assert(null != scales), - _transformations = transformations, + required this.code, + required this.projection, + required this.transformation, + required this.infinite, + List? transformations, + required List scales, + }) : _transformations = transformations, _scales = scales; factory Proj4Crs.fromFactory({ - @required String code, - @required proj4.Projection proj4Projection, - Transformation transformation, - List origins, - Bounds bounds, - List scales, - List resolutions, + required String code, + required proj4.Projection proj4Projection, + Transformation? transformation, + List? origins, + Bounds? bounds, + List? scales, + List? resolutions, }) { final projection = _Proj4Projection(proj4Projection: proj4Projection, bounds: bounds); - List transformations; + List? transformations; var infinite = null == bounds; List finalScales; @@ -231,7 +226,7 @@ class Proj4Crs extends Crs { return Proj4Crs._( code: code, projection: projection, - transformation: transformation, + transformation: transformation!, infinite: infinite, transformations: transformations, scales: finalScales, @@ -255,7 +250,7 @@ class Proj4Crs extends Crs { /// Converts a map point to the sphere coordinate (at a certain zoom). @override - LatLng pointToLatLng(CustomPoint point, double zoom) { + LatLng? pointToLatLng(CustomPoint point, double zoom) { var scale = this.scale(zoom); var transformation = _getTransformationByZoom(zoom); @@ -270,10 +265,10 @@ class Proj4Crs extends Crs { /// Rescales the bounds to a given zoom value. @override - Bounds getProjectedBounds(double zoom) { + Bounds? getProjectedBounds(double zoom) { if (infinite) return null; - var b = projection.bounds; + var b = projection.bounds!; var s = scale(zoom); var transformation = _getTransformationByZoom(zoom); @@ -304,17 +299,19 @@ class Proj4Crs extends Crs { num zoom(double scale) { // Find closest number in _scales, down var downScale = _closestElement(_scales, scale); + if (downScale == null) { + return double.negativeInfinity; + } var downZoom = _scales.indexOf(downScale); // Check if scale is downScale => return array index if (scale == downScale) { return downZoom; } - if (downScale == null) { - return double.negativeInfinity; - } // Interpolate var nextZoom = downZoom + 1; var nextScale = _scales[nextZoom]; + + /// TODO would a null scale be valid if (nextScale == null) { return double.infinity; } @@ -323,8 +320,8 @@ class Proj4Crs extends Crs { } /// Get the closest lowest element in an array - double _closestElement(List array, double element) { - double low; + double? _closestElement(List array, double element) { + double? low; for (var i = array.length - 1; i >= 0; i--) { var curr = array[i]; @@ -342,24 +339,24 @@ class Proj4Crs extends Crs { } var iZoom = zoom.round(); - var lastIdx = _transformations.length - 1; + var lastIdx = _transformations!.length - 1; - return _transformations[iZoom > lastIdx ? lastIdx : iZoom]; + return _transformations![iZoom > lastIdx ? lastIdx : iZoom]; } } abstract class Projection { const Projection(); - Bounds get bounds; + Bounds? get bounds; CustomPoint project(LatLng latlng); LatLng unproject(CustomPoint point); double _inclusive(Comparable start, Comparable end, double value) { - if (value.compareTo(start) < 0) return start; - if (value.compareTo(end) > 0) return end; + if (value.compareTo(start as num) < 0) return start as double; + if (value.compareTo(end as num) > 0) return end as double; return value; } @@ -391,7 +388,8 @@ class _LonLat extends Projection { @override LatLng unproject(CustomPoint point) { - return LatLng(inclusiveLat(point.y), inclusiveLng(point.x)); + return LatLng( + inclusiveLat(point.y as double), inclusiveLng(point.x as double)); } } @@ -436,13 +434,12 @@ class _Proj4Projection extends Projection { final proj4.Projection proj4Projection; @override - final Bounds bounds; + final Bounds? bounds; _Proj4Projection({ - @required this.proj4Projection, - @required this.bounds, - }) : assert(null != proj4Projection), - epsg4326 = proj4.Projection.WGS84; + required this.proj4Projection, + this.bounds, + }) : epsg4326 = proj4.Projection.WGS84; @override CustomPoint project(LatLng latlng) { @@ -455,7 +452,7 @@ class _Proj4Projection extends Projection { @override LatLng unproject(CustomPoint point) { var point2 = proj4Projection.transform( - epsg4326, proj4.Point(x: point.x, y: point.y)); + epsg4326, proj4.Point(x: point.x as double, y: point.y as double)); return LatLng(inclusiveLat(point2.y), inclusiveLng(point2.x)); } @@ -469,14 +466,14 @@ class Transformation { const Transformation(this.a, this.b, this.c, this.d); - CustomPoint transform(CustomPoint point, double scale) { + CustomPoint transform(CustomPoint point, double? scale) { scale ??= 1.0; var x = scale * (a * point.x + b); var y = scale * (c * point.y + d); return CustomPoint(x, y); } - CustomPoint untransform(CustomPoint point, double scale) { + CustomPoint untransform(CustomPoint point, double? scale) { scale ??= 1.0; var x = (point.x / scale - b) / a; var y = (point.y / scale - d) / c; diff --git a/lib/src/geo/latlng_bounds.dart b/lib/src/geo/latlng_bounds.dart index 7e0f0a0e7..b27e8b324 100644 --- a/lib/src/geo/latlng_bounds.dart +++ b/lib/src/geo/latlng_bounds.dart @@ -3,20 +3,20 @@ import 'dart:math' as math; import 'package:latlong2/latlong.dart'; class LatLngBounds { - LatLng _sw; - LatLng _ne; + LatLng? _sw; + LatLng? _ne; - LatLngBounds([LatLng corner1, LatLng corner2]) { + LatLngBounds([LatLng? corner1, LatLng? corner2]) { extend(corner1); extend(corner2); } LatLngBounds.fromPoints(List points) { - if (points != null && points.isNotEmpty) { - num minX; - num maxX; - num minY; - num maxY; + if (points.isNotEmpty) { + num? minX; + num? maxX; + num? minY; + num? maxY; for (var point in points) { num x = point.longitudeInRad; @@ -39,12 +39,12 @@ class LatLngBounds { } } - _sw = LatLng(radianToDeg(minY), radianToDeg(minX)); - _ne = LatLng(radianToDeg(maxY), radianToDeg(maxX)); + _sw = LatLng(radianToDeg(minY as double), radianToDeg(minX as double)); + _ne = LatLng(radianToDeg(maxY as double), radianToDeg(maxX as double)); } } - void extend(LatLng latlng) { + void extend(LatLng? latlng) { if (latlng == null) { return; } @@ -55,25 +55,25 @@ class LatLngBounds { _extend(bounds._sw, bounds._ne); } - void _extend(LatLng sw2, LatLng ne2) { + void _extend(LatLng? sw2, LatLng? ne2) { if (_sw == null && _ne == null) { - _sw = LatLng(sw2.latitude, sw2.longitude); - _ne = LatLng(ne2.latitude, ne2.longitude); + _sw = LatLng(sw2!.latitude, sw2.longitude); + _ne = LatLng(ne2!.latitude, ne2.longitude); } else { - _sw.latitude = math.min(sw2.latitude, _sw.latitude); - _sw.longitude = math.min(sw2.longitude, _sw.longitude); - _ne.latitude = math.max(ne2.latitude, _ne.latitude); - _ne.longitude = math.max(ne2.longitude, _ne.longitude); + _sw!.latitude = math.min(sw2!.latitude, _sw!.latitude); + _sw!.longitude = math.min(sw2.longitude, _sw!.longitude); + _ne!.latitude = math.max(ne2!.latitude, _ne!.latitude); + _ne!.longitude = math.max(ne2.longitude, _ne!.longitude); } } - double get west => southWest.longitude; - double get south => southWest.latitude; - double get east => northEast.longitude; - double get north => northEast.latitude; + double get west => southWest!.longitude; + double get south => southWest!.latitude; + double get east => northEast!.longitude; + double get north => northEast!.latitude; - LatLng get southWest => _sw; - LatLng get northEast => _ne; + LatLng? get southWest => _sw; + LatLng? get northEast => _ne; LatLng get northWest => LatLng(north, west); LatLng get southEast => LatLng(south, east); @@ -81,7 +81,7 @@ class LatLngBounds { return _sw != null && _ne != null; } - bool contains(LatLng point) { + bool contains(LatLng? point) { if (!isValid) { return false; } @@ -91,34 +91,34 @@ class LatLngBounds { } bool containsBounds(LatLngBounds bounds) { - var sw2 = bounds._sw; + var sw2 = bounds._sw!; var ne2 = bounds._ne; - return (sw2.latitude >= _sw.latitude) && - (ne2.latitude <= _ne.latitude) && - (sw2.longitude >= _sw.longitude) && - (ne2.longitude <= _ne.longitude); + return (sw2.latitude >= _sw!.latitude) && + (ne2!.latitude <= _ne!.latitude) && + (sw2.longitude >= _sw!.longitude) && + (ne2.longitude <= _ne!.longitude); } - bool isOverlapping(LatLngBounds bounds) { + bool isOverlapping(LatLngBounds? bounds) { if (!isValid) { return false; } // check if bounding box rectangle is outside the other, if it is then it's // considered not overlapping - if (_sw.latitude > bounds._ne.latitude || - _ne.latitude < bounds._sw.latitude || - _ne.longitude < bounds._sw.longitude || - _sw.longitude > bounds._ne.longitude) { + if (_sw!.latitude > bounds!._ne!.latitude || + _ne!.latitude < bounds._sw!.latitude || + _ne!.longitude < bounds._sw!.longitude || + _sw!.longitude > bounds._ne!.longitude) { return false; } return true; } void pad(double bufferRatio) { - var heightBuffer = (_sw.latitude - _ne.latitude).abs() * bufferRatio; - var widthBuffer = (_sw.longitude - _ne.longitude).abs() * bufferRatio; + var heightBuffer = (_sw!.latitude - _ne!.latitude).abs() * bufferRatio; + var widthBuffer = (_sw!.longitude - _ne!.longitude).abs() * bufferRatio; - _sw = LatLng(_sw.latitude - heightBuffer, _sw.longitude - widthBuffer); - _ne = LatLng(_ne.latitude + heightBuffer, _ne.longitude + widthBuffer); + _sw = LatLng(_sw!.latitude - heightBuffer, _sw!.longitude - widthBuffer); + _ne = LatLng(_ne!.latitude + heightBuffer, _ne!.longitude + widthBuffer); } } diff --git a/lib/src/gestures/gestures.dart b/lib/src/gestures/gestures.dart index 30cf88d53..bc81176a5 100644 --- a/lib/src/gestures/gestures.dart +++ b/lib/src/gestures/gestures.dart @@ -30,25 +30,25 @@ abstract class MapGestureMixin extends State // Helps to reset ScaleUpdateDetails.scale back to 1.0 when a multi finger // gesture wins - double _scaleCorrector; + late double _scaleCorrector; - double _lastRotation; - double _lastScale; - Offset _lastFocalLocal; + late double _lastRotation; + late double _lastScale; + late Offset _lastFocalLocal; - LatLng _mapCenterStart; - double _mapZoomStart; - Offset _focalStartLocal; + late LatLng _mapCenterStart; + late double _mapZoomStart; + late Offset _focalStartLocal; - AnimationController _flingController; - Animation _flingAnimation; + late AnimationController _flingController; + late Animation _flingAnimation; - AnimationController _doubleTapController; - Animation _doubleTapZoomAnimation; - Animation _doubleTapCenterAnimation; + late AnimationController _doubleTapController; + late Animation _doubleTapZoomAnimation; + late Animation _doubleTapCenterAnimation; int _tapUpCounter = 0; - Timer _doubleTapHoldMaxDelay; + Timer? _doubleTapHoldMaxDelay; @override FlutterMap get widget; @@ -161,7 +161,7 @@ abstract class MapGestureMixin extends State } } - int _getMultiFingerGestureFlags({int gestureWinner, MapOptions mapOptions}) { + int _getMultiFingerGestureFlags({int? gestureWinner, MapOptions? mapOptions}) { gestureWinner ??= _gestureWinner; mapOptions ??= options; @@ -480,7 +480,7 @@ abstract class MapGestureMixin extends State var direction = details.velocity.pixelsPerSecond / magnitude; var distance = - (Offset.zero & Size(mapState.originalSize.x, mapState.originalSize.y)) + (Offset.zero & Size(mapState.originalSize!.x as double, mapState.originalSize!.y as double)) .shortestSide; var _flingOffset = _focalStartLocal - _lastFocalLocal; @@ -498,10 +498,10 @@ abstract class MapGestureMixin extends State closeFlingAnimationController(MapEventSource.tap); closeDoubleTapController(MapEventSource.tap); - final latlng = _offsetToCrs(position.relative); + final latlng = _offsetToCrs(position.relative!); if (options.onTap != null) { // emit the event - options.onTap(latlng); + options.onTap!(latlng); } mapState.emitMapEvent( @@ -520,10 +520,10 @@ abstract class MapGestureMixin extends State closeFlingAnimationController(MapEventSource.longPress); closeDoubleTapController(MapEventSource.longPress); - final latlng = _offsetToCrs(position.relative); + final latlng = _offsetToCrs(position.relative!); if (options.onLongPress != null) { // emit the event - options.onLongPress(latlng); + options.onLongPress!(latlng); } mapState.emitMapEvent( @@ -538,7 +538,7 @@ abstract class MapGestureMixin extends State LatLng _offsetToCrs(Offset offset) { final focalStartPt = mapState.project(mapState.center, mapState.zoom); - final point = (_offsetToPoint(offset) - (mapState.originalSize / 2.0)) + final point = (_offsetToPoint(offset) - (mapState.originalSize! / 2.0)) .rotate(mapState.rotationRad); var newCenterPt = focalStartPt + point; @@ -557,10 +557,10 @@ abstract class MapGestureMixin extends State if (InteractiveFlag.hasFlag( options.interactiveFlags, InteractiveFlag.doubleTapZoom)) { - final centerPos = _pointToOffset(mapState.originalSize) / 2.0; + final centerPos = _pointToOffset(mapState.originalSize!) / 2.0; final newZoom = _getZoomForScale(mapState.zoom, 2.0); final focalDelta = _getDoubleTapFocalDelta( - centerPos, tapPosition.relative, newZoom - mapState.zoom); + centerPos, tapPosition.relative!, newZoom - mapState.zoom); final newCenter = _offsetToCrs(centerPos + focalDelta); _startDoubleTapAnimation(newZoom, newCenter); } diff --git a/lib/src/gestures/latlng_tween.dart b/lib/src/gestures/latlng_tween.dart index e815b1b1c..65d8ac746 100644 --- a/lib/src/gestures/latlng_tween.dart +++ b/lib/src/gestures/latlng_tween.dart @@ -3,12 +3,12 @@ import 'package:flutter/foundation.dart'; import 'package:latlong2/latlong.dart'; class LatLngTween extends Tween { - LatLngTween({@required LatLng begin, @required LatLng end}) + LatLngTween({required LatLng begin, required LatLng end}) : super(begin: begin, end: end); @override LatLng lerp(double t) => LatLng( - begin.latitude + (end.latitude - begin.latitude) * t, - begin.longitude + (end.longitude - begin.longitude) * t, + begin!.latitude + (end!.latitude - begin!.latitude) * t, + begin!.longitude + (end!.longitude - begin!.longitude) * t, ); } diff --git a/lib/src/gestures/map_events.dart b/lib/src/gestures/map_events.dart index 656ce8ee2..084b8c178 100644 --- a/lib/src/gestures/map_events.dart +++ b/lib/src/gestures/map_events.dart @@ -15,6 +15,9 @@ enum MapEventSource { flingAnimationController, doubleTapZoomAnimationController, interactiveFlagsChanged, + fitBounds, + initialization, + custom } abstract class MapEvent { @@ -25,7 +28,7 @@ abstract class MapEvent { // current zoom when event is emitted final double zoom; - MapEvent({this.source, this.center, this.zoom}); + MapEvent({required this.source, required this.center, required this.zoom}); } abstract class MapEventWithMove extends MapEvent { @@ -33,11 +36,11 @@ abstract class MapEventWithMove extends MapEvent { final double targetZoom; MapEventWithMove({ - this.targetCenter, - this.targetZoom, - MapEventSource source, - LatLng center, - double zoom, + required this.targetCenter, + required this.targetZoom, + required MapEventSource source, + required LatLng center, + required double zoom, }) : super(source: source, center: center, zoom: zoom); } @@ -45,10 +48,10 @@ class MapEventTap extends MapEvent { final LatLng tapPosition; MapEventTap({ - this.tapPosition, - MapEventSource source, - LatLng center, - double zoom, + required this.tapPosition, + required MapEventSource source, + required LatLng center, + required double zoom, }) : super(source: source, center: center, zoom: zoom); } @@ -56,23 +59,23 @@ class MapEventLongPress extends MapEvent { final LatLng tapPosition; MapEventLongPress({ - this.tapPosition, - MapEventSource source, - LatLng center, - double zoom, + required this.tapPosition, + required MapEventSource source, + required LatLng center, + required double zoom, }) : super(source: source, center: center, zoom: zoom); } class MapEventMove extends MapEventWithMove { - final String id; + final String? id; MapEventMove({ this.id, - LatLng targetCenter, - double targetZoom, - MapEventSource source, - LatLng center, - double zoom, + required LatLng targetCenter, + required double targetZoom, + required MapEventSource source, + required LatLng center, + required double zoom, }) : super( targetCenter: targetCenter, targetZoom: targetZoom, @@ -83,22 +86,28 @@ class MapEventMove extends MapEventWithMove { } class MapEventMoveStart extends MapEvent { - MapEventMoveStart({MapEventSource source, LatLng center, double zoom}) + MapEventMoveStart( + {required MapEventSource source, + required LatLng center, + required double zoom}) : super(source: source, center: center, zoom: zoom); } class MapEventMoveEnd extends MapEvent { - MapEventMoveEnd({MapEventSource source, LatLng center, double zoom}) + MapEventMoveEnd( + {required MapEventSource source, + required LatLng center, + required double zoom}) : super(source: source, center: center, zoom: zoom); } class MapEventFlingAnimation extends MapEventWithMove { MapEventFlingAnimation({ - LatLng targetCenter, - double targetZoom, - MapEventSource source, - LatLng center, - double zoom, + required LatLng targetCenter, + required double targetZoom, + required MapEventSource source, + required LatLng center, + required double zoom, }) : super( targetCenter: targetCenter, targetZoom: targetZoom, @@ -112,28 +121,35 @@ class MapEventFlingAnimation extends MapEventWithMove { /// to start fling animation class MapEventFlingAnimationNotStarted extends MapEvent { MapEventFlingAnimationNotStarted( - {MapEventSource source, LatLng center, double zoom}) + {required MapEventSource source, + required LatLng center, + required double zoom}) : super(source: source, center: center, zoom: zoom); } class MapEventFlingAnimationStart extends MapEvent { MapEventFlingAnimationStart( - {MapEventSource source, LatLng center, double zoom}) + {required MapEventSource source, + required LatLng center, + required double zoom}) : super(source: source, center: center, zoom: zoom); } class MapEventFlingAnimationEnd extends MapEvent { - MapEventFlingAnimationEnd({MapEventSource source, LatLng center, double zoom}) + MapEventFlingAnimationEnd( + {required MapEventSource source, + required LatLng center, + required double zoom}) : super(source: source, center: center, zoom: zoom); } class MapEventDoubleTapZoom extends MapEventWithMove { MapEventDoubleTapZoom({ - LatLng targetCenter, - double targetZoom, - MapEventSource source, - LatLng center, - double zoom, + required LatLng targetCenter, + required double targetZoom, + required MapEventSource source, + required LatLng center, + required double zoom, }) : super( targetCenter: targetCenter, targetZoom: targetZoom, @@ -145,36 +161,47 @@ class MapEventDoubleTapZoom extends MapEventWithMove { class MapEventDoubleTapZoomStart extends MapEvent { MapEventDoubleTapZoomStart( - {MapEventSource source, LatLng center, double zoom}) + {required MapEventSource source, + required LatLng center, + required double zoom}) : super(source: source, center: center, zoom: zoom); } class MapEventDoubleTapZoomEnd extends MapEvent { - MapEventDoubleTapZoomEnd({MapEventSource source, LatLng center, double zoom}) + MapEventDoubleTapZoomEnd( + {required MapEventSource source, + required LatLng center, + required double zoom}) : super(source: source, center: center, zoom: zoom); } class MapEventRotate extends MapEvent { - final String id; + final String? id; final double currentRotation; final double targetRotation; MapEventRotate({ - this.id, - this.currentRotation, - this.targetRotation, - MapEventSource source, - LatLng center, - double zoom, + required this.id, + required this.currentRotation, + required this.targetRotation, + required MapEventSource source, + required LatLng center, + required double zoom, }) : super(source: source, center: center, zoom: zoom); } class MapEventRotateStart extends MapEvent { - MapEventRotateStart({MapEventSource source, LatLng center, double zoom}) + MapEventRotateStart( + {required MapEventSource source, + required LatLng center, + required double zoom}) : super(source: source, center: center, zoom: zoom); } class MapEventRotateEnd extends MapEvent { - MapEventRotateEnd({MapEventSource source, LatLng center, double zoom}) + MapEventRotateEnd( + {required MapEventSource source, + required LatLng center, + required double zoom}) : super(source: source, center: center, zoom: zoom); } diff --git a/lib/src/layer/circle_layer.dart b/lib/src/layer/circle_layer.dart index 7bebde3dc..8f7c14804 100644 --- a/lib/src/layer/circle_layer.dart +++ b/lib/src/layer/circle_layer.dart @@ -8,9 +8,9 @@ import 'package:latlong2/latlong.dart' hide Path; class CircleLayerOptions extends LayerOptions { final List circles; CircleLayerOptions({ - Key key, + Key? key, this.circles = const [], - Stream rebuild, + Stream? rebuild, }) : super(key: key, rebuild: rebuild); } @@ -24,8 +24,8 @@ class CircleMarker { Offset offset = Offset.zero; num realRadius = 0; CircleMarker({ - this.point, - this.radius, + required this.point, + required this.radius, this.useRadiusInMeter = false, this.color = const Color(0xFF00FF00), this.borderStrokeWidth = 0.0, @@ -36,11 +36,11 @@ class CircleMarker { class CircleLayerWidget extends StatelessWidget { final CircleLayerOptions options; - CircleLayerWidget({Key key, @required this.options}) : super(key: key); + CircleLayerWidget({Key? key, required this.options}) : super(key: key); @override Widget build(BuildContext context) { - final mapState = MapState.of(context); + final mapState = MapState.maybeOf(context)!; return CircleLayer(options, mapState, mapState.onMoved); } } @@ -48,7 +48,7 @@ class CircleLayerWidget extends StatelessWidget { class CircleLayer extends StatelessWidget { final CircleLayerOptions circleOpts; final MapState map; - final Stream stream; + final Stream? stream; CircleLayer(this.circleOpts, this.map, this.stream) : super(key: circleOpts.key); @@ -112,8 +112,11 @@ class CirclePainter extends CustomPainter { ..style = PaintingStyle.fill ..color = circle.color; - _paintCircle(canvas, circle.offset, - circle.useRadiusInMeter ? circle.realRadius : circle.radius, paint); + _paintCircle( + canvas, + circle.offset, + circle.useRadiusInMeter ? circle.realRadius as double : circle.radius, + paint); if (circle.borderStrokeWidth > 0) { final paint = Paint() @@ -121,8 +124,11 @@ class CirclePainter extends CustomPainter { ..color = circle.borderColor ..strokeWidth = circle.borderStrokeWidth; - _paintCircle(canvas, circle.offset, - circle.useRadiusInMeter ? circle.realRadius : circle.radius, paint); + _paintCircle( + canvas, + circle.offset, + circle.useRadiusInMeter ? circle.realRadius as double : circle.radius, + paint); } } diff --git a/lib/src/layer/group_layer.dart b/lib/src/layer/group_layer.dart index 91cbe36bc..68b79761a 100644 --- a/lib/src/layer/group_layer.dart +++ b/lib/src/layer/group_layer.dart @@ -7,20 +7,20 @@ class GroupLayerOptions extends LayerOptions { List group = []; GroupLayerOptions({ - Key key, - this.group, - Stream rebuild, + required Key key, + required this.group, + required Stream rebuild, }) : super(key: key, rebuild: rebuild); } class GroupLayerWidget extends StatelessWidget { final GroupLayerOptions options; - GroupLayerWidget({Key key, @required this.options}) : super(key: key); + GroupLayerWidget({Key? key, required this.options}) : super(key: key); @override Widget build(BuildContext context) { - final mapState = MapState.of(context); + final mapState = MapState.maybeOf(context)!; return GroupLayer(options, mapState, mapState.onMoved); } } diff --git a/lib/src/layer/layer.dart b/lib/src/layer/layer.dart index 7105fd0eb..cf4cb0801 100644 --- a/lib/src/layer/layer.dart +++ b/lib/src/layer/layer.dart @@ -5,7 +5,7 @@ import 'package:flutter/foundation.dart'; /// All LayerOptions have access to a stream that notifies when the map needs /// rebuilding. class LayerOptions { - final Key key; - final Stream rebuild; + final Key? key; + final Stream? rebuild; LayerOptions({this.key, this.rebuild}); } diff --git a/lib/src/layer/marker_layer.dart b/lib/src/layer/marker_layer.dart index af95be987..426c0317c 100644 --- a/lib/src/layer/marker_layer.dart +++ b/lib/src/layer/marker_layer.dart @@ -7,9 +7,9 @@ import 'package:latlong2/latlong.dart'; class MarkerLayerOptions extends LayerOptions { final List markers; MarkerLayerOptions({ - Key key, + Key? key, this.markers = const [], - Stream rebuild, + Stream? rebuild, }) : super(key: key, rebuild: rebuild); } @@ -51,8 +51,8 @@ class Anchor { } } - factory Anchor.forPos(AnchorPos pos, double width, double height) { - if (pos == null) return Anchor._(width, height, null); + factory Anchor.forPos(AnchorPos? pos, double width, double height) { + if (pos == null) return Anchor._(width, height, AnchorAlign.none); if (pos.value is AnchorAlign) return Anchor._(width, height, pos.value); if (pos.value is Anchor) return pos.value; throw Exception('Unsupported AnchorPos value type: ${pos.runtimeType}.'); @@ -67,6 +67,7 @@ class AnchorPos { } enum AnchorAlign { + none, left, right, top, @@ -82,22 +83,22 @@ class Marker { final Anchor anchor; Marker({ - this.point, - this.builder, + required this.point, + required this.builder, this.width = 30.0, this.height = 30.0, - AnchorPos anchorPos, + AnchorPos? anchorPos, }) : anchor = Anchor.forPos(anchorPos, width, height); } class MarkerLayerWidget extends StatelessWidget { final MarkerLayerOptions options; - MarkerLayerWidget({Key key, @required this.options}) : super(key: key); + MarkerLayerWidget({Key? key, required this.options}) : super(key: key); @override Widget build(BuildContext context) { - final mapState = MapState.of(context); + final mapState = MapState.maybeOf(context)!; return MarkerLayer(options, mapState, mapState.onMoved); } } @@ -105,7 +106,7 @@ class MarkerLayerWidget extends StatelessWidget { class MarkerLayer extends StatelessWidget { final MarkerLayerOptions markerOpts; final MapState map; - final Stream stream; + final Stream? stream; MarkerLayer(this.markerOpts, this.map, this.stream) : super(key: markerOpts.key); @@ -123,9 +124,9 @@ class MarkerLayer extends StatelessWidget { @override Widget build(BuildContext context) { - return StreamBuilder( + return StreamBuilder( stream: stream, // a Stream or null - builder: (BuildContext context, AsyncSnapshot snapshot) { + builder: (BuildContext context, AsyncSnapshot snapshot) { var markers = []; for (var markerOpt in markerOpts.markers) { var pos = map.project(markerOpt.point); diff --git a/lib/src/layer/overlay_image_layer.dart b/lib/src/layer/overlay_image_layer.dart index a753c6aab..137c63155 100644 --- a/lib/src/layer/overlay_image_layer.dart +++ b/lib/src/layer/overlay_image_layer.dart @@ -9,9 +9,9 @@ class OverlayImageLayerOptions extends LayerOptions { final List overlayImages; OverlayImageLayerOptions({ - Key key, + Key? key, this.overlayImages = const [], - Stream rebuild, + Stream? rebuild, }) : super(key: key, rebuild: rebuild); } @@ -22,8 +22,8 @@ class OverlayImage { final bool gaplessPlayback; OverlayImage({ - this.bounds, - this.imageProvider, + required this.bounds, + required this.imageProvider, this.opacity = 1.0, this.gaplessPlayback = false, }); @@ -32,11 +32,11 @@ class OverlayImage { class OverlayImageLayerWidget extends StatelessWidget { final OverlayImageLayerOptions options; - OverlayImageLayerWidget({Key key, @required this.options}) : super(key: key); + OverlayImageLayerWidget({Key? key, required this.options}) : super(key: key); @override Widget build(BuildContext context) { - final mapState = MapState.of(context); + final mapState = MapState.maybeOf(context)!; return OverlayImageLayer(options, mapState, mapState.onMoved); } } @@ -44,7 +44,7 @@ class OverlayImageLayerWidget extends StatelessWidget { class OverlayImageLayer extends StatelessWidget { final OverlayImageLayerOptions overlayImageOpts; final MapState map; - final Stream stream; + final Stream? stream; OverlayImageLayer(this.overlayImageOpts, this.map, this.stream) : super(key: overlayImageOpts.key); diff --git a/lib/src/layer/polygon_layer.dart b/lib/src/layer/polygon_layer.dart index f46956b81..bff6baf26 100644 --- a/lib/src/layer/polygon_layer.dart +++ b/lib/src/layer/polygon_layer.dart @@ -12,10 +12,10 @@ class PolygonLayerOptions extends LayerOptions { /// screen space culling of polygons based on bounding box PolygonLayerOptions({ - Key key, + required Key key, this.polygons = const [], this.polygonCulling = false, - Stream rebuild, + required Stream rebuild, }) : super(key: key, rebuild: rebuild) { if (polygonCulling) { for (var polygon in polygons) { @@ -28,17 +28,17 @@ class PolygonLayerOptions extends LayerOptions { class Polygon { final List points; final List offsets = []; - final List> holePointsList; - final List> holeOffsetsList; + final List>? holePointsList; + final List>? holeOffsetsList; final Color color; final double borderStrokeWidth; final Color borderColor; final bool disableHolesBorder; final bool isDotted; - LatLngBounds boundingBox; + late LatLngBounds boundingBox; Polygon({ - this.points, + required this.points, this.holePointsList, this.color = const Color(0xFF00FF00), this.borderStrokeWidth = 0.0, @@ -52,11 +52,11 @@ class Polygon { class PolygonLayerWidget extends StatelessWidget { final PolygonLayerOptions options; - PolygonLayerWidget({Key key, @required this.options}) : super(key: key); + PolygonLayerWidget({Key? key, required this.options}) : super(key: key); @override Widget build(BuildContext context) { - final mapState = MapState.of(context); + final mapState = MapState.maybeOf(context)!; return PolygonLayer(options, mapState, mapState.onMoved); } } @@ -64,7 +64,7 @@ class PolygonLayerWidget extends StatelessWidget { class PolygonLayer extends StatelessWidget { final PolygonLayerOptions polygonOpts; final MapState map; - final Stream stream; + final Stream? stream; PolygonLayer(this.polygonOpts, this.map, this.stream) : super(key: polygonOpts.key); @@ -89,7 +89,7 @@ class PolygonLayer extends StatelessWidget { polygon.offsets.clear(); if (null != polygon.holeOffsetsList) { - for (var offsets in polygon.holeOffsetsList) { + for (var offsets in polygon.holeOffsetsList!) { offsets.clear(); } } @@ -103,9 +103,11 @@ class PolygonLayer extends StatelessWidget { _fillOffsets(polygon.offsets, polygon.points); if (null != polygon.holePointsList) { - for (var i = 0, len = polygon.holePointsList.length; i < len; ++i) { + for (var i = 0, len = polygon.holePointsList!.length; + i < len; + ++i) { _fillOffsets( - polygon.holeOffsetsList[i], polygon.holePointsList[i]); + polygon.holeOffsetsList![i], polygon.holePointsList![i]); } } @@ -170,7 +172,7 @@ class PolygonPainter extends CustomPainter { if (!polygonOpt.disableHolesBorder && null != polygonOpt.holeOffsetsList) { - for (var offsets in polygonOpt.holeOffsetsList) { + for (var offsets in polygonOpt.holeOffsetsList!) { _paintDottedLine( canvas, offsets, borderRadius, spacing, borderPaint); } @@ -180,7 +182,7 @@ class PolygonPainter extends CustomPainter { if (!polygonOpt.disableHolesBorder && null != polygonOpt.holeOffsetsList) { - for (var offsets in polygonOpt.holeOffsetsList) { + for (var offsets in polygonOpt.holeOffsetsList!) { _paintLine(canvas, offsets, borderRadius, borderPaint); } } @@ -225,7 +227,7 @@ class PolygonPainter extends CustomPainter { canvas.saveLayer(rect, paint); paint.style = PaintingStyle.fill; - for (var offsets in polygonOpt.holeOffsetsList) { + for (var offsets in polygonOpt.holeOffsetsList!) { var path = Path(); path.addPolygon(offsets, true); canvas.drawPath(path, paint); diff --git a/lib/src/layer/polyline_layer.dart b/lib/src/layer/polyline_layer.dart index 8ab7ff5de..66e50dd70 100644 --- a/lib/src/layer/polyline_layer.dart +++ b/lib/src/layer/polyline_layer.dart @@ -11,10 +11,10 @@ class PolylineLayerOptions extends LayerOptions { final bool polylineCulling; PolylineLayerOptions({ - Key key, + Key? key, this.polylines = const [], this.polylineCulling = false, - Stream rebuild, + Stream? rebuild, }) : super(key: key, rebuild: rebuild) { if (polylineCulling) { for (var polyline in polylines) { @@ -30,14 +30,14 @@ class Polyline { final double strokeWidth; final Color color; final double borderStrokeWidth; - final Color borderColor; - final List gradientColors; - final List colorsStop; + final Color? borderColor; + final List? gradientColors; + final List? colorsStop; final bool isDotted; - LatLngBounds boundingBox; + late LatLngBounds boundingBox; Polyline({ - this.points, + required this.points, this.strokeWidth = 1.0, this.color = const Color(0xFF00FF00), this.borderStrokeWidth = 0.0, @@ -50,11 +50,11 @@ class Polyline { class PolylineLayerWidget extends StatelessWidget { final PolylineLayerOptions options; - PolylineLayerWidget({Key key, @required this.options}) : super(key: key); + PolylineLayerWidget({Key? key, required this.options}) : super(key: key); @override Widget build(BuildContext context) { - final mapState = MapState.of(context); + final mapState = MapState.maybeOf(context)!; return PolylineLayer(options, mapState, mapState.onMoved); } } @@ -62,7 +62,7 @@ class PolylineLayerWidget extends StatelessWidget { class PolylineLayer extends StatelessWidget { final PolylineLayerOptions polylineOpts; final MapState map; - final Stream stream; + final Stream? stream; PolylineLayer(this.polylineOpts, this.map, this.stream) : super(key: polylineOpts.key); @@ -145,15 +145,15 @@ class PolylinePainter extends CustomPainter { if (polylineOpt.gradientColors == null) { paint.color = polylineOpt.color; } else { - polylineOpt.gradientColors.isNotEmpty + polylineOpt.gradientColors!.isNotEmpty ? paint.shader = _paintGradient() : paint.color = polylineOpt.color; } - Paint filterPaint; + Paint? filterPaint; if (polylineOpt.borderColor != null) { filterPaint = Paint() - ..color = polylineOpt.borderColor.withAlpha(255) + ..color = polylineOpt.borderColor!.withAlpha(255) ..strokeWidth = polylineOpt.strokeWidth ..strokeCap = StrokeCap.round ..strokeJoin = StrokeJoin.round @@ -162,7 +162,7 @@ class PolylinePainter extends CustomPainter { final borderPaint = polylineOpt.borderStrokeWidth > 0.0 ? (Paint() - ..color = polylineOpt.borderColor + ..color = polylineOpt.borderColor ?? Color(0x00000000) ..strokeWidth = polylineOpt.strokeWidth + polylineOpt.borderStrokeWidth ..strokeCap = StrokeCap.round @@ -178,7 +178,7 @@ class PolylinePainter extends CustomPainter { _paintDottedLine( canvas, polylineOpt.offsets, borderRadius, spacing, borderPaint); _paintDottedLine( - canvas, polylineOpt.offsets, radius, spacing, filterPaint); + canvas, polylineOpt.offsets, radius, spacing, filterPaint!); } _paintDottedLine(canvas, polylineOpt.offsets, radius, spacing, paint); canvas.restore(); @@ -190,8 +190,8 @@ class PolylinePainter extends CustomPainter { filterPaint.style = PaintingStyle.stroke; _paintLine(canvas, polylineOpt.offsets, borderPaint); } - borderPaint?.style = PaintingStyle.stroke; - _paintLine(canvas, polylineOpt.offsets, filterPaint); + borderPaint.style = PaintingStyle.stroke; + _paintLine(canvas, polylineOpt.offsets, filterPaint!); } _paintLine(canvas, polylineOpt.offsets, paint); canvas.restore(); @@ -234,18 +234,18 @@ class PolylinePainter extends CustomPainter { } ui.Gradient _paintGradient() => ui.Gradient.linear(polylineOpt.offsets.first, - polylineOpt.offsets.last, polylineOpt.gradientColors, _getColorsStop()); + polylineOpt.offsets.last, polylineOpt.gradientColors!, _getColorsStop()); - List _getColorsStop() => (polylineOpt.colorsStop != null && - polylineOpt.colorsStop.length == polylineOpt.gradientColors.length) + List? _getColorsStop() => (polylineOpt.colorsStop != null && + polylineOpt.colorsStop!.length == polylineOpt.gradientColors!.length) ? polylineOpt.colorsStop : _calculateColorsStop(); List _calculateColorsStop() { - final colorsStopInterval = 1.0 / polylineOpt.gradientColors.length; - return polylineOpt.gradientColors + final colorsStopInterval = 1.0 / polylineOpt.gradientColors!.length; + return polylineOpt.gradientColors! .map((gradientColor) => - polylineOpt.gradientColors.indexOf(gradientColor) * + polylineOpt.gradientColors!.indexOf(gradientColor) * colorsStopInterval) .toList(); } diff --git a/lib/src/layer/tile_layer.dart b/lib/src/layer/tile_layer.dart index fbbb3c0e4..24e8c3626 100644 --- a/lib/src/layer/tile_layer.dart +++ b/lib/src/layer/tile_layer.dart @@ -49,14 +49,14 @@ class TileLayerOptions extends LayerOptions { /// Is translated to this: /// /// https://a.tile.openstreetmap.org/12/2177/1259.png - final String urlTemplate; + final String? urlTemplate; /// If `true`, inverses Y axis numbering for tiles (turn this on for /// [TMS](https://en.wikipedia.org/wiki/Tile_Map_Service) services). final bool tms; /// If not `null`, then tiles will pull's WMS protocol requests - final WMSTileLayerOptions wmsOptions; + final WMSTileLayerOptions? wmsOptions; /// Size for the tile. /// Default is 256 @@ -73,12 +73,12 @@ class TileLayerOptions extends LayerOptions { /// Minimum zoom number the tile source has available. If it is specified, the /// tiles on all zoom levels lower than minNativeZoom will be loaded from /// minNativeZoom level and auto-scaled. - final double minNativeZoom; + final double? minNativeZoom; /// Maximum zoom number the tile source has available. If it is specified, the /// tiles on all zoom levels higher than maxNativeZoom will be loaded from /// maxNativeZoom level and auto-scaled. - final double maxNativeZoom; + final double? maxNativeZoom; /// If set to true, the zoom number used in tile URLs will be reversed /// (`maxZoom - zoom` instead of `zoom`) @@ -141,10 +141,10 @@ class TileLayerOptions extends LayerOptions { final int keepBuffer; /// Placeholder to show until tile images are fetched by the provider. - final ImageProvider placeholderImage; + final ImageProvider? placeholderImage; /// Tile image to show in place of the tile that failed to load. - final ImageProvider errorImage; + final ImageProvider? errorImage; /// Static informations that should replace placeholders in the [urlTemplate]. /// Applying API keys is a good example on how to use this parameter. @@ -170,11 +170,11 @@ class TileLayerOptions extends LayerOptions { /// loading tiles every frame when panning / zooming, flutter is fast) This /// can save some fps and even bandwidth (ie. when fast panning / animating /// between long distances in short time) - final Duration updateInterval; + final Duration? updateInterval; /// Tiles fade in duration in milliseconds (default 100). This can be null to /// avoid fade in. - final Duration tileFadeInDuration; + final Duration? tileFadeInDuration; /// Opacity start value when Tile starts fade in (0.0 - 1.0) Takes effect if /// `tileFadeInDuration` is not null @@ -210,17 +210,17 @@ class TileLayerOptions extends LayerOptions { final bool retinaMode; /// This callback will be execute if some errors occur when fetching tiles. - final ErrorTileCallBack errorTileCallback; + final ErrorTileCallBack? errorTileCallback; final TemplateFunction templateFunction; /// Function which may Wrap Tile with custom Widget /// There are predefined examples in 'tile_builder.dart' - final TileBuilder tileBuilder; + final TileBuilder? tileBuilder; /// Function which may wrap Tiles Container with custom Widget /// There are predefined examples in 'tile_builder.dart' - final TilesContainerBuilder tilesContainerBuilder; + final TilesContainerBuilder? tilesContainerBuilder; // If a Tile was loaded with error and if strategy isn't `none` then TileProvider // will be asked to evict Image based on current strategy @@ -228,7 +228,7 @@ class TileLayerOptions extends LayerOptions { final EvictErrorTileStrategy evictErrorTileStrategy; TileLayerOptions({ - Key key, + Key? key, this.urlTemplate, double tileSize = 256.0, double minZoom = 0.0, @@ -237,7 +237,7 @@ class TileLayerOptions extends LayerOptions { this.maxNativeZoom, this.zoomReverse = false, double zoomOffset = 0.0, - Map additionalOptions, + Map? additionalOptions, this.subdomains = const [], this.keepBuffer = 2, this.backgroundColor = const Color(0xFFE0E0E0), @@ -264,7 +264,7 @@ class TileLayerOptions extends LayerOptions { this.overrideTilesWhenUrlChanges = false, this.retinaMode = false, this.errorTileCallback, - Stream rebuild, + Stream? rebuild, this.templateFunction = util.template, this.tileBuilder, this.tilesContainerBuilder, @@ -328,12 +328,12 @@ class WMSTileLayerOptions { /// other request parameters final Map otherParameters; - String _encodedBaseUrl; + late String _encodedBaseUrl; - double _versionNumber; + late double _versionNumber; WMSTileLayerOptions({ - @required this.baseUrl, + required this.baseUrl, this.layers = const [], this.styles = const [], this.format = 'image/png', @@ -366,8 +366,8 @@ class WMSTileLayerOptions { final tileSizePoint = CustomPoint(tileSize, tileSize); final nvPoint = coords.scaleBy(tileSizePoint); final sePoint = nvPoint + tileSizePoint; - final nvCoords = crs.pointToLatLng(nvPoint, coords.z); - final seCoords = crs.pointToLatLng(sePoint, coords.z); + final nvCoords = crs.pointToLatLng(nvPoint, coords.z as double)!; + final seCoords = crs.pointToLatLng(sePoint, coords.z as double)!; final nv = crs.projection.project(nvCoords); final se = crs.projection.project(seCoords); final bounds = Bounds(nv, se); @@ -386,11 +386,11 @@ class WMSTileLayerOptions { class TileLayerWidget extends StatelessWidget { final TileLayerOptions options; - TileLayerWidget({Key key, @required this.options}) : super(key: key); + TileLayerWidget({Key? key, required this.options}) : super(key: key); @override Widget build(BuildContext context) { - final mapState = MapState.of(context); + final mapState = MapState.maybeOf(context)!; return TileLayer( mapState: mapState, @@ -406,9 +406,9 @@ class TileLayer extends StatefulWidget { final Stream stream; TileLayer({ - this.options, - this.mapState, - this.stream, + required this.options, + required this.mapState, + required this.stream, }) : super(key: options.key); @override @@ -421,16 +421,16 @@ class _TileLayerState extends State with TickerProviderStateMixin { MapState get map => widget.mapState; TileLayerOptions get options => widget.options; - Bounds _globalTileRange; - Tuple2 _wrapX; - Tuple2 _wrapY; - double _tileZoom; + late Bounds _globalTileRange; + Tuple2? _wrapX; + Tuple2? _wrapY; + double? _tileZoom; //ignore: unused_field - Level _level; - StreamSubscription _moveSub; - StreamController _throttleUpdate; - CustomPoint _tileSize; + Level? _level; + StreamSubscription? _moveSub; + StreamController? _throttleUpdate; + late CustomPoint _tileSize; final Map _tiles = {}; final Map _levels = {}; @@ -498,8 +498,8 @@ class _TileLayerState extends State with TickerProviderStateMixin { bool _isZoomOutsideMinMax() { for (var tile in _tiles.values) { - if (tile.level.zoom > (options.maxZoom ?? 1.0) || - tile.level.zoom < (options.minZoom ?? 20.0)) { + if (tile.level.zoom > (options.maxZoom) || + tile.level.zoom < (options.minZoom)) { return true; } } @@ -510,8 +510,8 @@ class _TileLayerState extends State with TickerProviderStateMixin { if (options.updateInterval == null) { _throttleUpdate = null; } else { - _throttleUpdate = StreamController(sync: true); - _throttleUpdate.stream + _throttleUpdate = StreamController(sync: true); + _throttleUpdate!.stream .transform( util.throttleStreamTransformerWithTrailingCall( options.updateInterval, @@ -549,7 +549,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { color: options.backgroundColor, child: options.tilesContainerBuilder == null ? tilesContainer - : options.tilesContainerBuilder( + : options.tilesContainerBuilder!( context, tilesContainer, tilesToRender, @@ -563,8 +563,8 @@ class _TileLayerState extends State with TickerProviderStateMixin { var level = tile.level; var tileSize = getTileSize(); var pos = (tilePos).multiplyBy(level.scale) + level.translatePoint; - var width = tileSize.x * level.scale; - var height = tileSize.y * level.scale; + num width = tileSize.x * level.scale; + num height = tileSize.y * level.scale; final Widget content = AnimatedTile( tile: tile, @@ -595,7 +595,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { } for (var key in toRemove) { - var tile = _tiles[key]; + var tile = _tiles[key]!; tile.tileReady = null; tile.dispose(tile.loadError && @@ -618,7 +618,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { return false; } - Level _updateLevels() { + Level? _updateLevels() { var zoom = _tileZoom; var maxZoom = options.maxZoom; @@ -647,8 +647,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { if (level == null) { level = _levels[zoom] = Level(); level.zIndex = maxZoom; - level.origin = map.project(map.unproject(map.getPixelOrigin()), zoom) ?? - CustomPoint(0.0, 0.0); + level.origin = map.project(map.unproject(map.getPixelOrigin()), zoom); level.zoom = zoom; _setZoomTransform(level, map.center, map.zoom); @@ -658,6 +657,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { } void _pruneTiles() { + // TODO this pretty sure isn't necessary anymore if (map == null) { return; } @@ -776,21 +776,20 @@ class _TileLayerState extends State with TickerProviderStateMixin { } double _clampZoom(double zoom) { - if (null != options.minNativeZoom && zoom < options.minNativeZoom) { - return options.minNativeZoom; + if (null != options.minNativeZoom && zoom < options.minNativeZoom!) { + return options.minNativeZoom!; } - if (null != options.maxNativeZoom && options.maxNativeZoom < zoom) { - return options.maxNativeZoom; + if (null != options.maxNativeZoom && options.maxNativeZoom! < zoom) { + return options.maxNativeZoom!; } return zoom; } void _setView(LatLng center, double zoom) { - var tileZoom = _clampZoom(zoom.roundToDouble()); - if ((options.maxZoom != null && tileZoom > options.maxZoom) || - (options.minZoom != null && tileZoom < options.minZoom)) { + double? tileZoom = _clampZoom(zoom.roundToDouble()); + if ((tileZoom > options.maxZoom) || (tileZoom < options.minZoom)) { tileZoom = null; } @@ -810,7 +809,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { void _setZoomTransforms(LatLng center, double zoom) { for (var i in _levels.keys) { - _setZoomTransform(_levels[i], center, zoom); + _setZoomTransform(_levels[i]!, center, zoom); } } @@ -820,7 +819,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { if (level.origin == null) { return; } - var translate = level.origin.multiplyBy(scale) - pixelOrigin; + var translate = level.origin!.multiplyBy(scale) - pixelOrigin; level.translatePoint = translate; level.scale = scale; } @@ -839,23 +838,23 @@ class _TileLayerState extends State with TickerProviderStateMixin { // wrapping _wrapX = crs.wrapLng; if (_wrapX != null) { - var first = - (map.project(LatLng(0.0, crs.wrapLng.item1), tileZoom).x / tileSize.x) - .floorToDouble(); - var second = - (map.project(LatLng(0.0, crs.wrapLng.item2), tileZoom).x / tileSize.y) - .ceilToDouble(); + var first = (map.project(LatLng(0.0, crs.wrapLng!.item1), tileZoom).x / + tileSize.x) + .floorToDouble(); + var second = (map.project(LatLng(0.0, crs.wrapLng!.item2), tileZoom).x / + tileSize.y) + .ceilToDouble(); _wrapX = Tuple2(first, second); } _wrapY = crs.wrapLat; if (_wrapY != null) { - var first = - (map.project(LatLng(crs.wrapLat.item1, 0.0), tileZoom).y / tileSize.x) - .floorToDouble(); - var second = - (map.project(LatLng(crs.wrapLat.item2, 0.0), tileZoom).y / tileSize.y) - .ceilToDouble(); + var first = (map.project(LatLng(crs.wrapLat!.item1, 0.0), tileZoom).y / + tileSize.x) + .floorToDouble(); + var second = (map.project(LatLng(crs.wrapLat!.item2, 0.0), tileZoom).y / + tileSize.y) + .ceilToDouble(); _wrapY = Tuple2(first, second); } } @@ -866,8 +865,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { if (_tileZoom == null) { // if there is no _tileZoom available it means we are out within zoom level // we will restore fully via _setView call if we are back on trail - if ((options.maxZoom != null && tileZoom <= options.maxZoom) && - (options.minZoom != null && tileZoom >= options.minZoom)) { + if ((tileZoom <= options.maxZoom) && (tileZoom >= options.minZoom)) { _tileZoom = tileZoom; setState(() { _setView(map.center, tileZoom); @@ -877,7 +875,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { } } else { setState(() { - if ((tileZoom - _tileZoom).abs() >= 1) { + if ((tileZoom - _tileZoom!).abs() >= 1) { // It was a zoom lvl change _setView(map.center, tileZoom); @@ -886,7 +884,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { if (null == _throttleUpdate) { _update(null); } else { - _throttleUpdate.add(null); + _throttleUpdate!.add(null); } _setZoomTransforms(map.center, map.zoom); @@ -905,7 +903,8 @@ class _TileLayerState extends State with TickerProviderStateMixin { // Private method to load tiles in the grid's active zoom level according to // map bounds - void _update(LatLng center) { + void _update(LatLng? center) { + // TODO can we safely remove the null check for map if (map == null || _tileZoom == null) { return; } @@ -916,7 +915,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { var pixelBounds = _getTiledPixelBounds(center); var tileRange = _pxBoundsToTileRange(pixelBounds); var tileCenter = tileRange.getCenter(); - var queue = >[]; + final queue = >[]; var margin = options.keepBuffer; var noPruneRange = Bounds( tileRange.bottomLeft - CustomPoint(margin, -margin), @@ -935,7 +934,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { // _update just loads more tiles. If the tile zoom level differs too much // from the map's, let _setView reset levels and prune old tiles. - if ((zoom - _tileZoom).abs() > 1) { + if ((zoom - _tileZoom!).abs() > 1) { _setView(center, zoom); return; } @@ -943,8 +942,8 @@ class _TileLayerState extends State with TickerProviderStateMixin { // create a queue of coordinates to load tiles from for (var j = tileRange.min.y; j <= tileRange.max.y; j++) { for (var i = tileRange.min.x; i <= tileRange.max.x; i++) { - var coords = Coords(i.toDouble(), j.toDouble()); - coords.z = _tileZoom; + final coords = Coords(i.toDouble(), j.toDouble()); + coords.z = _tileZoom!; if (!_isValidTile(coords)) { continue; @@ -966,7 +965,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { (a.distanceTo(tileCenter) - b.distanceTo(tileCenter)).toInt()); for (var i = 0; i < queue.length; i++) { - _addTile(queue[i]); + _addTile(queue[i] as Coords); } } @@ -1018,7 +1017,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { coordsKey: tileCoordsToKey, tilePos: _getTilePos(coords), current: true, - level: _levels[coords.z], + level: _levels[coords.z]!, imageProvider: options.tileProvider.getImage(_wrapCoords(coords), options), tileReady: _tileReady, @@ -1040,7 +1039,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { } for (var key in toRemove) { - var tile = _tiles[key]; + var tile = _tiles[key]!; tile.dispose(true); _tiles.remove(key); @@ -1059,7 +1058,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { } for (var key in toRemove) { - var tile = _tiles[key]; + var tile = _tiles[key]!; tile.dispose(true); _tiles.remove(key); @@ -1067,17 +1066,17 @@ class _TileLayerState extends State with TickerProviderStateMixin { } } - void _tileReady(Coords coords, dynamic error, Tile tile) { + void _tileReady(Coords coords, dynamic error, Tile? tile) { if (null != error) { print(error); - tile.loadError = true; + tile!.loadError = true; if (options.errorTileCallback != null) { - options.errorTileCallback(tile, error); + options.errorTileCallback!(tile, error); } } else { - tile.loadError = false; + tile!.loadError = false; } var key = _tileCoordsToKey(coords); @@ -1096,7 +1095,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { tile.active = true; } else { tile.startFadeInAnimation( - options.tileFadeInDuration, + options.tileFadeInDuration!, this, from: fadeInStart, ); @@ -1111,7 +1110,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { // fade-in) to trigger a pruning. Future.delayed( options.tileFadeInDuration != null - ? options.tileFadeInDuration + const Duration(milliseconds: 50) + ? options.tileFadeInDuration! + const Duration(milliseconds: 50) : const Duration(milliseconds: 50), () { if (mounted) { @@ -1123,17 +1122,17 @@ class _TileLayerState extends State with TickerProviderStateMixin { } CustomPoint _getTilePos(Coords coords) { - var level = _levels[coords.z]; - return coords.scaleBy(getTileSize()) - level.origin; + var level = _levels[coords.z as double]!; + return coords.scaleBy(getTileSize()) - level.origin!; } Coords _wrapCoords(Coords coords) { var newCoords = Coords( _wrapX != null - ? util.wrapNum(coords.x.toDouble(), _wrapX) + ? util.wrapNum(coords.x.toDouble(), _wrapX!) : coords.x.toDouble(), _wrapY != null - ? util.wrapNum(coords.y.toDouble(), _wrapY) + ? util.wrapNum(coords.y.toDouble(), _wrapY!) : coords.y.toDouble(), ); newCoords.z = coords.z.toDouble(); @@ -1172,29 +1171,29 @@ class Tile implements Comparable { bool retain; bool active; bool loadError; - DateTime loaded; - DateTime loadStarted; + DateTime? loaded; + late DateTime loadStarted; - AnimationController animationController; + AnimationController? animationController; double get opacity => animationController == null ? (active ? 1.0 : 0.0) - : animationController.value; + : animationController!.value; // callback when tile is ready / error occurred // it maybe be null forinstance when download aborted - TileReady tileReady; - ImageInfo imageInfo; - ImageStream _imageStream; - ImageStreamListener _listener; + TileReady? tileReady; + ImageInfo? imageInfo; + ImageStream? _imageStream; + late ImageStreamListener _listener; Tile({ - this.coordsKey, - this.coords, - this.tilePos, - this.imageProvider, + required this.coordsKey, + required this.coords, + required this.tilePos, + required this.imageProvider, this.tileReady, - this.level, + required this.level, this.current = false, this.active = false, this.retain = false, @@ -1208,11 +1207,11 @@ class Tile implements Comparable { final oldImageStream = _imageStream; _imageStream = imageProvider.resolve(ImageConfiguration()); - if (_imageStream.key != oldImageStream?.key) { + if (_imageStream!.key != oldImageStream?.key) { oldImageStream?.removeListener(_listener); _listener = ImageStreamListener(_tileOnLoad, onError: _tileOnError); - _imageStream.addListener(_listener); + _imageStream!.addListener(_listener); } } catch (e, s) { // make sure all exception is handled - #444 / #536 @@ -1222,8 +1221,9 @@ class Tile implements Comparable { // call this before GC! void dispose([bool evict = false]) { - if (evict && imageProvider != null) { + if (evict) { try { + // ignore: return_type_invalid_for_catch_error imageProvider.evict().catchError(print); } catch (e) { // this may be never called because catchError will handle errors, however @@ -1238,13 +1238,13 @@ class Tile implements Comparable { } void startFadeInAnimation(Duration duration, TickerProvider vsync, - {double from}) { + {double? from}) { animationController?.removeStatusListener(_onAnimateEnd); animationController = AnimationController(duration: duration, vsync: vsync) ..addStatusListener(_onAnimateEnd); - animationController.forward(from: from); + animationController!.forward(from: from); } void _onAnimateEnd(AnimationStatus status) { @@ -1256,13 +1256,13 @@ class Tile implements Comparable { void _tileOnLoad(ImageInfo imageInfo, bool synchronousCall) { if (null != tileReady) { this.imageInfo = imageInfo; - tileReady(coords, null, this); + tileReady!(coords, null, this); } } - void _tileOnError(dynamic exception, StackTrace stackTrace) { + void _tileOnError(dynamic exception, StackTrace? stackTrace) { if (null != tileReady) { - tileReady( + tileReady!( coords, exception ?? 'Unknown exception during loadTileImage', this); } } @@ -1290,16 +1290,15 @@ class Tile implements Comparable { class AnimatedTile extends StatefulWidget { final Tile tile; - final ImageProvider errorImage; - final TileBuilder tileBuilder; + final ImageProvider? errorImage; + final TileBuilder? tileBuilder; AnimatedTile({ - Key key, - @required this.tile, + Key? key, + required this.tile, this.errorImage, - @required this.tileBuilder, - }) : assert(null != tile), - super(key: key); + required this.tileBuilder, + }) : super(key: key); @override _AnimatedTileState createState() => _AnimatedTileState(); @@ -1312,7 +1311,7 @@ class _AnimatedTileState extends State { Widget build(BuildContext context) { final tileWidget = (widget.tile.loadError && widget.errorImage != null) ? Image( - image: widget.errorImage, + image: widget.errorImage!, fit: BoxFit.fill, ) : RawImage( @@ -1324,7 +1323,7 @@ class _AnimatedTileState extends State { opacity: widget.tile.opacity, child: widget.tileBuilder == null ? tileWidget - : widget.tileBuilder(context, tileWidget, widget.tile), + : widget.tileBuilder!(context, tileWidget, widget.tile), ); } @@ -1333,7 +1332,7 @@ class _AnimatedTileState extends State { super.initState(); if (null != widget.tile.animationController) { - widget.tile.animationController.addListener(_handleChange); + widget.tile.animationController!.addListener(_handleChange); listenerAttached = true; } } @@ -1352,7 +1351,7 @@ class _AnimatedTileState extends State { super.didUpdateWidget(oldWidget); if (!listenerAttached && null != widget.tile.animationController) { - widget.tile.animationController.addListener(_handleChange); + widget.tile.animationController!.addListener(_handleChange); listenerAttached = true; } } @@ -1365,15 +1364,15 @@ class _AnimatedTileState extends State { } class Level { - double zIndex; - CustomPoint origin; - double zoom; - CustomPoint translatePoint; - double scale; + late double zIndex; + CustomPoint? origin; + late double zoom; + late CustomPoint translatePoint; + late double scale; } class Coords extends CustomPoint { - T z; + late T z; Coords(T x, T y) : super(x, y); diff --git a/lib/src/layer/tile_provider/tile_provider.dart b/lib/src/layer/tile_provider/tile_provider.dart index 8aa0d4676..62fc0dd1f 100644 --- a/lib/src/layer/tile_provider/tile_provider.dart +++ b/lib/src/layer/tile_provider/tile_provider.dart @@ -13,7 +13,7 @@ abstract class TileProvider { String getTileUrl(Coords coords, TileLayerOptions options) { var urlTemplate = (options.wmsOptions != null) - ? options.wmsOptions + ? options.wmsOptions! .getUrl(coords, options.tileSize.toInt(), options.retinaMode) : options.urlTemplate; @@ -31,7 +31,7 @@ abstract class TileProvider { } var allOpts = Map.from(data) ..addAll(options.additionalOptions); - return options.templateFunction(urlTemplate, allOpts); + return options.templateFunction(urlTemplate!, allOpts); } double _getZoomForUrl(Coords coords, TileLayerOptions options) { @@ -91,7 +91,7 @@ class FileTileProvider extends TileProvider { class CustomTileProvider extends TileProvider { final String Function(Coords coors, TileLayerOptions options) customTileUrl; - const CustomTileProvider({@required this.customTileUrl}); + const CustomTileProvider({required this.customTileUrl}); @override String getTileUrl(Coords coords, TileLayerOptions options) { diff --git a/lib/src/map/flutter_map_state.dart b/lib/src/map/flutter_map_state.dart index 0b5503f80..770c39326 100644 --- a/lib/src/map/flutter_map_state.dart +++ b/lib/src/map/flutter_map_state.dart @@ -19,10 +19,11 @@ class FlutterMapState extends MapGestureMixin { MapOptions get options => widget.options; @override - MapState mapState; + late MapState mapState; - FlutterMapState(MapController mapController) - : mapController = mapController ?? MapController(); + FlutterMapState(MapController? mapController) + : mapController = mapController as MapControllerImpl? ?? + MapController() as MapControllerImpl; @override void didUpdateWidget(FlutterMap oldWidget) { @@ -58,11 +59,11 @@ class FlutterMapState extends MapGestureMixin { } Stream _merge(LayerOptions options) { - if (options?.rebuild == null) return mapState.onMoved; + if (options.rebuild == null) return mapState.onMoved; var group = StreamGroup(); group.add(mapState.onMoved); - group.add(options.rebuild); + group.add(options.rebuild!); groups.add(group); return group.stream; } @@ -98,19 +99,16 @@ class FlutterMapState extends MapGestureMixin { child: Stack( children: [ OverflowBox( - minWidth: size.x, - maxWidth: size.x, - minHeight: size.y, - maxHeight: size.y, + minWidth: size.x as double?, + maxWidth: size.x as double?, + minHeight: size.y as double?, + maxHeight: size.y as double?, child: Transform.rotate( angle: mapState.rotationRad, child: Stack( children: [ - if (widget.children != null && - widget.children.isNotEmpty) - ...widget.children, - if (widget.layers != null && - widget.layers.isNotEmpty) + if (widget.children.isNotEmpty) ...widget.children, + if (widget.layers.isNotEmpty) ...widget.layers.map( (layer) => _createLayer(layer, options.plugins), ) @@ -120,11 +118,9 @@ class FlutterMapState extends MapGestureMixin { ), Stack( children: [ - if (widget.nonRotatedChildren != null && - widget.nonRotatedChildren.isNotEmpty) + if (widget.nonRotatedChildren.isNotEmpty) ...widget.nonRotatedChildren, - if (widget.nonRotatedLayers != null && - widget.nonRotatedLayers.isNotEmpty) + if (widget.nonRotatedLayers.isNotEmpty) ...widget.nonRotatedLayers.map( (layer) => _createLayer(layer, options.plugins), ) @@ -168,10 +164,9 @@ class FlutterMapState extends MapGestureMixin { if (options is OverlayImageLayerOptions) { return OverlayImageLayer(options, mapState, _merge(options)); } - assert(false, """ + throw (StateError(""" Can't find correct layer for $options. Perhaps when you create your FlutterMap you need something like this: - options: new MapOptions(plugins: [MyFlutterMapPlugin()])"""); - return null; + options: new MapOptions(plugins: [MyFlutterMapPlugin()])""")); } } diff --git a/lib/src/map/map.dart b/lib/src/map/map.dart index b8f534d27..cd7440188 100644 --- a/lib/src/map/map.dart +++ b/lib/src/map/map.dart @@ -13,7 +13,7 @@ class MapControllerImpl implements MapController { final Completer _readyCompleter = Completer(); final StreamController _mapEventSink = StreamController.broadcast(); StreamSink get mapEventSink => _mapEventSink.sink; - MapState _state; + late MapState _state; @override Future get onReady => _readyCompleter.future; @@ -31,13 +31,13 @@ class MapControllerImpl implements MapController { @override MoveAndRotateResult moveAndRotate(LatLng center, double zoom, double degree, - {String id}) { + {String? id}) { return _state.moveAndRotate(center, zoom, degree, - source: MapEventSource.mapController, id: id); + source: MapEventSource.mapController, id: id!); } @override - bool move(LatLng center, double zoom, {String id}) { + bool move(LatLng center, double zoom, {String? id}) { return _state.move(center, zoom, id: id, source: MapEventSource.mapController); } @@ -45,20 +45,21 @@ class MapControllerImpl implements MapController { @override void fitBounds( LatLngBounds bounds, { - FitBoundsOptions options = + FitBoundsOptions? options = const FitBoundsOptions(padding: EdgeInsets.all(12.0)), }) { - _state.fitBounds(bounds, options); + _state.fitBounds(bounds, options!); } @override + // TODO could it happen at all that _state isn't set here? bool get ready => _state != null; @override LatLng get center => _state.center; @override - LatLngBounds get bounds => _state.bounds; + LatLngBounds? get bounds => _state.bounds; @override double get zoom => _state.zoom; @@ -67,7 +68,7 @@ class MapControllerImpl implements MapController { double get rotation => _state.rotation; @override - bool rotate(double degree, {String id}) { + bool rotate(double degree, {String? id}) { return _state.rotate(degree, id: id, source: MapEventSource.mapController); } @@ -95,10 +96,10 @@ class MapState { double get rotationRad => _rotationRad; - LatLng _lastCenter; - LatLngBounds _lastBounds; - Bounds _lastPixelBounds; - CustomPoint _pixelOrigin; + LatLng? _lastCenter; + LatLngBounds? _lastBounds; + Bounds? _lastPixelBounds; + late CustomPoint _pixelOrigin; bool _initialized = false; MapState(this.options, this.onRotationChanged, this._mapEventSink) @@ -110,15 +111,15 @@ class MapState { Stream get onMoved => _onMoveSink.stream; // Original size of the map where rotation isn't calculated - CustomPoint _originalSize; + CustomPoint? _originalSize; - CustomPoint get originalSize => _originalSize; + CustomPoint? get originalSize => _originalSize; void setOriginalSize(double width, double height) { final isCurrSizeNull = _originalSize == null; if (isCurrSizeNull || - _originalSize.x != width || - _originalSize.y != height) { + _originalSize!.x != width || + _originalSize!.y != height) { _originalSize = CustomPoint(width, height); _updateSizeByOriginalSizeAndRotation(); @@ -131,19 +132,21 @@ class MapState { } // Extended size of the map where rotation is calculated - CustomPoint _size; + CustomPoint? _size; CustomPoint get size => _size ?? CustomPoint(0.0, 0.0); void _updateSizeByOriginalSizeAndRotation() { - final originalWidth = _originalSize.x; - final originalHeight = _originalSize.y; + final originalWidth = _originalSize!.x; + final originalHeight = _originalSize!.y; if (_rotation != 0.0) { final cosAngle = math.cos(_rotationRad).abs(); final sinAngle = math.sin(_rotationRad).abs(); - final width = (originalWidth * cosAngle) + (originalHeight * sinAngle); - final height = (originalHeight * cosAngle) + (originalWidth * sinAngle); + final num width = + (originalWidth * cosAngle) + (originalHeight * sinAngle); + final num height = + (originalHeight * cosAngle) + (originalWidth * sinAngle); _size = CustomPoint(width, height); } else { @@ -155,29 +158,29 @@ class MapState { _initialized = true; } - _pixelOrigin = getNewPixelOrigin(_lastCenter); + _pixelOrigin = getNewPixelOrigin(_lastCenter!); } LatLng get center => getCenter() ?? options.center; - LatLngBounds get bounds => getBounds(); + LatLngBounds? get bounds => getBounds(); Bounds get pixelBounds => getLastPixelBounds(); void _init() { if (options.bounds != null) { - fitBounds(options.bounds, options.boundsOptions); + fitBounds(options.bounds!, options.boundsOptions); } else { - move(options.center, zoom); + move(options.center, zoom, source: MapEventSource.initialization); } } void _handleMoveEmit(LatLng targetCenter, double targetZoom, hasGesture, - MapEventSource source, String id) { + MapEventSource source, String? id) { if (source == MapEventSource.flingAnimationController) { emitMapEvent( MapEventFlingAnimation( - center: _lastCenter, + center: _lastCenter!, zoom: _zoom, targetCenter: targetCenter, targetZoom: targetZoom, @@ -187,7 +190,7 @@ class MapState { } else if (source == MapEventSource.doubleTapZoomAnimationController) { emitMapEvent( MapEventDoubleTapZoom( - center: _lastCenter, + center: _lastCenter!, zoom: _zoom, targetCenter: targetCenter, targetZoom: targetZoom, @@ -198,7 +201,7 @@ class MapState { source == MapEventSource.onMultiFinger) { emitMapEvent( MapEventMove( - center: _lastCenter, + center: _lastCenter!, zoom: _zoom, targetCenter: targetCenter, targetZoom: targetZoom, @@ -209,7 +212,7 @@ class MapState { emitMapEvent( MapEventMove( id: id, - center: _lastCenter, + center: _lastCenter!, zoom: _zoom, targetCenter: targetCenter, targetZoom: targetZoom, @@ -236,8 +239,8 @@ class MapState { double degree, { hasGesture = false, callOnMoveSink = true, - MapEventSource source, - String id, + required MapEventSource source, + String? id, }) { if (degree != _rotation) { var oldRotation = _rotation; @@ -251,7 +254,7 @@ class MapState { id: id, currentRotation: oldRotation, targetRotation: _rotation, - center: _lastCenter, + center: _lastCenter!, zoom: _zoom, source: source, ), @@ -268,7 +271,7 @@ class MapState { } MoveAndRotateResult moveAndRotate(LatLng center, double zoom, double degree, - {MapEventSource source, String id}) { + {required MapEventSource source, required String id}) { final moveSucc = move(center, zoom, id: id, source: source, callOnMoveSink: false); final rotateSucc = @@ -284,12 +287,12 @@ class MapState { bool move(LatLng center, double zoom, {hasGesture = false, callOnMoveSink = true, - MapEventSource source, - String id}) { + required MapEventSource source, + String? id}) { zoom = fitZoomToBounds(zoom); final mapMoved = center != _lastCenter || zoom != _zoom; - if (_lastCenter != null && (!mapMoved || !bounds.isValid)) { + if (_lastCenter != null && (!mapMoved || !bounds!.isValid)) { return false; } @@ -315,20 +318,20 @@ class MapState { var mapPosition = MapPosition( center: center, bounds: bounds, zoom: zoom, hasGesture: hasGesture); - options.onPositionChanged(mapPosition, hasGesture); + options.onPositionChanged!(mapPosition, hasGesture); } return true; } - double fitZoomToBounds(double zoom) { + double fitZoomToBounds(double? zoom) { zoom ??= _zoom; // Abide to min/max zoom if (options.maxZoom != null) { - zoom = (zoom > options.maxZoom) ? options.maxZoom : zoom; + zoom = (zoom > options.maxZoom!) ? options.maxZoom! : zoom; } if (options.minZoom != null) { - zoom = (zoom < options.minZoom) ? options.minZoom : zoom; + zoom = (zoom < options.minZoom!) ? options.minZoom! : zoom; } return zoom; } @@ -338,17 +341,17 @@ class MapState { throw Exception('Bounds are not valid.'); } var target = getBoundsCenterZoom(bounds, options); - move(target.center, target.zoom); + move(target.center, target.zoom, source: MapEventSource.fitBounds); } - LatLng getCenter() { + LatLng? getCenter() { if (_lastCenter != null) { return _lastCenter; } return layerPointToLatLng(_centerLayerPoint); } - LatLngBounds getBounds() { + LatLngBounds? getBounds() { if (_lastBounds != null) { return _lastBounds; } @@ -358,7 +361,7 @@ class MapState { Bounds getLastPixelBounds() { if (_lastPixelBounds != null) { - return _lastPixelBounds; + return _lastPixelBounds!; } return getPixelBounds(zoom); @@ -385,8 +388,8 @@ class MapState { zoom = math.min(options.maxZoom, zoom); var paddingOffset = (paddingBR - paddingTL) / 2; - var swPoint = project(bounds.southWest, zoom); - var nePoint = project(bounds.northEast, zoom); + var swPoint = project(bounds.southWest!, zoom); + var nePoint = project(bounds.northEast!, zoom); var center = unproject((swPoint + nePoint) / 2 + paddingOffset, zoom); return CenterZoom( center: center, @@ -396,7 +399,7 @@ class MapState { double getBoundsZoom(LatLngBounds bounds, CustomPoint padding, {bool inside = false}) { - var zoom = this.zoom ?? 0.0; + var zoom = this.zoom; var min = options.minZoom ?? 0.0; var max = options.maxZoom ?? double.infinity; var nw = bounds.northWest; @@ -414,14 +417,14 @@ class MapState { return math.max(min, math.min(max, zoom)); } - CustomPoint project(LatLng latlng, [double zoom]) { + CustomPoint project(LatLng latlng, [double? zoom]) { zoom ??= _zoom; return options.crs.latLngToPoint(latlng, zoom); } - LatLng unproject(CustomPoint point, [double zoom]) { + LatLng unproject(CustomPoint point, [double? zoom]) { zoom ??= _zoom; - return options.crs.pointToLatLng(point, zoom); + return options.crs.pointToLatLng(point, zoom)!; } LatLng layerPointToLatLng(CustomPoint point) { @@ -432,19 +435,19 @@ class MapState { return size / 2; } - double getZoomScale(double toZoom, double fromZoom) { + double getZoomScale(double toZoom, double? fromZoom) { var crs = options.crs; fromZoom = fromZoom ?? _zoom; return crs.scale(toZoom) / crs.scale(fromZoom); } - double getScaleZoom(double scale, double fromZoom) { + double getScaleZoom(double scale, double? fromZoom) { var crs = options.crs; fromZoom = fromZoom ?? _zoom; - return crs.zoom(scale * crs.scale(fromZoom)); + return crs.zoom(scale * crs.scale(fromZoom)) as double; } - Bounds getPixelWorldBounds(double zoom) { + Bounds? getPixelWorldBounds(double? zoom) { return options.crs.getProjectedBounds(zoom ?? _zoom); } @@ -452,7 +455,7 @@ class MapState { return _pixelOrigin; } - CustomPoint getNewPixelOrigin(LatLng center, [double zoom]) { + CustomPoint getNewPixelOrigin(LatLng center, [double? zoom]) { var viewHalf = size / 2.0; return (project(center, zoom) - viewHalf).round(); } @@ -465,9 +468,7 @@ class MapState { return Bounds(pixelCenter - halfSize, pixelCenter + halfSize); } - static MapState of(BuildContext context, {bool nullOk = false}) { - assert(context != null); - assert(nullOk != null); + static MapState? maybeOf(BuildContext context, {bool nullOk = false}) { final widget = context.dependOnInheritedWidgetOfExactType(); if (nullOk || widget != null) { diff --git a/lib/src/map/map_state_widget.dart b/lib/src/map/map_state_widget.dart index 9e97d05ea..661409229 100644 --- a/lib/src/map/map_state_widget.dart +++ b/lib/src/map/map_state_widget.dart @@ -6,9 +6,9 @@ class MapStateInheritedWidget extends InheritedWidget { final MapState mapState; MapStateInheritedWidget({ - Key key, - @required this.mapState, - @required Widget child, + Key? key, + required this.mapState, + required Widget child, }) : super(key: key, child: child); @override @@ -19,7 +19,7 @@ class MapStateInheritedWidget extends InheritedWidget { return true; } - static MapStateInheritedWidget of(BuildContext context) { + static MapStateInheritedWidget? maybeOf(BuildContext context) { return context .dependOnInheritedWidgetOfExactType(); } diff --git a/pubspec.yaml b/pubspec.yaml index b2f8c68cf..57efb136a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ version: 0.12.0 repository: https://github.com/johnpryan/flutter_map environment: - sdk: ">=2.7.0 <3.0.0" + sdk: '>=2.12.0 <3.0.0' flutter: ">=2.0.0" dependencies: @@ -19,10 +19,9 @@ dependencies: git: url: "https://github.com/flutter/flutter_image" ref: null-safety - vector_math: ^2.0.0 + vector_math: ^2.1.0 proj4dart: ^1.0.4 - meta: ^1.1.0 - collection: ^1.14.0 + collection: ^1.15.0 dev_dependencies: pedantic: ^1.11.0 diff --git a/test/flutter_map_test.dart b/test/flutter_map_test.dart index 1d7920157..d33a1b292 100644 --- a/test/flutter_map_test.dart +++ b/test/flutter_map_test.dart @@ -18,8 +18,8 @@ class MockHttpClientResponse extends Mock implements HttpClientResponse { HttpClientResponseCompressionState.notCompressed; @override - StreamSubscription> listen(void Function(List event) onData, - {Function onError, void Function() onDone, bool cancelOnError}) { + StreamSubscription> listen(void Function(List event)? onData, + {Function? onError, void Function()? onDone, bool? cancelOnError}) { return _stream.listen(onData, onError: onError, onDone: onDone, cancelOnError: cancelOnError); } @@ -42,7 +42,7 @@ class MockClient extends Mock implements HttpClient { class MockHttpOverrides extends HttpOverrides { @override - HttpClient createHttpClient(SecurityContext securityContext) => MockClient(); + HttpClient createHttpClient(SecurityContext? securityContext) => MockClient(); } void main() { From 413495607f94abc48e63d380abbe2a690cc13dcf Mon Sep 17 00:00:00 2001 From: escamoteur Date: Tue, 23 Mar 2021 17:30:27 +0100 Subject: [PATCH 06/16] removed .packages from repository --- .packages | 86 ------------------------------------------------------- 1 file changed, 86 deletions(-) delete mode 100644 .packages diff --git a/.packages b/.packages deleted file mode 100644 index 2b85cc504..000000000 --- a/.packages +++ /dev/null @@ -1,86 +0,0 @@ -# This file is deprecated. Tools should instead consume -# `.dart_tools/package_config.json`. -# -# For more info see: https://dart.dev/go/dot-packages-deprecation -# -# Generated by pub on 2021-03-22 15:51:25.463978. -_fe_analyzer_shared:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/_fe_analyzer_shared-18.0.0/lib/ -analyzer:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/analyzer-1.2.0/lib/ -args:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/args-2.0.0/lib/ -async:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/async-2.5.0/lib/ -boolean_selector:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/boolean_selector-2.1.0/lib/ -build:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/build-1.6.3/lib/ -built_collection:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/built_collection-5.0.0/lib/ -built_value:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/built_value-8.0.3/lib/ -characters:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/characters-1.1.0/lib/ -charcode:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/charcode-1.2.0/lib/ -cli_util:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/cli_util-0.3.0/lib/ -clock:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/clock-1.1.0/lib/ -code_builder:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/code_builder-3.7.0/lib/ -collection:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/collection-1.15.0/lib/ -convert:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/convert-3.0.0/lib/ -coverage:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/coverage-0.15.2/lib/ -crypto:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/crypto-3.0.0/lib/ -dart_style:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/dart_style-1.3.14/lib/ -fake_async:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/fake_async-1.2.0/lib/ -file:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/file-6.1.0/lib/ -fixnum:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/fixnum-1.0.0/lib/ -flutter:file:///C:/Entwicklung/flutter/packages/flutter/lib/ -flutter_image:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/git/flutter_image-b3d792066477efc57c7baa57098cfc3a0164de41/lib/ -flutter_test:file:///C:/Entwicklung/flutter/packages/flutter_test/lib/ -flutter_web_plugins:file:///C:/Entwicklung/flutter/packages/flutter_web_plugins/lib/ -glob:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/glob-2.0.0/lib/ -http_multi_server:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/http_multi_server-3.0.0/lib/ -http_parser:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/http_parser-4.0.0/lib/ -intl:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/intl-0.17.0/lib/ -io:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/io-1.0.0/lib/ -js:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/js-0.6.3/lib/ -latlong2:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/latlong2-0.8.0/lib/ -lists:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/lists-0.1.6/lib/ -location:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/location-4.1.1/lib/ -location_platform_interface:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/location_platform_interface-2.1.0/lib/ -location_web:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/location_web-3.0.0/lib/ -logging:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/logging-0.11.4/lib/ -matcher:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/matcher-0.12.10/lib/ -meta:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/meta-1.3.0/lib/ -mgrs_dart:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/mgrs_dart-1.0.1/lib/ -mime:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/mime-1.0.0/lib/ -mockito:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/mockito-5.0.2/lib/ -node_preamble:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/node_preamble-1.4.13/lib/ -package_config:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/package_config-2.0.0/lib/ -path:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/path-1.8.0/lib/ -pedantic:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/pedantic-1.11.0/lib/ -plugin_platform_interface:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/plugin_platform_interface-2.0.0/lib/ -pool:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/pool-1.5.0/lib/ -positioned_tap_detector_2:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/positioned_tap_detector_2-1.0.0/lib/ -proj4dart:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/proj4dart-1.0.5/lib/ -pub_semver:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/pub_semver-2.0.0/lib/ -quiver:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/quiver-3.0.0/lib/ -shelf:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf-1.1.0/lib/ -shelf_packages_handler:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf_packages_handler-3.0.0/lib/ -shelf_static:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf_static-1.0.0/lib/ -shelf_web_socket:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/shelf_web_socket-1.0.1/lib/ -sky_engine:file:///C:/Entwicklung/flutter/bin/cache/pkg/sky_engine/lib/ -source_gen:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/source_gen-0.9.10+3/lib/ -source_map_stack_trace:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/source_map_stack_trace-2.1.0/lib/ -source_maps:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/source_maps-0.10.10/lib/ -source_span:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/source_span-1.8.0/lib/ -stack_trace:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/stack_trace-1.10.0/lib/ -stream_channel:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/stream_channel-2.1.0/lib/ -string_scanner:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/string_scanner-1.1.0/lib/ -term_glyph:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/term_glyph-1.2.0/lib/ -test:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/test-1.16.5/lib/ -test_api:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/test_api-0.2.19/lib/ -test_core:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/test_core-0.3.15/lib/ -transparent_image:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/transparent_image-2.0.0/lib/ -tuple:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/tuple-2.0.0/lib/ -typed_data:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/typed_data-1.3.0/lib/ -unicode:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/unicode-0.2.4/lib/ -vector_math:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/vector_math-2.1.0/lib/ -vm_service:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/vm_service-6.1.0+1/lib/ -watcher:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/watcher-1.0.0/lib/ -web_socket_channel:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/web_socket_channel-2.0.0/lib/ -webkit_inspection_protocol:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/webkit_inspection_protocol-0.7.5/lib/ -wkt_parser:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/wkt_parser-1.0.7/lib/ -yaml:file:///C:/Users/escam/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/yaml-3.1.0/lib/ -flutter_map:lib/ From 80978510d3dfad7ee21594f6a6719063e8983d9e Mon Sep 17 00:00:00 2001 From: escamoteur Date: Tue, 23 Mar 2021 17:41:03 +0100 Subject: [PATCH 07/16] small fixes --- CHANGELOG.md | 2 +- example/lib/pages/custom_crs/custom_crs.dart | 4 ++-- pubspec.yaml | 5 ++++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 157f6aece..6c360bd6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -249,7 +249,7 @@ release! - Set Dart SDK to 2 ## [0.0.11] - 8/2/2018 -- upgrade to latlong2 from 0.4.0 to 0.5.3 +- upgrade to latlong from 0.4.0 to 0.5.3 ## [0.0.11] - 7/31/2018 - fix LICENSE spelling error diff --git a/example/lib/pages/custom_crs/custom_crs.dart b/example/lib/pages/custom_crs/custom_crs.dart index e124656de..0cc0e8682 100644 --- a/example/lib/pages/custom_crs/custom_crs.dart +++ b/example/lib/pages/custom_crs/custom_crs.dart @@ -32,13 +32,13 @@ class _CustomCrsPageState extends State { super.initState(); // EPSG:4326 is a predefined projection ships with proj4dart - epsg4326 = proj4.Projection('EPSG:4326'); + epsg4326 = proj4.Projection.get('EPSG:4326')!; // EPSG:3413 is a user-defined projection from a valid Proj4 definition string // From: http://epsg.io/3413, proj definition: http://epsg.io/3413.proj4 // Find Projection by name or define it if not exists // TODO the warning here will go away as soon as proj4 is migrated to null safety - epsg3413 = proj4.Projection('EPSG:3413') ?? + epsg3413 = proj4.Projection.get('EPSG:3413') ?? proj4.Projection.add('EPSG:3413', '+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs'); diff --git a/pubspec.yaml b/pubspec.yaml index 57efb136a..41eeb47ae 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -20,7 +20,10 @@ dependencies: url: "https://github.com/flutter/flutter_image" ref: null-safety vector_math: ^2.1.0 - proj4dart: ^1.0.4 + proj4dart: + git: + url: "https://github.com/maRci002/proj4dart" + ref: migrate-null-safety collection: ^1.15.0 dev_dependencies: From 3e7d6b7999aed2eae59a4025c4604593a1ce670e Mon Sep 17 00:00:00 2001 From: escamoteur Date: Thu, 25 Mar 2021 15:56:37 +0100 Subject: [PATCH 08/16] Update lib/src/core/point.dart Co-authored-by: Sata51 --- lib/src/core/point.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/core/point.dart b/lib/src/core/point.dart index 604c68993..19b6cef0e 100644 --- a/lib/src/core/point.dart +++ b/lib/src/core/point.dart @@ -39,8 +39,8 @@ class CustomPoint extends math.Point { } CustomPoint round() { - num x = this.x is double ? this.x.round() : this.x; - num y = this.y is double ? this.y.round() : this.y; + final x = this.x is double ? this.x.round() : this.x; + final y = this.y is double ? this.y.round() : this.y; return CustomPoint(x, y); } From 490f3677043b117701315230c147ca818f729e04 Mon Sep 17 00:00:00 2001 From: escamoteur Date: Thu, 25 Mar 2021 15:57:05 +0100 Subject: [PATCH 09/16] Update pubspec.yaml Co-authored-by: Sata51 --- pubspec.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index 41eeb47ae..8557e554c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -20,10 +20,7 @@ dependencies: url: "https://github.com/flutter/flutter_image" ref: null-safety vector_math: ^2.1.0 - proj4dart: - git: - url: "https://github.com/maRci002/proj4dart" - ref: migrate-null-safety + proj4dart: ^2.0.0 collection: ^1.15.0 dev_dependencies: From 42ce971a7bbff4bb2bef7a3a95ff0ec99b96bbc7 Mon Sep 17 00:00:00 2001 From: escamoteur Date: Thu, 25 Mar 2021 15:57:41 +0100 Subject: [PATCH 10/16] Update lib/src/gestures/latlng_tween.dart Co-authored-by: Sata51 --- lib/src/gestures/latlng_tween.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/src/gestures/latlng_tween.dart b/lib/src/gestures/latlng_tween.dart index 65d8ac746..145778da8 100644 --- a/lib/src/gestures/latlng_tween.dart +++ b/lib/src/gestures/latlng_tween.dart @@ -1,5 +1,4 @@ import 'package:flutter/animation.dart'; -import 'package:flutter/foundation.dart'; import 'package:latlong2/latlong.dart'; class LatLngTween extends Tween { From aa64b12af528ab4976bff10c21e26857a86a72c0 Mon Sep 17 00:00:00 2001 From: alt Date: Thu, 25 Mar 2021 20:20:42 +0430 Subject: [PATCH 11/16] type '_ControllerStream' is not a subtype of type 'Stream' of 'stream' --- lib/src/layer/tile_layer.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/layer/tile_layer.dart b/lib/src/layer/tile_layer.dart index 24e8c3626..134dc92f4 100644 --- a/lib/src/layer/tile_layer.dart +++ b/lib/src/layer/tile_layer.dart @@ -513,7 +513,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { _throttleUpdate = StreamController(sync: true); _throttleUpdate!.stream .transform( - util.throttleStreamTransformerWithTrailingCall( + util.throttleStreamTransformerWithTrailingCall( options.updateInterval, ), ) From 74394491ba081dcfe9b961cc6e8a45453f9a73a4 Mon Sep 17 00:00:00 2001 From: escamoteur Date: Thu, 25 Mar 2021 17:14:51 +0100 Subject: [PATCH 12/16] changes according to review --- lib/src/core/bounds.dart | 25 ++++++++++--------------- lib/src/geo/crs/crs.dart | 4 ---- pubspec.yaml | 11 +++++++---- 3 files changed, 17 insertions(+), 23 deletions(-) diff --git a/lib/src/core/bounds.dart b/lib/src/core/bounds.dart index c77f729ba..4801b1b8f 100644 --- a/lib/src/core/bounds.dart +++ b/lib/src/core/bounds.dart @@ -19,21 +19,16 @@ class Bounds { /// Creates a new [Bounds] obtained by expanding the current ones with a new /// point. Bounds extend(CustomPoint point) { - CustomPoint newMin; - CustomPoint newMax; - // TODO had this any functionality before? - if (min == null && max == null) { - newMin = point; - newMax = point; - } else { - var minX = math.min(point.x, min.x); - var maxX = math.max(point.x, max.x); - var minY = math.min(point.y, min.y); - var maxY = math.max(point.y, max.y); - newMin = CustomPoint(minX, minY); - newMax = CustomPoint(maxX, maxY); - } - return Bounds._(newMin, newMax); + return Bounds._( + CustomPoint( + math.min(point.x, min.x), + math.min(point.y, min.y), + ), + CustomPoint( + math.max(point.x, max.x), + math.max(point.y, max.y), + ), + ); } /// This [Bounds] cental point. diff --git a/lib/src/geo/crs/crs.dart b/lib/src/geo/crs/crs.dart index d6b3578bb..fad20c1be 100644 --- a/lib/src/geo/crs/crs.dart +++ b/lib/src/geo/crs/crs.dart @@ -311,10 +311,6 @@ class Proj4Crs extends Crs { var nextZoom = downZoom + 1; var nextScale = _scales[nextZoom]; - /// TODO would a null scale be valid - if (nextScale == null) { - return double.infinity; - } var scaleDiff = nextScale - downScale; return (scale - downScale) / scaleDiff + downZoom; } diff --git a/pubspec.yaml b/pubspec.yaml index 8557e554c..ddd67f882 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,10 +15,7 @@ dependencies: positioned_tap_detector_2: ^1.0.0 transparent_image: ^2.0.0 async: ^2.1.0 - flutter_image: - git: - url: "https://github.com/flutter/flutter_image" - ref: null-safety + flutter_image: any vector_math: ^2.1.0 proj4dart: ^2.0.0 collection: ^1.15.0 @@ -30,3 +27,9 @@ dev_dependencies: sdk: flutter test: ^1.16.5 mockito: ^5.0.2 + +dependency_override: + flutter_image: + git: + url: "https://github.com/flutter/flutter_image" + ref: null-safety \ No newline at end of file From 14c91b1365c9af99a2879bd7c779980e503e9565 Mon Sep 17 00:00:00 2001 From: escamoteur Date: Fri, 2 Apr 2021 21:25:08 +0200 Subject: [PATCH 13/16] made key nullable --- lib/src/layer/polygon_layer.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/layer/polygon_layer.dart b/lib/src/layer/polygon_layer.dart index bff6baf26..24597d0d8 100644 --- a/lib/src/layer/polygon_layer.dart +++ b/lib/src/layer/polygon_layer.dart @@ -12,7 +12,7 @@ class PolygonLayerOptions extends LayerOptions { /// screen space culling of polygons based on bounding box PolygonLayerOptions({ - required Key key, + Key? key, this.polygons = const [], this.polygonCulling = false, required Stream rebuild, From 3a4ff10952d3656aba150cca8c55fd4cce8144ae Mon Sep 17 00:00:00 2001 From: escamoteur Date: Fri, 2 Apr 2021 21:28:22 +0200 Subject: [PATCH 14/16] made rebuild nullable again --- lib/src/layer/polygon_layer.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/layer/polygon_layer.dart b/lib/src/layer/polygon_layer.dart index 24597d0d8..7284aec53 100644 --- a/lib/src/layer/polygon_layer.dart +++ b/lib/src/layer/polygon_layer.dart @@ -15,7 +15,7 @@ class PolygonLayerOptions extends LayerOptions { Key? key, this.polygons = const [], this.polygonCulling = false, - required Stream rebuild, + Stream? rebuild, }) : super(key: key, rebuild: rebuild) { if (polygonCulling) { for (var polygon in polygons) { From 7736df4b169dc71817160bc594fa3e5330dd82f3 Mon Sep 17 00:00:00 2001 From: Ahmed-gubara Date: Tue, 6 Apr 2021 16:00:47 +0200 Subject: [PATCH 15/16] Fix polyline border drawing --- lib/src/layer/polyline_layer.dart | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/src/layer/polyline_layer.dart b/lib/src/layer/polyline_layer.dart index 66e50dd70..b114748bb 100644 --- a/lib/src/layer/polyline_layer.dart +++ b/lib/src/layer/polyline_layer.dart @@ -174,24 +174,22 @@ class PolylinePainter extends CustomPainter { if (polylineOpt.isDotted) { var spacing = polylineOpt.strokeWidth * 1.5; canvas.saveLayer(rect, Paint()); - if (borderPaint != null) { + if (borderPaint != null && filterPaint != null) { _paintDottedLine( canvas, polylineOpt.offsets, borderRadius, spacing, borderPaint); _paintDottedLine( - canvas, polylineOpt.offsets, radius, spacing, filterPaint!); + canvas, polylineOpt.offsets, radius, spacing, filterPaint); } _paintDottedLine(canvas, polylineOpt.offsets, radius, spacing, paint); canvas.restore(); } else { paint.style = PaintingStyle.stroke; canvas.saveLayer(rect, Paint()); - if (borderPaint != null) { - if (filterPaint != null) { - filterPaint.style = PaintingStyle.stroke; - _paintLine(canvas, polylineOpt.offsets, borderPaint); - } + if (borderPaint != null && filterPaint != null) { borderPaint.style = PaintingStyle.stroke; - _paintLine(canvas, polylineOpt.offsets, filterPaint!); + _paintLine(canvas, polylineOpt.offsets, borderPaint); + filterPaint.style = PaintingStyle.stroke; + _paintLine(canvas, polylineOpt.offsets, filterPaint); } _paintLine(canvas, polylineOpt.offsets, paint); canvas.restore(); From d946ac1f47bd91935fdbbc662e13914d22b23e89 Mon Sep 17 00:00:00 2001 From: escamoteur Date: Thu, 8 Apr 2021 08:46:29 +0200 Subject: [PATCH 16/16] corrected typo in dependency_overrides --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index ddd67f882..96eede055 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -28,7 +28,7 @@ dev_dependencies: test: ^1.16.5 mockito: ^5.0.2 -dependency_override: +dependency_overrides: flutter_image: git: url: "https://github.com/flutter/flutter_image"