From 911ca0d833dc444587e1cca60055fe0c8b5dea3b Mon Sep 17 00:00:00 2001 From: John Ryan Date: Fri, 19 Mar 2021 16:03:14 -0700 Subject: [PATCH 01/46] Add actions/stale@v3 GitHub Action patched version --- flutter_map.iml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 dfb91efa1cd77fc288baa88f143828cf08d3bac9 Mon Sep 17 00:00:00 2001 From: escamoteur Date: Wed, 6 Jan 2021 12:45:57 +0100 Subject: [PATCH 02/46] 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 49119d163e07155338a2d2d444d3af8b5a5d15d3 Mon Sep 17 00:00:00 2001 From: escamoteur Date: Mon, 22 Mar 2021 09:03:11 +0100 Subject: [PATCH 03/46] 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 30cf88d53..e1df6a8a7 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: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; @@ -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 357f1fe05..633a033dc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,10 +10,10 @@ environment: dependencies: flutter: sdk: flutter - tuple: ^1.0.2 + tuple: ^2.0.0 latlong2: ^0.8.0 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 f084f2ae84e45652ef39e15b525543c27b3867ce Mon Sep 17 00:00:00 2001 From: escamoteur Date: Mon, 22 Mar 2021 10:25:44 +0100 Subject: [PATCH 04/46] updated latlong import --- .packages | 9 +- CHANGELOG.md | 2 +- example/lib/pages/scalebar_utils.dart | 36 ++----- lib/src/geo/latlng_bounds.dart | 1 + lib/src/gestures/gestures.dart | 141 +++++++++++++++++--------- lib/src/map/flutter_map_state.dart | 22 ++-- pubspec.yaml | 5 +- 7 files changed, 129 insertions(+), 87 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 ede305da3..ae3b3bb9a 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/scalebar_utils.dart b/example/lib/pages/scalebar_utils.dart index 204232445..826574876 100644 --- a/example/lib/pages/scalebar_utils.dart +++ b/example/lib/pages/scalebar_utils.dart @@ -1,4 +1,5 @@ import 'dart:math'; + import 'package:latlong2/latlong.dart'; const double piOver180 = pi / 180.0; @@ -10,8 +11,7 @@ double toRadians(double degrees) { return degrees * piOver180; } -LatLng calculateEndingGlobalCoordinates( - LatLng start, double startBearing, double distance) { +LatLng calculateEndingGlobalCoordinates(LatLng start, double startBearing, double distance) { var mSemiMajorAxis = 6378137.0; //WGS84 major axis var mSemiMinorAxis = (1.0 - 1.0 / 298.257223563) * 6378137.0; var mFlattening = 1.0 / 298.257223563; @@ -42,13 +42,10 @@ LatLng calculateEndingGlobalCoordinates( var uSquared = cos2Alpha * (aSquared - bSquared) / bSquared; // eq. 3 - var A = 1 + - (uSquared / 16384) * - (4096 + uSquared * (-768 + uSquared * (320 - 175 * uSquared))); + var A = 1 + (uSquared / 16384) * (4096 + uSquared * (-768 + uSquared * (320 - 175 * uSquared))); // eq. 4 - var B = (uSquared / 1024) * - (256 + uSquared * (-128 + uSquared * (74 - 47 * uSquared))); + var B = (uSquared / 1024) * (256 + uSquared * (-128 + uSquared * (74 - 47 * uSquared))); // iterate until there is a negligible change in sigma double deltaSigma; @@ -74,10 +71,7 @@ LatLng calculateEndingGlobalCoordinates( (cosSigmaM2 + (B / 4.0) * (cosSignma * (-1 + 2 * cos2SigmaM2) - - (B / 6.0) * - cosSigmaM2 * - (-3 + 4 * sinSigma * sinSigma) * - (-3 + 4 * cos2SigmaM2))); + (B / 6.0) * cosSigmaM2 * (-3 + 4 * sinSigma * sinSigma) * (-3 + 4 * cos2SigmaM2))); // eq. 7 sigma = sOverbA + deltaSigma; @@ -96,11 +90,8 @@ LatLng calculateEndingGlobalCoordinates( sinSigma = sin(sigma); // eq. 8 - var phi2 = atan2( - sinU1 * cosSigma + cosU1 * sinSigma * cosAlpha1, - (1.0 - f) * - sqrt(sin2Alpha + - pow(sinU1 * sinSigma - cosU1 * cosSigma * cosAlpha1, 2.0))); + var phi2 = atan2(sinU1 * cosSigma + cosU1 * sinSigma * cosAlpha1, + (1.0 - f) * sqrt(sin2Alpha + pow(sinU1 * sinSigma - cosU1 * cosSigma * cosAlpha1, 2.0))); // eq. 9 // This fixes the pole crossing defect spotted by Matt Feemster. When a @@ -112,21 +103,14 @@ LatLng calculateEndingGlobalCoordinates( // double tanLambda = sinSigma * sinAlpha1 / (cosU1 * cosSigma - sinU1 * // sinSigma * cosAlpha1); // double lambda = Math.atan(tanLambda); - var lambda = atan2( - sinSigma * sinAlpha1, (cosU1 * cosSigma - sinU1 * sinSigma * cosAlpha1)); + var lambda = atan2(sinSigma * sinAlpha1, (cosU1 * cosSigma - sinU1 * sinSigma * cosAlpha1)); // eq. 10 var C = (f / 16) * cos2Alpha * (4 + f * (4 - 3 * cos2Alpha)); // eq. 11 - var L = lambda - - (1 - C) * - f * - sinAlpha * - (sigma + - C * - sinSigma * - (cosSigmaM2 + C * cosSigma * (-1 + 2 * cos2SigmaM2))); + var L = + lambda - (1 - C) * f * sinAlpha * (sigma + C * sinSigma * (cosSigmaM2 + C * cosSigma * (-1 + 2 * cos2SigmaM2))); // eq. 12 // double alpha2 = Math.atan2(sinAlpha, -sinU1 * sinSigma + cosU1 * diff --git a/lib/src/geo/latlng_bounds.dart b/lib/src/geo/latlng_bounds.dart index ad3983411..7e0f0a0e7 100644 --- a/lib/src/geo/latlng_bounds.dart +++ b/lib/src/geo/latlng_bounds.dart @@ -1,4 +1,5 @@ import 'dart:math' as math; + import 'package:latlong2/latlong.dart'; class LatLngBounds { diff --git a/lib/src/gestures/gestures.dart b/lib/src/gestures/gestures.dart index e1df6a8a7..30cf88d53 100644 --- a/lib/src/gestures/gestures.dart +++ b/lib/src/gestures/gestures.dart @@ -9,7 +9,8 @@ import 'package:flutter_map/src/map/map.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/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/pubspec.yaml b/pubspec.yaml index 633a033dc..b2f8c68cf 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,10 @@ dependencies: 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 From 98ebcff6d84744ecc2aaf3c7441574454da4deda Mon Sep 17 00:00:00 2001 From: escamoteur Date: Mon, 22 Mar 2021 17:34:34 +0100 Subject: [PATCH 05/46] migrated to unsound null safety --- .packages | 160 +++++------ example/ios/Flutter/Debug.xcconfig | 1 + example/ios/Flutter/Release.xcconfig | 1 + .../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/marker_rotate.dart | 22 +- 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 | 54 ++-- lib/src/layer/overlay_image_layer.dart | 14 +- lib/src/layer/polygon_layer.dart | 32 +-- lib/src/layer/polyline_layer.dart | 88 +++---- 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 +- 42 files changed, 732 insertions(+), 718 deletions(-) diff --git a/.packages b/.packages index c8543ee3b..79b2eca8a 100644 --- a/.packages +++ b/.packages @@ -3,84 +3,84 @@ # # For more info see: https://dart.dev/go/dot-packages-deprecation # -# 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/ -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/ +# Generated by pub on 2021-04-08 11:39:55.089104. +_fe_analyzer_shared:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/_fe_analyzer_shared-20.0.0/lib/ +analyzer:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-1.4.0/lib/ +args:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/args-2.0.0/lib/ +async:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.5.0/lib/ +boolean_selector:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/boolean_selector-2.1.0/lib/ +build:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/build-1.6.3/lib/ +built_collection:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/built_collection-5.0.0/lib/ +built_value:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/built_value-8.0.4/lib/ +characters:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/characters-1.1.0/lib/ +charcode:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/charcode-1.2.0/lib/ +cli_util:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/cli_util-0.3.0/lib/ +clock:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/clock-1.1.0/lib/ +code_builder:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/code_builder-3.7.0/lib/ +collection:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/collection-1.15.0/lib/ +convert:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/convert-3.0.0/lib/ +coverage:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/coverage-0.15.2/lib/ +crypto:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/crypto-3.0.1/lib/ +dart_style:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/dart_style-1.3.14/lib/ +fake_async:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/fake_async-1.2.0/lib/ +file:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/file-6.1.0/lib/ +fixnum:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/fixnum-1.0.0/lib/ +flutter:file:///Users/kengu/Library/flutter/packages/flutter/lib/ +flutter_image:file:///Users/kengu/Library/flutter/.pub-cache/git/flutter_image-b3d792066477efc57c7baa57098cfc3a0164de41/lib/ +flutter_test:file:///Users/kengu/Library/flutter/packages/flutter_test/lib/ +flutter_web_plugins:file:///Users/kengu/Library/flutter/packages/flutter_web_plugins/lib/ +glob:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/glob-2.0.1/lib/ +http_multi_server:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/http_multi_server-3.0.0/lib/ +http_parser:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/http_parser-4.0.0/lib/ +intl:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/intl-0.17.0/lib/ +io:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/io-1.0.0/lib/ +js:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/js-0.6.3/lib/ +latlong2:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/latlong2-0.8.0/lib/ +lists:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/lists-0.1.6/lib/ +location:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/location-4.1.1/lib/ +location_platform_interface:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/location_platform_interface-2.1.0/lib/ +location_web:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/location_web-3.0.0/lib/ +logging:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/logging-0.11.4/lib/ +matcher:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.10/lib/ +meta:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0/lib/ +mgrs_dart:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/mgrs_dart-1.0.1/lib/ +mime:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/mime-1.0.0/lib/ +mockito:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/mockito-5.0.3/lib/ +node_preamble:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/node_preamble-1.4.13/lib/ +package_config:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/package_config-2.0.0/lib/ +path:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/path-1.8.0/lib/ +pedantic:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/pedantic-1.11.0/lib/ +plugin_platform_interface:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/plugin_platform_interface-2.0.0/lib/ +pool:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/pool-1.5.0/lib/ +positioned_tap_detector_2:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/positioned_tap_detector_2-1.0.0/lib/ +proj4dart:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/proj4dart-1.0.5/lib/ +pub_semver:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/pub_semver-2.0.0/lib/ +quiver:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/quiver-3.0.1/lib/ +shelf:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/shelf-1.1.0/lib/ +shelf_packages_handler:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/shelf_packages_handler-3.0.0/lib/ +shelf_static:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/shelf_static-1.0.0/lib/ +shelf_web_socket:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/shelf_web_socket-1.0.1/lib/ +sky_engine:file:///Users/kengu/Library/flutter/bin/cache/pkg/sky_engine/lib/ +source_gen:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/source_gen-0.9.10+3/lib/ +source_map_stack_trace:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/source_map_stack_trace-2.1.0/lib/ +source_maps:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/source_maps-0.10.10/lib/ +source_span:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/source_span-1.8.0/lib/ +stack_trace:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.10.0/lib/ +stream_channel:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/stream_channel-2.1.0/lib/ +string_scanner:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.1.0/lib/ +term_glyph:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.2.0/lib/ +test:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/test-1.16.5/lib/ +test_api:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/test_api-0.2.19/lib/ +test_core:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/test_core-0.3.15/lib/ +transparent_image:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/transparent_image-2.0.0/lib/ +tuple:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/tuple-2.0.0/lib/ +typed_data:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/typed_data-1.3.0/lib/ +unicode:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/unicode-0.2.4/lib/ +vector_math:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.1.0/lib/ +vm_service:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/vm_service-6.2.0/lib/ +watcher:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/watcher-1.0.0/lib/ +web_socket_channel:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/web_socket_channel-2.0.0/lib/ +webkit_inspection_protocol:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/webkit_inspection_protocol-0.7.5/lib/ +wkt_parser:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/wkt_parser-1.0.7/lib/ +yaml:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/yaml-3.1.0/lib/ flutter_map:lib/ diff --git a/example/ios/Flutter/Debug.xcconfig b/example/ios/Flutter/Debug.xcconfig index 592ceee85..ec97fc6f3 100644 --- a/example/ios/Flutter/Debug.xcconfig +++ b/example/ios/Flutter/Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/example/ios/Flutter/Release.xcconfig b/example/ios/Flutter/Release.xcconfig index 592ceee85..c4855bfe2 100644 --- a/example/ios/Flutter/Release.xcconfig +++ b/example/ios/Flutter/Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" 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/marker_rotate.dart b/example/lib/pages/marker_rotate.dart index 95cc72ced..b976a32a7 100644 --- a/example/lib/pages/marker_rotate.dart +++ b/example/lib/pages/marker_rotate.dart @@ -13,9 +13,9 @@ class MarkerRotatePage extends StatefulWidget { } class MarkerRotatePageState extends State { - bool rotateMarkerLondon; - bool rotateMarkerDublin; - bool rotateMarkerParis; + bool? rotateMarkerLondon; + bool? rotateMarkerDublin; + bool? rotateMarkerParis; bool rotateMarkerLayerOptions = false; @override @@ -33,7 +33,7 @@ class MarkerRotatePageState extends State { setState(() { if (rotateMarkerLondon == null) { rotateMarkerLondon = true; - } else if (rotateMarkerLondon) { + } else if (rotateMarkerLondon != null) { rotateMarkerLondon = false; } else { rotateMarkerLondon = null; @@ -45,7 +45,7 @@ class MarkerRotatePageState extends State { setState(() { if (rotateMarkerDublin == null) { rotateMarkerDublin = true; - } else if (rotateMarkerDublin) { + } else if (rotateMarkerDublin != null) { rotateMarkerDublin = false; } else { rotateMarkerDublin = null; @@ -57,7 +57,7 @@ class MarkerRotatePageState extends State { setState(() { if (rotateMarkerParis == null) { rotateMarkerParis = true; - } else if (rotateMarkerParis) { + } else if (rotateMarkerParis != null) { rotateMarkerParis = false; } else { rotateMarkerParis = null; @@ -108,8 +108,7 @@ class MarkerRotatePageState extends State { children: [ Padding( padding: EdgeInsets.only(top: 8.0, bottom: 8.0), - child: - Text('Markers can be counter rotated to the map rotation.'), + child: Text('Markers can be counter rotated to the map rotation.'), ), Padding( padding: EdgeInsets.only(top: 8.0, bottom: 8.0), @@ -117,8 +116,7 @@ class MarkerRotatePageState extends State { children: [ MaterialButton( onPressed: _setRotateMarkerLayerOptions, - child: - Text('Set by LayerOptions: $rotateMarkerLayerOptions'), + child: Text('Set by LayerOptions: $rotateMarkerLayerOptions'), ), MaterialButton( onPressed: _setRotateMarkerLondon, @@ -143,9 +141,7 @@ class MarkerRotatePageState extends State { ), layers: [ TileLayerOptions( - urlTemplate: - 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', - subdomains: ['a', 'b', 'c']), + urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', subdomains: ['a', 'b', 'c']), MarkerLayerOptions( rotate: rotateMarkerLayerOptions, markers: markers, 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 1d758e90d..1308ff39b 100644 --- a/lib/src/layer/marker_layer.dart +++ b/lib/src/layer/marker_layer.dart @@ -8,14 +8,14 @@ class MarkerLayerOptions extends LayerOptions { final List markers; /// If true markers will be counter rotated to the map rotation - final bool rotate; + final bool? rotate; /// The origin of the coordinate system (relative to the upper left corner of /// this render object) in which to apply the matrix. /// /// Setting an origin is equivalent to conjugating the transform matrix by a /// translation. This property is provided just for convenience. - final Offset rotateOrigin; + final Offset? rotateOrigin; /// The alignment of the origin, relative to the size of the box. /// @@ -29,15 +29,15 @@ class MarkerLayerOptions extends LayerOptions { /// same as an [Alignment] whose [Alignment.x] value is `1.0` if /// [Directionality.of] returns [TextDirection.ltr], and `-1.0` if /// [Directionality.of] returns [TextDirection.rtl]. - final AlignmentGeometry rotateAlignment; + final AlignmentGeometry? rotateAlignment; MarkerLayerOptions({ - Key key, + Key? key, this.markers = const [], this.rotate = false, this.rotateOrigin, this.rotateAlignment = Alignment.center, - Stream rebuild, + Stream? rebuild, }) : super(key: key, rebuild: rebuild); } @@ -79,8 +79,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}.'); @@ -95,6 +95,7 @@ class AnchorPos { } enum AnchorAlign { + none, left, right, top, @@ -110,14 +111,14 @@ class Marker { final Anchor anchor; /// If true marker will be counter rotated to the map rotation - final bool rotate; + final bool? rotate; /// The origin of the coordinate system (relative to the upper left corner of /// this render object) in which to apply the matrix. /// /// Setting an origin is equivalent to conjugating the transform matrix by a /// translation. This property is provided just for convenience. - final Offset rotateOrigin; + final Offset? rotateOrigin; /// The alignment of the origin, relative to the size of the box. /// @@ -131,28 +132,28 @@ class Marker { /// same as an [Alignment] whose [Alignment.x] value is `1.0` if /// [Directionality.of] returns [TextDirection.ltr], and `-1.0` if /// [Directionality.of] returns [TextDirection.rtl]. - final AlignmentGeometry rotateAlignment; + final AlignmentGeometry? rotateAlignment; Marker({ - this.point, - this.builder, + required this.point, + required this.builder, this.width = 30.0, this.height = 30.0, this.rotate, this.rotateOrigin, this.rotateAlignment, - 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); } } @@ -160,10 +161,9 @@ class MarkerLayerWidget extends StatelessWidget { class MarkerLayer extends StatelessWidget { final MarkerLayerOptions markerLayerOptions; final MapState map; - final Stream stream; + final Stream? stream; - MarkerLayer(this.markerLayerOptions, this.map, this.stream) - : super(key: markerLayerOptions.key); + MarkerLayer(this.markerLayerOptions, this.map, this.stream) : super(key: markerLayerOptions.key); bool _boundsContainsMarker(Marker marker) { var pixelPoint = map.project(marker.point); @@ -178,32 +178,28 @@ 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 markerLayerOptions.markers) { var pos = map.project(markerOpt.point); - pos = pos.multiplyBy(map.getZoomScale(map.zoom, map.zoom)) - - map.getPixelOrigin(); + pos = pos.multiplyBy(map.getZoomScale(map.zoom, map.zoom)) - map.getPixelOrigin(); - var pixelPosX = - (pos.x - (markerOpt.width - markerOpt.anchor.left)).toDouble(); - var pixelPosY = - (pos.y - (markerOpt.height - markerOpt.anchor.top)).toDouble(); + var pixelPosX = (pos.x - (markerOpt.width - markerOpt.anchor.left)).toDouble(); + var pixelPosY = (pos.y - (markerOpt.height - markerOpt.anchor.top)).toDouble(); if (!_boundsContainsMarker(markerOpt)) { continue; } Widget marker; - if (markerOpt.rotate ?? markerLayerOptions.rotate) { + if (markerOpt.rotate ?? markerLayerOptions.rotate ?? false) { // Counter rotated marker to the map rotation marker = Transform.rotate( angle: -map.rotationRad, origin: markerOpt.rotateOrigin ?? markerLayerOptions.rotateOrigin, - alignment: markerOpt.rotateAlignment ?? - markerLayerOptions.rotateAlignment, + alignment: markerOpt.rotateAlignment ?? markerLayerOptions.rotateAlignment, child: markerOpt.builder(context), ); } else { 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 30c68bc03..9f8aecfdb 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,10 +62,9 @@ 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); + PolylineLayer(this.polylineOpts, this.map, this.stream) : super(key: polylineOpts.key); @override Widget build(BuildContext context) { @@ -86,8 +85,7 @@ class PolylineLayer extends StatelessWidget { for (var polylineOpt in polylineOpts.polylines) { polylineOpt.offsets.clear(); - if (polylineOpts.polylineCulling && - !polylineOpt.boundingBox.isOverlapping(map.bounds)) { + if (polylineOpts.polylineCulling && !polylineOpt.boundingBox.isOverlapping(map.bounds)) { // skip this polyline as it's offscreen continue; } @@ -114,8 +112,7 @@ class PolylineLayer extends StatelessWidget { var point = points[i]; var pos = map.project(point); - pos = pos.multiplyBy(map.getZoomScale(map.zoom, map.zoom)) - - map.getPixelOrigin(); + pos = pos.multiplyBy(map.getZoomScale(map.zoom, map.zoom)) - map.getPixelOrigin(); offsets.add(Offset(pos.x.toDouble(), pos.y.toDouble())); if (i > 0) { offsets.add(Offset(pos.x.toDouble(), pos.y.toDouble())); @@ -145,15 +142,13 @@ class PolylinePainter extends CustomPainter { if (polylineOpt.gradientColors == null) { paint.color = polylineOpt.color; } else { - polylineOpt.gradientColors.isNotEmpty - ? paint.shader = _paintGradient() - : paint.color = polylineOpt.color; + 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,9 +157,8 @@ class PolylinePainter extends CustomPainter { final borderPaint = polylineOpt.borderStrokeWidth > 0.0 ? (Paint() - ..color = polylineOpt.borderColor - ..strokeWidth = - polylineOpt.strokeWidth + polylineOpt.borderStrokeWidth + ..color = polylineOpt.borderColor ?? Color(0x00000000) + ..strokeWidth = polylineOpt.strokeWidth + polylineOpt.borderStrokeWidth ..strokeCap = StrokeCap.round ..strokeJoin = StrokeJoin.round ..blendMode = BlendMode.srcOver) @@ -175,29 +169,28 @@ class PolylinePainter extends CustomPainter { var spacing = polylineOpt.strokeWidth * 1.5; canvas.saveLayer(rect, Paint()); if (borderPaint != null && filterPaint != null) { - _paintDottedLine( - canvas, polylineOpt.offsets, borderRadius, spacing, borderPaint); - _paintDottedLine( - canvas, polylineOpt.offsets, radius, spacing, filterPaint); + _paintDottedLine(canvas, polylineOpt.offsets, borderRadius, spacing, borderPaint); + _paintDottedLine(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 && filterPaint != null) { + if (borderPaint != null) { + if (filterPaint != null) { + filterPaint.style = PaintingStyle.stroke; + _paintLine(canvas, polylineOpt.offsets, borderPaint); + } borderPaint.style = PaintingStyle.stroke; - _paintLine(canvas, polylineOpt.offsets, borderPaint); - filterPaint.style = PaintingStyle.stroke; - _paintLine(canvas, polylineOpt.offsets, filterPaint); + _paintLine(canvas, polylineOpt.offsets, filterPaint!); } _paintLine(canvas, polylineOpt.offsets, paint); canvas.restore(); } } - void _paintDottedLine(Canvas canvas, List offsets, double radius, - double stepLength, Paint paint) { + void _paintDottedLine(Canvas canvas, List offsets, double radius, double stepLength, Paint paint) { final path = ui.Path(); var startDistance = 0.0; for (var i = 0; i < offsets.length - 1; i++) { @@ -212,12 +205,9 @@ class PolylinePainter extends CustomPainter { path.addOval(Rect.fromCircle(center: offset, radius: radius)); distance += stepLength; } - startDistance = distance < totalDistance - ? stepLength - (totalDistance - distance) - : distance - totalDistance; + startDistance = distance < totalDistance ? stepLength - (totalDistance - distance) : distance - totalDistance; } - path.addOval( - Rect.fromCircle(center: polylineOpt.offsets.last, radius: radius)); + path.addOval(Rect.fromCircle(center: polylineOpt.offsets.last, radius: radius)); canvas.drawPath(path, paint); } @@ -231,20 +221,18 @@ class PolylinePainter extends CustomPainter { } } - ui.Gradient _paintGradient() => ui.Gradient.linear(polylineOpt.offsets.first, - polylineOpt.offsets.last, polylineOpt.gradientColors, _getColorsStop()); + ui.Gradient _paintGradient() => ui.Gradient.linear( + polylineOpt.offsets.first, polylineOpt.offsets.last, polylineOpt.gradientColors!, _getColorsStop()); - List _getColorsStop() => (polylineOpt.colorsStop != null && - polylineOpt.colorsStop.length == polylineOpt.gradientColors.length) - ? polylineOpt.colorsStop - : _calculateColorsStop(); + 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 - .map((gradientColor) => - polylineOpt.gradientColors.indexOf(gradientColor) * - colorsStopInterval) + final colorsStopInterval = 1.0 / polylineOpt.gradientColors!.length; + return polylineOpt.gradientColors! + .map((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 d210359af00f9acdf7415199b32c670adb4d020b Mon Sep 17 00:00:00 2001 From: escamoteur Date: Tue, 23 Mar 2021 17:30:27 +0100 Subject: [PATCH 06/46] 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 79b2eca8a..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-04-08 11:39:55.089104. -_fe_analyzer_shared:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/_fe_analyzer_shared-20.0.0/lib/ -analyzer:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-1.4.0/lib/ -args:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/args-2.0.0/lib/ -async:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.5.0/lib/ -boolean_selector:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/boolean_selector-2.1.0/lib/ -build:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/build-1.6.3/lib/ -built_collection:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/built_collection-5.0.0/lib/ -built_value:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/built_value-8.0.4/lib/ -characters:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/characters-1.1.0/lib/ -charcode:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/charcode-1.2.0/lib/ -cli_util:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/cli_util-0.3.0/lib/ -clock:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/clock-1.1.0/lib/ -code_builder:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/code_builder-3.7.0/lib/ -collection:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/collection-1.15.0/lib/ -convert:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/convert-3.0.0/lib/ -coverage:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/coverage-0.15.2/lib/ -crypto:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/crypto-3.0.1/lib/ -dart_style:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/dart_style-1.3.14/lib/ -fake_async:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/fake_async-1.2.0/lib/ -file:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/file-6.1.0/lib/ -fixnum:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/fixnum-1.0.0/lib/ -flutter:file:///Users/kengu/Library/flutter/packages/flutter/lib/ -flutter_image:file:///Users/kengu/Library/flutter/.pub-cache/git/flutter_image-b3d792066477efc57c7baa57098cfc3a0164de41/lib/ -flutter_test:file:///Users/kengu/Library/flutter/packages/flutter_test/lib/ -flutter_web_plugins:file:///Users/kengu/Library/flutter/packages/flutter_web_plugins/lib/ -glob:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/glob-2.0.1/lib/ -http_multi_server:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/http_multi_server-3.0.0/lib/ -http_parser:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/http_parser-4.0.0/lib/ -intl:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/intl-0.17.0/lib/ -io:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/io-1.0.0/lib/ -js:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/js-0.6.3/lib/ -latlong2:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/latlong2-0.8.0/lib/ -lists:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/lists-0.1.6/lib/ -location:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/location-4.1.1/lib/ -location_platform_interface:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/location_platform_interface-2.1.0/lib/ -location_web:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/location_web-3.0.0/lib/ -logging:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/logging-0.11.4/lib/ -matcher:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.10/lib/ -meta:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0/lib/ -mgrs_dart:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/mgrs_dart-1.0.1/lib/ -mime:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/mime-1.0.0/lib/ -mockito:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/mockito-5.0.3/lib/ -node_preamble:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/node_preamble-1.4.13/lib/ -package_config:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/package_config-2.0.0/lib/ -path:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/path-1.8.0/lib/ -pedantic:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/pedantic-1.11.0/lib/ -plugin_platform_interface:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/plugin_platform_interface-2.0.0/lib/ -pool:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/pool-1.5.0/lib/ -positioned_tap_detector_2:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/positioned_tap_detector_2-1.0.0/lib/ -proj4dart:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/proj4dart-1.0.5/lib/ -pub_semver:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/pub_semver-2.0.0/lib/ -quiver:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/quiver-3.0.1/lib/ -shelf:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/shelf-1.1.0/lib/ -shelf_packages_handler:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/shelf_packages_handler-3.0.0/lib/ -shelf_static:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/shelf_static-1.0.0/lib/ -shelf_web_socket:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/shelf_web_socket-1.0.1/lib/ -sky_engine:file:///Users/kengu/Library/flutter/bin/cache/pkg/sky_engine/lib/ -source_gen:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/source_gen-0.9.10+3/lib/ -source_map_stack_trace:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/source_map_stack_trace-2.1.0/lib/ -source_maps:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/source_maps-0.10.10/lib/ -source_span:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/source_span-1.8.0/lib/ -stack_trace:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.10.0/lib/ -stream_channel:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/stream_channel-2.1.0/lib/ -string_scanner:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.1.0/lib/ -term_glyph:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.2.0/lib/ -test:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/test-1.16.5/lib/ -test_api:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/test_api-0.2.19/lib/ -test_core:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/test_core-0.3.15/lib/ -transparent_image:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/transparent_image-2.0.0/lib/ -tuple:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/tuple-2.0.0/lib/ -typed_data:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/typed_data-1.3.0/lib/ -unicode:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/unicode-0.2.4/lib/ -vector_math:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.1.0/lib/ -vm_service:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/vm_service-6.2.0/lib/ -watcher:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/watcher-1.0.0/lib/ -web_socket_channel:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/web_socket_channel-2.0.0/lib/ -webkit_inspection_protocol:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/webkit_inspection_protocol-0.7.5/lib/ -wkt_parser:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/wkt_parser-1.0.7/lib/ -yaml:file:///Users/kengu/Library/flutter/.pub-cache/hosted/pub.dartlang.org/yaml-3.1.0/lib/ -flutter_map:lib/ From 5633366b3ad537a858c7d919c861fcc3932fa3d0 Mon Sep 17 00:00:00 2001 From: escamoteur Date: Tue, 23 Mar 2021 17:41:03 +0100 Subject: [PATCH 07/46] 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 ae3b3bb9a..ede305da3 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 0bf64bf618ef8af70c10287fccd7bcc9e5847077 Mon Sep 17 00:00:00 2001 From: escamoteur Date: Thu, 25 Mar 2021 15:56:37 +0100 Subject: [PATCH 08/46] 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 c7d523a9f99354d6d899fe7a57925e1c6422436a Mon Sep 17 00:00:00 2001 From: escamoteur Date: Thu, 25 Mar 2021 15:57:05 +0100 Subject: [PATCH 09/46] 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 48f361e7da4ae9acd614470279faf8075143e334 Mon Sep 17 00:00:00 2001 From: escamoteur Date: Thu, 25 Mar 2021 15:57:41 +0100 Subject: [PATCH 10/46] 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 d1be78e9a264db74e9f96673a5f6718491ce304d Mon Sep 17 00:00:00 2001 From: alt Date: Thu, 25 Mar 2021 20:20:42 +0430 Subject: [PATCH 11/46] 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 f2aaf92f3f97b9b759047a8650896b30436f2dff Mon Sep 17 00:00:00 2001 From: escamoteur Date: Thu, 25 Mar 2021 17:14:51 +0100 Subject: [PATCH 12/46] 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 2affa2c17bfab89ceaa8d7b4d5905a7e89714248 Mon Sep 17 00:00:00 2001 From: escamoteur Date: Fri, 2 Apr 2021 21:25:08 +0200 Subject: [PATCH 13/46] 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 34bf6210c1ea3c63f2bd0bd525a82a994c3fd6c0 Mon Sep 17 00:00:00 2001 From: escamoteur Date: Fri, 2 Apr 2021 21:28:22 +0200 Subject: [PATCH 14/46] 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 cd6ec357ce93eb24024228bdb853c5b82fcab7a6 Mon Sep 17 00:00:00 2001 From: Ahmed-gubara Date: Tue, 6 Apr 2021 16:00:47 +0200 Subject: [PATCH 15/46] Fix polyline border drawing --- lib/src/layer/polyline_layer.dart | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/src/layer/polyline_layer.dart b/lib/src/layer/polyline_layer.dart index 9f8aecfdb..981060aa2 100644 --- a/lib/src/layer/polyline_layer.dart +++ b/lib/src/layer/polyline_layer.dart @@ -177,13 +177,11 @@ class PolylinePainter extends CustomPainter { } 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 53be3cea7578161655c8d5101ad4e5e63d8d583e Mon Sep 17 00:00:00 2001 From: escamoteur Date: Thu, 8 Apr 2021 08:46:29 +0200 Subject: [PATCH 16/46] 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" From 8bb439c81493964552e66d5222d455b2c6f4905d Mon Sep 17 00:00:00 2001 From: Kenneth Gulbrandsoy Date: Thu, 8 Apr 2021 11:47:07 +0200 Subject: [PATCH 17/46] Removed unnecessary null-checks --- lib/src/layer/tile_layer.dart | 139 ++++++++++------------------------ lib/src/map/map.dart | 62 +++++---------- 2 files changed, 59 insertions(+), 142 deletions(-) diff --git a/lib/src/layer/tile_layer.dart b/lib/src/layer/tile_layer.dart index 134dc92f4..9fce2d748 100644 --- a/lib/src/layer/tile_layer.dart +++ b/lib/src/layer/tile_layer.dart @@ -16,8 +16,7 @@ import 'package:tuple/tuple.dart'; import 'layer.dart'; -typedef TemplateFunction = String Function( - String str, Map data); +typedef TemplateFunction = String Function(String str, Map data); enum EvictErrorTileStrategy { // never evict error Tiles @@ -269,33 +268,20 @@ class TileLayerOptions extends LayerOptions { this.tileBuilder, this.tilesContainerBuilder, this.evictErrorTileStrategy = EvictErrorTileStrategy.none, - }) : updateInterval = - updateInterval <= 0 ? null : Duration(milliseconds: updateInterval), - tileFadeInDuration = tileFadeInDuration <= 0 - ? null - : Duration(milliseconds: tileFadeInDuration), + }) : updateInterval = updateInterval <= 0 ? null : Duration(milliseconds: updateInterval), + tileFadeInDuration = tileFadeInDuration <= 0 ? null : Duration(milliseconds: tileFadeInDuration), assert(tileFadeInStart >= 0.0 && tileFadeInStart <= 1.0), - assert(tileFadeInStartWhenOverride >= 0.0 && - tileFadeInStartWhenOverride <= 1.0), - maxZoom = - wmsOptions == null && retinaMode && maxZoom > 0.0 && !zoomReverse - ? maxZoom - 1.0 - : maxZoom, + assert(tileFadeInStartWhenOverride >= 0.0 && tileFadeInStartWhenOverride <= 1.0), + maxZoom = wmsOptions == null && retinaMode && maxZoom > 0.0 && !zoomReverse ? maxZoom - 1.0 : maxZoom, minZoom = - wmsOptions == null && retinaMode && maxZoom > 0.0 && zoomReverse - ? math.max(minZoom + 1.0, 0.0) - : minZoom, + wmsOptions == null && retinaMode && maxZoom > 0.0 && zoomReverse ? math.max(minZoom + 1.0, 0.0) : minZoom, zoomOffset = wmsOptions == null && retinaMode && maxZoom > 0.0 ? (zoomReverse ? zoomOffset - 1.0 : zoomOffset + 1.0) : zoomOffset, - tileSize = wmsOptions == null && retinaMode && maxZoom > 0.0 - ? (tileSize / 2.0).floorToDouble() - : tileSize, + tileSize = wmsOptions == null && retinaMode && maxZoom > 0.0 ? (tileSize / 2.0).floorToDouble() : tileSize, // copy additionalOptions Map if not null, so we can safely compare old // and new Map inside didUpdateWidget with MapEquality. - additionalOptions = additionalOptions == null - ? const {} - : Map.from(additionalOptions), + additionalOptions = additionalOptions == null ? const {} : Map.from(additionalOptions), super(key: key, rebuild: rebuild); } @@ -357,8 +343,7 @@ class WMSTileLayerOptions { ..write('&$projectionKey=${Uri.encodeComponent(crs.code)}') ..write('&version=${Uri.encodeComponent(version)}') ..write('&transparent=$transparent'); - otherParameters - .forEach((k, v) => buffer.write('&$k=${Uri.encodeComponent(v)}')); + otherParameters.forEach((k, v) => buffer.write('&$k=${Uri.encodeComponent(v)}')); return buffer.toString(); } @@ -468,19 +453,16 @@ class _TileLayerState extends State with TickerProviderStateMixin { } if (!reloadTiles) { - final oldUrl = oldWidget.options.wmsOptions?._encodedBaseUrl ?? - oldWidget.options.urlTemplate; + final oldUrl = oldWidget.options.wmsOptions?._encodedBaseUrl ?? oldWidget.options.urlTemplate; final newUrl = options.wmsOptions?._encodedBaseUrl ?? options.urlTemplate; final oldOptions = oldWidget.options.additionalOptions; final newOptions = options.additionalOptions; - if (oldUrl != newUrl || - !(const MapEquality()).equals(oldOptions, newOptions)) { + if (oldUrl != newUrl || !(const MapEquality()).equals(oldOptions, newOptions)) { if (options.overrideTilesWhenUrlChanges) { for (var tile in _tiles.values) { - tile.imageProvider = options.tileProvider - .getImage(_wrapCoords(tile.coords), options); + tile.imageProvider = options.tileProvider.getImage(_wrapCoords(tile.coords), options); tile.loadTileImage(); } } else { @@ -498,8 +480,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { bool _isZoomOutsideMinMax() { for (var tile in _tiles.values) { - if (tile.level.zoom > (options.maxZoom) || - tile.level.zoom < (options.minZoom)) { + if (tile.level.zoom > (options.maxZoom) || tile.level.zoom < (options.minZoom)) { return true; } } @@ -535,9 +516,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { Widget build(BuildContext context) { var tilesToRender = _tiles.values.toList()..sort(); - var tileWidgets = [ - for (var tile in tilesToRender) _createTileWidget(tile) - ]; + var tileWidgets = [for (var tile in tilesToRender) _createTileWidget(tile)]; var tilesContainer = Stack( children: tileWidgets, @@ -598,8 +577,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { var tile = _tiles[key]!; tile.tileReady = null; - tile.dispose(tile.loadError && - options.evictErrorTileStrategy != EvictErrorTileStrategy.none); + tile.dispose(tile.loadError && options.evictErrorTileStrategy != EvictErrorTileStrategy.none); _tiles.remove(key); } } @@ -657,11 +635,6 @@ class _TileLayerState extends State with TickerProviderStateMixin { } void _pruneTiles() { - // TODO this pretty sure isn't necessary anymore - if (map == null) { - return; - } - var zoom = _tileZoom; if (zoom == null) { _removeAllTiles(); @@ -838,23 +811,15 @@ 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); } } @@ -904,8 +869,7 @@ 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) { - // TODO can we safely remove the null check for map - if (map == null || _tileZoom == null) { + if (_tileZoom == null) { return; } @@ -926,8 +890,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { var tile = entry.value; var c = tile.coords; - if (tile.current == true && - (c.z != _tileZoom || !noPruneRange.contains(CustomPoint(c.x, c.y)))) { + if (tile.current == true && (c.z != _tileZoom || !noPruneRange.contains(CustomPoint(c.x, c.y)))) { tile.current = false; } } @@ -961,8 +924,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { _evictErrorTilesBasedOnStrategy(tileRange); // sort tile queue to load tiles in order of their distance to center - queue.sort((a, b) => - (a.distanceTo(tileCenter) - b.distanceTo(tileCenter)).toInt()); + queue.sort((a, b) => (a.distanceTo(tileCenter) - b.distanceTo(tileCenter)).toInt()); for (var i = 0; i < queue.length; i++) { _addTile(queue[i] as Coords); @@ -975,10 +937,8 @@ class _TileLayerState extends State with TickerProviderStateMixin { if (!crs.infinite) { // don't load tile if it's out of bounds and not wrapped var bounds = _globalTileRange; - if ((crs.wrapLng == null && - (coords.x < bounds.min.x || coords.x > bounds.max.x)) || - (crs.wrapLat == null && - (coords.y < bounds.min.y || coords.y > bounds.max.y))) { + if ((crs.wrapLng == null && (coords.x < bounds.min.x || coords.x > bounds.max.x)) || + (crs.wrapLat == null && (coords.y < bounds.min.y || coords.y > bounds.max.y))) { return false; } } @@ -1005,8 +965,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { return; } - tile.dispose(tile.loadError && - options.evictErrorTileStrategy != EvictErrorTileStrategy.none); + tile.dispose(tile.loadError && options.evictErrorTileStrategy != EvictErrorTileStrategy.none); _tiles.remove(key); } @@ -1018,8 +977,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { tilePos: _getTilePos(coords), current: true, level: _levels[coords.z]!, - imageProvider: - options.tileProvider.getImage(_wrapCoords(coords), options), + imageProvider: options.tileProvider.getImage(_wrapCoords(coords), options), tileReady: _tileReady, ); @@ -1027,8 +985,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { } void _evictErrorTilesBasedOnStrategy(Bounds tileRange) { - if (options.evictErrorTileStrategy == - EvictErrorTileStrategy.notVisibleRespectMargin) { + if (options.evictErrorTileStrategy == EvictErrorTileStrategy.notVisibleRespectMargin) { var toRemove = []; for (var entry in _tiles.entries) { var tile = entry.value; @@ -1044,15 +1001,13 @@ class _TileLayerState extends State with TickerProviderStateMixin { tile.dispose(true); _tiles.remove(key); } - } else if (options.evictErrorTileStrategy == - EvictErrorTileStrategy.notVisible) { + } else if (options.evictErrorTileStrategy == EvictErrorTileStrategy.notVisible) { var toRemove = []; for (var entry in _tiles.entries) { var tile = entry.value; var c = tile.coords; - if (tile.loadError && - (!tile.current || !tileRange.contains(CustomPoint(c.x, c.y)))) { + if (tile.loadError && (!tile.current || !tileRange.contains(CustomPoint(c.x, c.y)))) { toRemove.add(entry.key); } } @@ -1085,13 +1040,9 @@ class _TileLayerState extends State with TickerProviderStateMixin { return; } - var fadeInStart = tile.loaded == null - ? options.tileFadeInStart - : options.tileFadeInStartWhenOverride; + var fadeInStart = tile.loaded == null ? options.tileFadeInStart : options.tileFadeInStartWhenOverride; tile.loaded = DateTime.now(); - if (options.tileFadeInDuration == null || - fadeInStart == 1.0 || - (tile.loadError && null == options.errorImage)) { + if (options.tileFadeInDuration == null || fadeInStart == 1.0 || (tile.loadError && null == options.errorImage)) { tile.active = true; } else { tile.startFadeInAnimation( @@ -1128,12 +1079,8 @@ class _TileLayerState extends State with TickerProviderStateMixin { Coords _wrapCoords(Coords coords) { var newCoords = Coords( - _wrapX != null - ? util.wrapNum(coords.x.toDouble(), _wrapX!) - : coords.x.toDouble(), - _wrapY != null - ? util.wrapNum(coords.y.toDouble(), _wrapY!) - : coords.y.toDouble(), + _wrapX != null ? util.wrapNum(coords.x.toDouble(), _wrapX!) : coords.x.toDouble(), + _wrapY != null ? util.wrapNum(coords.y.toDouble(), _wrapY!) : coords.y.toDouble(), ); newCoords.z = coords.z.toDouble(); return newCoords; @@ -1157,8 +1104,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { } } -typedef TileReady = void Function( - Coords coords, dynamic error, Tile tile); +typedef TileReady = void Function(Coords coords, dynamic error, Tile tile); class Tile implements Comparable { final String coordsKey; @@ -1176,9 +1122,7 @@ class Tile implements Comparable { AnimationController? animationController; - double get opacity => animationController == null - ? (active ? 1.0 : 0.0) - : animationController!.value; + double get opacity => animationController == null ? (active ? 1.0 : 0.0) : animationController!.value; // callback when tile is ready / error occurred // it maybe be null forinstance when download aborted @@ -1237,12 +1181,10 @@ class Tile implements Comparable { _imageStream?.removeListener(_listener); } - void startFadeInAnimation(Duration duration, TickerProvider vsync, - {double? from}) { + void startFadeInAnimation(Duration duration, TickerProvider vsync, {double? from}) { animationController?.removeStatusListener(_onAnimateEnd); - animationController = AnimationController(duration: duration, vsync: vsync) - ..addStatusListener(_onAnimateEnd); + animationController = AnimationController(duration: duration, vsync: vsync)..addStatusListener(_onAnimateEnd); animationController!.forward(from: from); } @@ -1262,8 +1204,7 @@ class Tile implements Comparable { void _tileOnError(dynamic exception, StackTrace? stackTrace) { if (null != tileReady) { - tileReady!( - coords, exception ?? 'Unknown exception during loadTileImage', this); + tileReady!(coords, exception ?? 'Unknown exception during loadTileImage', this); } } @@ -1321,9 +1262,7 @@ class _AnimatedTileState extends State { return Opacity( opacity: widget.tile.opacity, - child: widget.tileBuilder == null - ? tileWidget - : widget.tileBuilder!(context, tileWidget, widget.tile), + child: widget.tileBuilder == null ? tileWidget : widget.tileBuilder!(context, tileWidget, widget.tile), ); } diff --git a/lib/src/map/map.dart b/lib/src/map/map.dart index cd7440188..6179c7480 100644 --- a/lib/src/map/map.dart +++ b/lib/src/map/map.dart @@ -30,29 +30,25 @@ class MapControllerImpl implements MapController { } @override - MoveAndRotateResult moveAndRotate(LatLng center, double zoom, double degree, - {String? id}) { - return _state.moveAndRotate(center, zoom, degree, - source: MapEventSource.mapController, id: id!); + MoveAndRotateResult moveAndRotate(LatLng center, double zoom, double degree, {String? id}) { + return _state.moveAndRotate(center, zoom, degree, source: MapEventSource.mapController, id: id!); } @override bool move(LatLng center, double zoom, {String? id}) { - return _state.move(center, zoom, - id: id, source: MapEventSource.mapController); + return _state.move(center, zoom, id: id, source: MapEventSource.mapController); } @override void fitBounds( LatLngBounds bounds, { - FitBoundsOptions? options = - const FitBoundsOptions(padding: EdgeInsets.all(12.0)), + FitBoundsOptions? options = const FitBoundsOptions(padding: EdgeInsets.all(12.0)), }) { _state.fitBounds(bounds, options!); } @override - // TODO could it happen at all that _state isn't set here? + // TODO Remove getter since _state is never null bool get ready => _state != null; @override @@ -117,9 +113,7 @@ class MapState { void setOriginalSize(double width, double height) { final isCurrSizeNull = _originalSize == null; - if (isCurrSizeNull || - _originalSize!.x != width || - _originalSize!.y != height) { + if (isCurrSizeNull || _originalSize!.x != width || _originalSize!.y != height) { _originalSize = CustomPoint(width, height); _updateSizeByOriginalSizeAndRotation(); @@ -143,10 +137,8 @@ class MapState { if (_rotation != 0.0) { final cosAngle = math.cos(_rotationRad).abs(); final sinAngle = math.sin(_rotationRad).abs(); - final num width = - (originalWidth * cosAngle) + (originalHeight * sinAngle); - final num height = - (originalHeight * cosAngle) + (originalWidth * sinAngle); + final num width = (originalWidth * cosAngle) + (originalHeight * sinAngle); + final num height = (originalHeight * cosAngle) + (originalWidth * sinAngle); _size = CustomPoint(width, height); } else { @@ -175,8 +167,7 @@ class MapState { } } - void _handleMoveEmit(LatLng targetCenter, double targetZoom, hasGesture, - MapEventSource source, String? id) { + void _handleMoveEmit(LatLng targetCenter, double targetZoom, hasGesture, MapEventSource source, String? id) { if (source == MapEventSource.flingAnimationController) { emitMapEvent( MapEventFlingAnimation( @@ -197,8 +188,7 @@ class MapState { source: source, ), ); - } else if (source == MapEventSource.onDrag || - source == MapEventSource.onMultiFinger) { + } else if (source == MapEventSource.onDrag || source == MapEventSource.onMultiFinger) { emitMapEvent( MapEventMove( center: _lastCenter!, @@ -272,10 +262,8 @@ class MapState { MoveAndRotateResult moveAndRotate(LatLng center, double zoom, double degree, {required MapEventSource source, required String id}) { - final moveSucc = - move(center, zoom, id: id, source: source, callOnMoveSink: false); - final rotateSucc = - rotate(degree, id: id, source: source, callOnMoveSink: false); + final moveSucc = move(center, zoom, id: id, source: source, callOnMoveSink: false); + final rotateSucc = rotate(degree, id: id, source: source, callOnMoveSink: false); if (moveSucc || rotateSucc) { _onMoveSink.add(null); @@ -285,10 +273,7 @@ class MapState { } bool move(LatLng center, double zoom, - {hasGesture = false, - callOnMoveSink = true, - required MapEventSource source, - String? id}) { + {hasGesture = false, callOnMoveSink = true, required MapEventSource source, String? id}) { zoom = fitZoomToBounds(zoom); final mapMoved = center != _lastCenter || zoom != _zoom; @@ -315,8 +300,7 @@ class MapState { } if (options.onPositionChanged != null) { - var mapPosition = MapPosition( - center: center, bounds: bounds, zoom: zoom, hasGesture: hasGesture); + var mapPosition = MapPosition(center: center, bounds: bounds, zoom: zoom, hasGesture: hasGesture); options.onPositionChanged!(mapPosition, hasGesture); } @@ -375,12 +359,9 @@ class MapState { ); } - CenterZoom getBoundsCenterZoom( - LatLngBounds bounds, FitBoundsOptions options) { - var paddingTL = - CustomPoint(options.padding.left, options.padding.top); - var paddingBR = - CustomPoint(options.padding.right, options.padding.bottom); + CenterZoom getBoundsCenterZoom(LatLngBounds bounds, FitBoundsOptions options) { + var paddingTL = CustomPoint(options.padding.left, options.padding.top); + var paddingBR = CustomPoint(options.padding.right, options.padding.bottom); var paddingTotalXY = paddingTL + paddingBR; @@ -397,8 +378,7 @@ class MapState { ); } - double getBoundsZoom(LatLngBounds bounds, CustomPoint padding, - {bool inside = false}) { + double getBoundsZoom(LatLngBounds bounds, CustomPoint padding, {bool inside = false}) { var zoom = this.zoom; var min = options.minZoom ?? 0.0; var max = options.maxZoom ?? double.infinity; @@ -469,12 +449,10 @@ class MapState { } static MapState? maybeOf(BuildContext context, {bool nullOk = false}) { - final widget = - context.dependOnInheritedWidgetOfExactType(); + final widget = context.dependOnInheritedWidgetOfExactType(); if (nullOk || widget != null) { return widget?.mapState; } - throw FlutterError( - 'MapState.of() called with a context that does not contain a FlutterMap.'); + throw FlutterError('MapState.of() called with a context that does not contain a FlutterMap.'); } } From 2b509adcb610e5851d69bd54ccb8fd926bc252e0 Mon Sep 17 00:00:00 2001 From: Kenneth Gulbrandsoy Date: Wed, 14 Apr 2021 21:30:54 +0200 Subject: [PATCH 18/46] Limit number of purges in TileLayer and cancel pending on dispose --- lib/src/layer/tile_layer.dart | 6 +++++- test/flutter_map_test.dart | 10 +++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/src/layer/tile_layer.dart b/lib/src/layer/tile_layer.dart index 9fce2d748..b7494f374 100644 --- a/lib/src/layer/tile_layer.dart +++ b/lib/src/layer/tile_layer.dart @@ -420,6 +420,8 @@ class _TileLayerState extends State with TickerProviderStateMixin { final Map _tiles = {}; final Map _levels = {}; + Timer? _pruneLater; + @override void initState() { super.initState(); @@ -506,6 +508,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { void dispose() { _removeAllTiles(); _moveSub?.cancel(); + _pruneLater?.cancel(); options.tileProvider.dispose(); _throttleUpdate?.close(); @@ -1059,7 +1062,8 @@ class _TileLayerState extends State with TickerProviderStateMixin { if (_noTilesToLoad()) { // Wait a bit more than tileFadeInDuration (the duration of the tile // fade-in) to trigger a pruning. - Future.delayed( + _pruneLater?.cancel(); + _pruneLater = Timer( options.tileFadeInDuration != null ? options.tileFadeInDuration! + const Duration(milliseconds: 50) : const Duration(milliseconds: 50), diff --git a/test/flutter_map_test.dart b/test/flutter_map_test.dart index d33a1b292..23f8afb16 100644 --- a/test/flutter_map_test.dart +++ b/test/flutter_map_test.dart @@ -14,14 +14,12 @@ class MockHttpClientResponse extends Mock implements HttpClientResponse { int get statusCode => HttpStatus.ok; @override - HttpClientResponseCompressionState get compressionState => - HttpClientResponseCompressionState.notCompressed; + HttpClientResponseCompressionState get compressionState => HttpClientResponseCompressionState.notCompressed; @override StreamSubscription> listen(void Function(List event)? onData, {Function? onError, void Function()? onDone, bool? cancelOnError}) { - return _stream.listen(onData, - onError: onError, onDone: onDone, cancelOnError: cancelOnError); + return _stream.listen(onData, onError: onError, onDone: onDone, cancelOnError: cancelOnError); } static Stream> readFile() => File('test/res/map.png').openRead(); @@ -102,9 +100,7 @@ class _TestAppState extends State { ), layers: [ TileLayerOptions( - urlTemplate: - 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', - subdomains: ['a', 'b', 'c']), + urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', subdomains: ['a', 'b', 'c']), MarkerLayerOptions(markers: _markers), ], ), From 235dea9c4a59e88f55ca457b25f214aeed0f37b9 Mon Sep 17 00:00:00 2001 From: Kenneth Gulbrandsoy Date: Wed, 14 Apr 2021 21:57:48 +0200 Subject: [PATCH 19/46] Fix error messages in mocked classes --- test/flutter_map_test.dart | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/test/flutter_map_test.dart b/test/flutter_map_test.dart index 23f8afb16..48a86f330 100644 --- a/test/flutter_map_test.dart +++ b/test/flutter_map_test.dart @@ -14,27 +14,35 @@ class MockHttpClientResponse extends Mock implements HttpClientResponse { int get statusCode => HttpStatus.ok; @override - HttpClientResponseCompressionState get compressionState => HttpClientResponseCompressionState.notCompressed; + int get contentLength => File('test/res/map.png').lengthSync(); + + @override + HttpClientResponseCompressionState get compressionState => + HttpClientResponseCompressionState.notCompressed; @override StreamSubscription> listen(void Function(List event)? onData, {Function? onError, void Function()? onDone, bool? cancelOnError}) { - return _stream.listen(onData, onError: onError, onDone: onDone, cancelOnError: cancelOnError); + return _stream.listen( + onData, + onError: onError, + onDone: onDone, + cancelOnError: cancelOnError, + ); } static Stream> readFile() => File('test/res/map.png').openRead(); } -class MockHttpClientRequest extends Mock implements HttpClientRequest {} +class MockHttpClientRequest extends Mock implements HttpClientRequest { + @override + Future close() => Future.value(MockHttpClientResponse()); +} class MockClient extends Mock implements HttpClient { @override Future getUrl(Uri url) { - final request = MockHttpClientRequest(); - when(request.close()).thenAnswer((_) async { - return MockHttpClientResponse(); - }); - return Future.value(request); + return Future.value(MockHttpClientRequest()); } } @@ -100,7 +108,9 @@ class _TestAppState extends State { ), layers: [ TileLayerOptions( - urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', subdomains: ['a', 'b', 'c']), + urlTemplate: + 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', + subdomains: ['a', 'b', 'c']), MarkerLayerOptions(markers: _markers), ], ), From 2ff083d5f57cc372a8b5b46c8d8fe806326a1bcb Mon Sep 17 00:00:00 2001 From: Kenneth Gulbrandsoy Date: Wed, 14 Apr 2021 22:20:17 +0200 Subject: [PATCH 20/46] Set ready to true always (state is never null) --- lib/src/map/map.dart | 64 +++++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/lib/src/map/map.dart b/lib/src/map/map.dart index 6179c7480..4550b99d7 100644 --- a/lib/src/map/map.dart +++ b/lib/src/map/map.dart @@ -30,26 +30,30 @@ class MapControllerImpl implements MapController { } @override - MoveAndRotateResult moveAndRotate(LatLng center, double zoom, double degree, {String? id}) { - return _state.moveAndRotate(center, zoom, degree, source: MapEventSource.mapController, id: id!); + MoveAndRotateResult moveAndRotate(LatLng center, double zoom, double degree, + {String? id}) { + return _state.moveAndRotate(center, zoom, degree, + source: MapEventSource.mapController, id: id!); } @override bool move(LatLng center, double zoom, {String? id}) { - return _state.move(center, zoom, id: id, source: MapEventSource.mapController); + return _state.move(center, zoom, + id: id, source: MapEventSource.mapController); } @override void fitBounds( LatLngBounds bounds, { - FitBoundsOptions? options = const FitBoundsOptions(padding: EdgeInsets.all(12.0)), + FitBoundsOptions? options = + const FitBoundsOptions(padding: EdgeInsets.all(12.0)), }) { _state.fitBounds(bounds, options!); } @override - // TODO Remove getter since _state is never null - bool get ready => _state != null; + // TODO Remove getter since ready is always true (breaking change, was '=> _state != null' when state is never null) + bool get ready => true; @override LatLng get center => _state.center; @@ -113,7 +117,9 @@ class MapState { void setOriginalSize(double width, double height) { final isCurrSizeNull = _originalSize == null; - if (isCurrSizeNull || _originalSize!.x != width || _originalSize!.y != height) { + if (isCurrSizeNull || + _originalSize!.x != width || + _originalSize!.y != height) { _originalSize = CustomPoint(width, height); _updateSizeByOriginalSizeAndRotation(); @@ -137,8 +143,10 @@ class MapState { if (_rotation != 0.0) { final cosAngle = math.cos(_rotationRad).abs(); final sinAngle = math.sin(_rotationRad).abs(); - final num width = (originalWidth * cosAngle) + (originalHeight * sinAngle); - final num height = (originalHeight * cosAngle) + (originalWidth * sinAngle); + final num width = + (originalWidth * cosAngle) + (originalHeight * sinAngle); + final num height = + (originalHeight * cosAngle) + (originalWidth * sinAngle); _size = CustomPoint(width, height); } else { @@ -167,7 +175,8 @@ class MapState { } } - void _handleMoveEmit(LatLng targetCenter, double targetZoom, hasGesture, MapEventSource source, String? id) { + void _handleMoveEmit(LatLng targetCenter, double targetZoom, hasGesture, + MapEventSource source, String? id) { if (source == MapEventSource.flingAnimationController) { emitMapEvent( MapEventFlingAnimation( @@ -188,7 +197,8 @@ class MapState { source: source, ), ); - } else if (source == MapEventSource.onDrag || source == MapEventSource.onMultiFinger) { + } else if (source == MapEventSource.onDrag || + source == MapEventSource.onMultiFinger) { emitMapEvent( MapEventMove( center: _lastCenter!, @@ -262,8 +272,10 @@ class MapState { MoveAndRotateResult moveAndRotate(LatLng center, double zoom, double degree, {required MapEventSource source, required String id}) { - final moveSucc = move(center, zoom, id: id, source: source, callOnMoveSink: false); - final rotateSucc = rotate(degree, id: id, source: source, callOnMoveSink: false); + final moveSucc = + move(center, zoom, id: id, source: source, callOnMoveSink: false); + final rotateSucc = + rotate(degree, id: id, source: source, callOnMoveSink: false); if (moveSucc || rotateSucc) { _onMoveSink.add(null); @@ -273,7 +285,10 @@ class MapState { } bool move(LatLng center, double zoom, - {hasGesture = false, callOnMoveSink = true, required MapEventSource source, String? id}) { + {hasGesture = false, + callOnMoveSink = true, + required MapEventSource source, + String? id}) { zoom = fitZoomToBounds(zoom); final mapMoved = center != _lastCenter || zoom != _zoom; @@ -300,7 +315,8 @@ class MapState { } if (options.onPositionChanged != null) { - var mapPosition = MapPosition(center: center, bounds: bounds, zoom: zoom, hasGesture: hasGesture); + var mapPosition = MapPosition( + center: center, bounds: bounds, zoom: zoom, hasGesture: hasGesture); options.onPositionChanged!(mapPosition, hasGesture); } @@ -359,9 +375,12 @@ class MapState { ); } - CenterZoom getBoundsCenterZoom(LatLngBounds bounds, FitBoundsOptions options) { - var paddingTL = CustomPoint(options.padding.left, options.padding.top); - var paddingBR = CustomPoint(options.padding.right, options.padding.bottom); + CenterZoom getBoundsCenterZoom( + LatLngBounds bounds, FitBoundsOptions options) { + var paddingTL = + CustomPoint(options.padding.left, options.padding.top); + var paddingBR = + CustomPoint(options.padding.right, options.padding.bottom); var paddingTotalXY = paddingTL + paddingBR; @@ -378,7 +397,8 @@ class MapState { ); } - double getBoundsZoom(LatLngBounds bounds, CustomPoint padding, {bool inside = false}) { + double getBoundsZoom(LatLngBounds bounds, CustomPoint padding, + {bool inside = false}) { var zoom = this.zoom; var min = options.minZoom ?? 0.0; var max = options.maxZoom ?? double.infinity; @@ -449,10 +469,12 @@ class MapState { } static MapState? maybeOf(BuildContext context, {bool nullOk = false}) { - final widget = context.dependOnInheritedWidgetOfExactType(); + final widget = + context.dependOnInheritedWidgetOfExactType(); if (nullOk || widget != null) { return widget?.mapState; } - throw FlutterError('MapState.of() called with a context that does not contain a FlutterMap.'); + throw FlutterError( + 'MapState.of() called with a context that does not contain a FlutterMap.'); } } From 622d7e894034681c46470a4e4c94964d0ccd6454 Mon Sep 17 00:00:00 2001 From: Kenneth Gulbrandsoy Date: Tue, 27 Apr 2021 14:52:27 +0200 Subject: [PATCH 21/46] make bounds, getBounds and getCenter null safe --- example/lib/pages/zoombuttons_plugin_option.dart | 4 ++-- lib/src/map/map.dart | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/example/lib/pages/zoombuttons_plugin_option.dart b/example/lib/pages/zoombuttons_plugin_option.dart index 944324ce6..fa879d223 100644 --- a/example/lib/pages/zoombuttons_plugin_option.dart +++ b/example/lib/pages/zoombuttons_plugin_option.dart @@ -76,7 +76,7 @@ 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) { @@ -99,7 +99,7 @@ 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) { diff --git a/lib/src/map/map.dart b/lib/src/map/map.dart index 4550b99d7..408f4eee4 100644 --- a/lib/src/map/map.dart +++ b/lib/src/map/map.dart @@ -161,9 +161,9 @@ class MapState { _pixelOrigin = getNewPixelOrigin(_lastCenter!); } - LatLng get center => getCenter() ?? options.center; + LatLng get center => getCenter(); - LatLngBounds? get bounds => getBounds(); + LatLngBounds get bounds => getBounds(); Bounds get pixelBounds => getLastPixelBounds(); @@ -292,7 +292,7 @@ class MapState { zoom = fitZoomToBounds(zoom); final mapMoved = center != _lastCenter || zoom != _zoom; - if (_lastCenter != null && (!mapMoved || !bounds!.isValid)) { + if (_lastCenter != null && (!mapMoved || !bounds.isValid)) { return false; } @@ -344,16 +344,16 @@ class MapState { move(target.center, target.zoom, source: MapEventSource.fitBounds); } - LatLng? getCenter() { + LatLng getCenter() { if (_lastCenter != null) { - return _lastCenter; + return _lastCenter!; } return layerPointToLatLng(_centerLayerPoint); } - LatLngBounds? getBounds() { + LatLngBounds getBounds() { if (_lastBounds != null) { - return _lastBounds; + return _lastBounds!; } return _calculateBounds(); From 72786e66e82ef492fbb86a388db4e065d6e3a8e8 Mon Sep 17 00:00:00 2001 From: josxha <34318751+josxha@users.noreply.github.com> Date: Mon, 10 May 2021 12:16:32 +0200 Subject: [PATCH 22/46] use http.RetryClient instead of flutter_image --- .../network_image_with_retry.dart | 48 +++++++++++++++++++ .../layer/tile_provider/tile_provider.dart | 3 +- pubspec.yaml | 10 +--- 3 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 lib/src/layer/tile_provider/network_image_with_retry.dart diff --git a/lib/src/layer/tile_provider/network_image_with_retry.dart b/lib/src/layer/tile_provider/network_image_with_retry.dart new file mode 100644 index 000000000..044088fff --- /dev/null +++ b/lib/src/layer/tile_provider/network_image_with_retry.dart @@ -0,0 +1,48 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter/painting.dart'; +import 'package:http/http.dart'; +import 'package:http/retry.dart'; + +class NetworkImageWithRetry extends ImageProvider { + /// The URL from which the image will be fetched. + final String url; + + /// The scale to place in the [ImageInfo] object of the image. + final double scale; + + /// The http RetryClient that is used for the requests + RetryClient retryClient = RetryClient(Client()); + + NetworkImageWithRetry(this.url, {this.scale = 1.0}); + + @override + ImageStreamCompleter load(NetworkImageWithRetry key, decode) { + return OneFrameImageStreamCompleter( + _loadWithRetry(key, decode), + informationCollector: () sync* { + yield ErrorDescription('Image provider: $this'); + yield ErrorDescription('Image key: $key'); + } + ); + } + + @override + Future obtainKey(ImageConfiguration configuration) { + return SynchronousFuture(this); + } + + Future _loadWithRetry(NetworkImageWithRetry key, DecoderCallback decode) async { + assert(key == this); + + final uri = Uri.parse(url); + final response = await retryClient.get(uri); + + final codec = await decode(response.bodyBytes); + final image = (await codec.getNextFrame()).image; + + return ImageInfo( + image: image, + scale: key.scale, + ); + } +} \ No newline at end of file diff --git a/lib/src/layer/tile_provider/tile_provider.dart b/lib/src/layer/tile_provider/tile_provider.dart index 62fc0dd1f..ab6adfc38 100644 --- a/lib/src/layer/tile_provider/tile_provider.dart +++ b/lib/src/layer/tile_provider/tile_provider.dart @@ -1,9 +1,10 @@ import 'dart:io'; import 'package:flutter/widgets.dart'; -import 'package:flutter_image/network.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'network_image_with_retry.dart'; + abstract class TileProvider { const TileProvider(); diff --git a/pubspec.yaml b/pubspec.yaml index 96eede055..95036ce19 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ dependencies: positioned_tap_detector_2: ^1.0.0 transparent_image: ^2.0.0 async: ^2.1.0 - flutter_image: any + http: ^0.13.2 vector_math: ^2.1.0 proj4dart: ^2.0.0 collection: ^1.15.0 @@ -26,10 +26,4 @@ dev_dependencies: flutter_test: sdk: flutter test: ^1.16.5 - mockito: ^5.0.2 - -dependency_overrides: - flutter_image: - git: - url: "https://github.com/flutter/flutter_image" - ref: null-safety \ No newline at end of file + mockito: ^5.0.2 \ No newline at end of file From a1496c517729bd6c893c36e3487c250de27ee6f7 Mon Sep 17 00:00:00 2001 From: josxha <34318751+josxha@users.noreply.github.com> Date: Mon, 10 May 2021 13:07:54 +0200 Subject: [PATCH 23/46] formatting --- lib/src/layer/tile_provider/network_image_with_retry.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/src/layer/tile_provider/network_image_with_retry.dart b/lib/src/layer/tile_provider/network_image_with_retry.dart index 044088fff..134888f4c 100644 --- a/lib/src/layer/tile_provider/network_image_with_retry.dart +++ b/lib/src/layer/tile_provider/network_image_with_retry.dart @@ -11,7 +11,7 @@ class NetworkImageWithRetry extends ImageProvider { final double scale; /// The http RetryClient that is used for the requests - RetryClient retryClient = RetryClient(Client()); + final RetryClient retryClient = RetryClient(Client()); NetworkImageWithRetry(this.url, {this.scale = 1.0}); @@ -36,7 +36,6 @@ class NetworkImageWithRetry extends ImageProvider { final uri = Uri.parse(url); final response = await retryClient.get(uri); - final codec = await decode(response.bodyBytes); final image = (await codec.getNextFrame()).image; From 0c7462f6a3a1f6068d9abd4646e56b840828ca25 Mon Sep 17 00:00:00 2001 From: josxha <34318751+josxha@users.noreply.github.com> Date: Mon, 10 May 2021 15:06:16 +0200 Subject: [PATCH 24/46] add change notes --- CHANGELOG.md | 11 +++++++++++ pubspec.yaml | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ede305da3..dd1b83b10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +## [0.13.0] - x/xx/2021 +This version has support for sound null safety. For this purpose, some inactive packages were exchanged with active forks. + +- Sound null safety migration (#851, #870) + - requires flutter version 2.0.0 or higher + - latlong is replaced with latlong2 +- Remove the package flutter_image and add http instead (#894) + - http has to be version 0.13.2 or higher for this package (#894) + +Thanks to escamoteur, ThexXTURBOXx, Sata51, tazik561, kengu, passsy, Ahmed-gubara, johnpryan and josxha for this release! + ## [0.12.0] - 3/16/2021 TileLayerOptions now takes some additional options, templateFunction, tileBuilder, tilesContainerBuilder, and evictErrorTileStrategy diff --git a/pubspec.yaml b/pubspec.yaml index 95036ce19..025c25904 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_map description: A Dart implementation of Leaflet for Flutter apps -version: 0.12.0 +version: 0.13.0 repository: https://github.com/johnpryan/flutter_map environment: From 45c94ea732b1bf12230bd55190a964f87dab7361 Mon Sep 17 00:00:00 2001 From: Kenneth Gulbrandsoy Date: Sat, 15 May 2021 11:15:56 +0200 Subject: [PATCH 25/46] Added example page for NetworkTileProvider --- example/lib/main.dart | 2 + example/lib/pages/network_tile_provider.dart | 87 ++++++++++++++++++++ example/lib/widgets/drawer.dart | 7 ++ 3 files changed, 96 insertions(+) create mode 100644 example/lib/pages/network_tile_provider.dart diff --git a/example/lib/main.dart b/example/lib/main.dart index 5b24650d0..f5b5f0efe 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter_map_example/pages/network_tile_provider.dart'; import './pages/animated_map_controller.dart'; import './pages/circle.dart'; @@ -39,6 +40,7 @@ class MyApp extends StatelessWidget { ), home: HomePage(), routes: { + NetworkTileProviderPage.route: (context) => NetworkTileProviderPage(), WidgetsPage.route: (context) => WidgetsPage(), TapToAddPage.route: (context) => TapToAddPage(), EsriPage.route: (context) => EsriPage(), diff --git a/example/lib/pages/network_tile_provider.dart b/example/lib/pages/network_tile_provider.dart new file mode 100644 index 000000000..e9eba1ffc --- /dev/null +++ b/example/lib/pages/network_tile_provider.dart @@ -0,0 +1,87 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_map/flutter_map.dart'; +import 'package:latlong2/latlong.dart'; + +import '../widgets/drawer.dart'; + +class NetworkTileProviderPage extends StatelessWidget { + static const String route = 'NetworkTileProvider'; + + @override + Widget build(BuildContext context) { + var markers = [ + Marker( + width: 80.0, + height: 80.0, + point: LatLng(51.5, -0.09), + builder: (ctx) => Container( + child: FlutterLogo( + textColor: Colors.blue, + key: ObjectKey(Colors.blue), + ), + ), + ), + Marker( + width: 80.0, + height: 80.0, + point: LatLng(53.3498, -6.2603), + builder: (ctx) => Container( + child: FlutterLogo( + textColor: Colors.green, + key: ObjectKey(Colors.green), + ), + ), + ), + Marker( + width: 80.0, + height: 80.0, + point: LatLng(48.8566, 2.3522), + builder: (ctx) => Container( + child: FlutterLogo( + textColor: Colors.purple, + key: ObjectKey(Colors.purple), + ), + ), + ), + ]; + + return Scaffold( + appBar: AppBar(title: Text('NetworkTileProvider')), + drawer: buildDrawer(context, route), + body: Padding( + padding: EdgeInsets.all(8.0), + child: Column( + children: [ + Padding( + padding: EdgeInsets.only(top: 8.0, bottom: 8.0), + child: Wrap(children: [ + Text('This is a map that is using NetworkTileProvider.'), + Text('Turn on flight mode to see that images are cached.'), + ]), + ), + Flexible( + child: FlutterMap( + options: MapOptions( + center: LatLng(51.5, -0.09), + zoom: 5.0, + ), + layers: [ + TileLayerOptions( + urlTemplate: + 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', + subdomains: ['a', 'b', 'c'], + // For example purposes. It is recommended to use + // TileProvider with a caching and retry strategy, like + // NetworkTileProvider or CachedNetworkTileProvider + tileProvider: NetworkTileProvider(), + ), + MarkerLayerOptions(markers: markers) + ], + ), + ), + ], + ), + ), + ); + } +} diff --git a/example/lib/widgets/drawer.dart b/example/lib/widgets/drawer.dart index d66a7ba9c..2557d2085 100644 --- a/example/lib/widgets/drawer.dart +++ b/example/lib/widgets/drawer.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_map_example/pages/marker_rotate.dart'; +import 'package:flutter_map_example/pages/network_tile_provider.dart'; import '../pages/animated_map_controller.dart'; import '../pages/circle.dart'; @@ -58,6 +59,12 @@ Drawer buildDrawer(BuildContext context, String currentRoute) { HomePage.route, currentRoute, ), + _buildMenuItem( + context, + const Text('NetworkTileProvider'), + NetworkTileProviderPage.route, + currentRoute, + ), _buildMenuItem( context, const Text('WMS Layer'), From d9dd15808f6e081eb8af7fb7db8ab242f50a3c9c Mon Sep 17 00:00:00 2001 From: Kenneth Gulbrandsoy Date: Sat, 15 May 2021 11:17:32 +0200 Subject: [PATCH 26/46] Added dependency on null safe version 0.17.0 of package intl (would not build without it) --- pubspec.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/pubspec.yaml b/pubspec.yaml index 96eede055..d0d2e861e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,6 +11,7 @@ dependencies: flutter: sdk: flutter tuple: ^2.0.0 + intl: ^0.17.0 latlong2: ^0.8.0 positioned_tap_detector_2: ^1.0.0 transparent_image: ^2.0.0 From e72a6f007a40b57d2f6825e7024ae7566bc844b6 Mon Sep 17 00:00:00 2001 From: Kenneth Gulbrandsoy Date: Sat, 15 May 2021 11:18:53 +0200 Subject: [PATCH 27/46] Changed to master branch of flutter_image that is now null-safe --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index d0d2e861e..57bfdeb5e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -33,4 +33,4 @@ dependency_overrides: flutter_image: git: url: "https://github.com/flutter/flutter_image" - ref: null-safety \ No newline at end of file + ref: master \ No newline at end of file From f132c3550fa93a26623ea96b07548add5a9526d4 Mon Sep 17 00:00:00 2001 From: Kenneth Gulbrandsoy Date: Sat, 15 May 2021 11:31:48 +0200 Subject: [PATCH 28/46] Change override of package flutter_image to new location in flutter packages --- pubspec.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index 57bfdeb5e..2a97c0ad8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -31,6 +31,7 @@ dev_dependencies: dependency_overrides: flutter_image: - git: - url: "https://github.com/flutter/flutter_image" - ref: master \ No newline at end of file + git: + url: "https://github.com/flutter/packages" + ref: master + path: packages/flutter_image \ No newline at end of file From 910f701fea14509fcc8456705dad2e96f0ec5c8c Mon Sep 17 00:00:00 2001 From: Nico Mexis Date: Wed, 19 May 2021 22:13:12 +0200 Subject: [PATCH 29/46] Update git repo link --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index d6e34a38c..713d59dbc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: flutter_map description: A Dart implementation of Leaflet for Flutter apps version: 0.13.0 -repository: https://github.com/johnpryan/flutter_map +repository: https://github.com/fleaflet/flutter_map environment: sdk: '>=2.12.0 <3.0.0' From 079daafb28be5435193c2052b67e9dba8454f26a Mon Sep 17 00:00:00 2001 From: Nico Mexis Date: Wed, 19 May 2021 22:13:17 +0200 Subject: [PATCH 30/46] Fix typos --- lib/src/core/bounds.dart | 2 +- lib/src/layer/tile_layer.dart | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/core/bounds.dart b/lib/src/core/bounds.dart index 4801b1b8f..fbb204b17 100644 --- a/lib/src/core/bounds.dart +++ b/lib/src/core/bounds.dart @@ -31,7 +31,7 @@ class Bounds { ); } - /// This [Bounds] cental point. + /// This [Bounds] central point. CustomPoint getCenter() { //TODO should this be a getter? return CustomPoint( diff --git a/lib/src/layer/tile_layer.dart b/lib/src/layer/tile_layer.dart index bf11ba77d..34f6061eb 100644 --- a/lib/src/layer/tile_layer.dart +++ b/lib/src/layer/tile_layer.dart @@ -146,7 +146,7 @@ class TileLayerOptions extends LayerOptions { /// Tile image to show in place of the tile that failed to load. final ImageProvider? errorImage; - /// Static informations that should replace placeholders in the [urlTemplate]. + /// Static information that should replace placeholders in the [urlTemplate]. /// Applying API keys is a good example on how to use this parameter. /// /// Example: @@ -333,7 +333,7 @@ class WMSTileLayerOptions { /// Version of the WMS service to use final String version; - /// tile transperency flag + /// tile transparency flag final bool transparent; // TODO find a way to implicit pass of current map [Crs] @@ -1205,7 +1205,7 @@ class Tile implements Comparable { : animationController!.value; // callback when tile is ready / error occurred - // it maybe be null forinstance when download aborted + // it maybe be null for instance when download aborted TileReady? tileReady; ImageInfo? imageInfo; ImageStream? _imageStream; From 918d65b2dff353b2336ec1d3bcf486959d322c1e Mon Sep 17 00:00:00 2001 From: Nico Mexis Date: Wed, 19 May 2021 22:15:40 +0200 Subject: [PATCH 31/46] Sort dependencies --- analysis_options.yaml | 1 + example/pubspec.yaml | 6 +++--- pubspec.yaml | 18 +++++++++--------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index f2a12ab81..202093b55 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -36,6 +36,7 @@ linter: - prefer_null_aware_operators - prefer_single_quotes - prefer_typing_uninitialized_variables + - sort_pub_dependencies - test_types_in_equals - throw_in_finally - unnecessary_brace_in_string_interps diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 1f6fcc7db..78027d9c4 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -21,19 +21,19 @@ environment: sdk: '>=2.12.0 <3.0.0' dependencies: - flutter: - sdk: flutter # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 + flutter: + sdk: flutter flutter_map: path: ../ location: ^4.1.1 dev_dependencies: - pedantic: ^1.11.0 flutter_test: sdk: flutter + pedantic: ^1.11.0 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/pubspec.yaml b/pubspec.yaml index 713d59dbc..8ba25da9c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -8,23 +8,23 @@ environment: flutter: ">=2.0.0" dependencies: + async: ^2.1.0 + collection: ^1.15.0 flutter: sdk: flutter - tuple: ^2.0.0 + http: ^0.13.2 intl: ^0.17.0 latlong2: ^0.8.0 positioned_tap_detector_2: ^1.0.0 + proj4dart: ^2.0.0 transparent_image: ^2.0.0 - async: ^2.1.0 - http: ^0.13.2 + tuple: ^2.0.0 vector_math: ^2.1.0 - proj4dart: ^2.0.0 - collection: ^1.15.0 dev_dependencies: - pedantic: ^1.11.0 - location: ^4.1.1 flutter_test: sdk: flutter - test: ^1.16.5 - mockito: ^5.0.2 \ No newline at end of file + location: ^4.1.1 + mockito: ^5.0.2 + pedantic: ^1.11.0 + test: ^1.16.5 \ No newline at end of file From 8c3659127e4ae80ddc54db5e609bcdfa232f0458 Mon Sep 17 00:00:00 2001 From: Nico Mexis Date: Wed, 19 May 2021 22:23:06 +0200 Subject: [PATCH 32/46] Reformat and improve pub score --- README.md | 2 +- lib/src/geo/crs/crs.dart | 2 +- lib/src/gestures/gestures.dart | 12 +++-- lib/src/layer/polyline_layer.dart | 49 ++++++++++++------- .../network_image_with_retry.dart | 17 +++---- 5 files changed, 49 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 3cf88d907..e335ac5a0 100644 --- a/README.md +++ b/README.md @@ -286,6 +286,6 @@ Note that there is also `FileTileProvider()`, which you can use to load tiles fr For the latest roadmap, please see the [Issue Tracker] -[Leaflet]: http://leafletjs.com/ +[Leaflet]: https://leafletjs.com/ [Mapbox]: https://www.mapbox.com/ [Issue Tracker]: https://github.com/johnpryan/flutter_map/issues diff --git a/lib/src/geo/crs/crs.dart b/lib/src/geo/crs/crs.dart index fad20c1be..522701bd7 100644 --- a/lib/src/geo/crs/crs.dart +++ b/lib/src/geo/crs/crs.dart @@ -183,7 +183,7 @@ class Proj4Crs extends Crs { required this.infinite, List? transformations, required List scales, - }) : _transformations = transformations, + }) : _transformations = transformations, _scales = scales; factory Proj4Crs.fromFactory({ diff --git a/lib/src/gestures/gestures.dart b/lib/src/gestures/gestures.dart index 46dcc9d77..308e31196 100644 --- a/lib/src/gestures/gestures.dart +++ b/lib/src/gestures/gestures.dart @@ -2,13 +2,13 @@ import 'dart:async'; import 'dart:math' as math; import 'package:flutter/material.dart'; +import 'package:flutter/physics.dart'; 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:latlong2/latlong.dart'; import 'package:positioned_tap_detector_2/positioned_tap_detector_2.dart'; -import 'package:flutter/physics.dart'; abstract class MapGestureMixin extends State with TickerProviderStateMixin { @@ -162,7 +162,8 @@ abstract class MapGestureMixin extends State } } - int _getMultiFingerGestureFlags({int? gestureWinner, MapOptions? mapOptions}) { + int _getMultiFingerGestureFlags( + {int? gestureWinner, MapOptions? mapOptions}) { gestureWinner ??= _gestureWinner; mapOptions ??= options; @@ -480,9 +481,10 @@ abstract class MapGestureMixin extends State } var direction = details.velocity.pixelsPerSecond / magnitude; - var distance = - (Offset.zero & Size(mapState.originalSize!.x as double, mapState.originalSize!.y as double)) - .shortestSide; + var distance = (Offset.zero & + Size(mapState.originalSize!.x as double, + mapState.originalSize!.y as double)) + .shortestSide; var _flingOffset = _focalStartLocal - _lastFocalLocal; _flingAnimation = Tween( diff --git a/lib/src/layer/polyline_layer.dart b/lib/src/layer/polyline_layer.dart index 981060aa2..5d0127f18 100644 --- a/lib/src/layer/polyline_layer.dart +++ b/lib/src/layer/polyline_layer.dart @@ -50,6 +50,7 @@ class Polyline { class PolylineLayerWidget extends StatelessWidget { final PolylineLayerOptions options; + PolylineLayerWidget({Key? key, required this.options}) : super(key: key); @override @@ -64,7 +65,8 @@ class PolylineLayer extends StatelessWidget { final MapState map; final Stream? stream; - PolylineLayer(this.polylineOpts, this.map, this.stream) : super(key: polylineOpts.key); + PolylineLayer(this.polylineOpts, this.map, this.stream) + : super(key: polylineOpts.key); @override Widget build(BuildContext context) { @@ -85,7 +87,8 @@ class PolylineLayer extends StatelessWidget { for (var polylineOpt in polylineOpts.polylines) { polylineOpt.offsets.clear(); - if (polylineOpts.polylineCulling && !polylineOpt.boundingBox.isOverlapping(map.bounds)) { + if (polylineOpts.polylineCulling && + !polylineOpt.boundingBox.isOverlapping(map.bounds)) { // skip this polyline as it's offscreen continue; } @@ -112,7 +115,8 @@ class PolylineLayer extends StatelessWidget { var point = points[i]; var pos = map.project(point); - pos = pos.multiplyBy(map.getZoomScale(map.zoom, map.zoom)) - map.getPixelOrigin(); + pos = pos.multiplyBy(map.getZoomScale(map.zoom, map.zoom)) - + map.getPixelOrigin(); offsets.add(Offset(pos.x.toDouble(), pos.y.toDouble())); if (i > 0) { offsets.add(Offset(pos.x.toDouble(), pos.y.toDouble())); @@ -142,7 +146,9 @@ class PolylinePainter extends CustomPainter { if (polylineOpt.gradientColors == null) { paint.color = polylineOpt.color; } else { - polylineOpt.gradientColors!.isNotEmpty ? paint.shader = _paintGradient() : paint.color = polylineOpt.color; + polylineOpt.gradientColors!.isNotEmpty + ? paint.shader = _paintGradient() + : paint.color = polylineOpt.color; } Paint? filterPaint; @@ -158,7 +164,8 @@ class PolylinePainter extends CustomPainter { final borderPaint = polylineOpt.borderStrokeWidth > 0.0 ? (Paint() ..color = polylineOpt.borderColor ?? Color(0x00000000) - ..strokeWidth = polylineOpt.strokeWidth + polylineOpt.borderStrokeWidth + ..strokeWidth = + polylineOpt.strokeWidth + polylineOpt.borderStrokeWidth ..strokeCap = StrokeCap.round ..strokeJoin = StrokeJoin.round ..blendMode = BlendMode.srcOver) @@ -169,8 +176,10 @@ class PolylinePainter extends CustomPainter { var spacing = polylineOpt.strokeWidth * 1.5; canvas.saveLayer(rect, Paint()); if (borderPaint != null && filterPaint != null) { - _paintDottedLine(canvas, polylineOpt.offsets, borderRadius, spacing, borderPaint); - _paintDottedLine(canvas, polylineOpt.offsets, radius, spacing, filterPaint); + _paintDottedLine( + canvas, polylineOpt.offsets, borderRadius, spacing, borderPaint); + _paintDottedLine( + canvas, polylineOpt.offsets, radius, spacing, filterPaint); } _paintDottedLine(canvas, polylineOpt.offsets, radius, spacing, paint); canvas.restore(); @@ -188,7 +197,8 @@ class PolylinePainter extends CustomPainter { } } - void _paintDottedLine(Canvas canvas, List offsets, double radius, double stepLength, Paint paint) { + void _paintDottedLine(Canvas canvas, List offsets, double radius, + double stepLength, Paint paint) { final path = ui.Path(); var startDistance = 0.0; for (var i = 0; i < offsets.length - 1; i++) { @@ -203,9 +213,12 @@ class PolylinePainter extends CustomPainter { path.addOval(Rect.fromCircle(center: offset, radius: radius)); distance += stepLength; } - startDistance = distance < totalDistance ? stepLength - (totalDistance - distance) : distance - totalDistance; + startDistance = distance < totalDistance + ? stepLength - (totalDistance - distance) + : distance - totalDistance; } - path.addOval(Rect.fromCircle(center: polylineOpt.offsets.last, radius: radius)); + path.addOval( + Rect.fromCircle(center: polylineOpt.offsets.last, radius: radius)); canvas.drawPath(path, paint); } @@ -219,18 +232,20 @@ class PolylinePainter extends CustomPainter { } } - ui.Gradient _paintGradient() => ui.Gradient.linear( - polylineOpt.offsets.first, polylineOpt.offsets.last, polylineOpt.gradientColors!, _getColorsStop()); + ui.Gradient _paintGradient() => ui.Gradient.linear(polylineOpt.offsets.first, + polylineOpt.offsets.last, polylineOpt.gradientColors!, _getColorsStop()); - List? _getColorsStop() => - (polylineOpt.colorsStop != null && polylineOpt.colorsStop!.length == polylineOpt.gradientColors!.length) - ? polylineOpt.colorsStop - : _calculateColorsStop(); + 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! - .map((gradientColor) => polylineOpt.gradientColors!.indexOf(gradientColor) * colorsStopInterval) + .map((gradientColor) => + polylineOpt.gradientColors!.indexOf(gradientColor) * + colorsStopInterval) .toList(); } diff --git a/lib/src/layer/tile_provider/network_image_with_retry.dart b/lib/src/layer/tile_provider/network_image_with_retry.dart index 134888f4c..9b6094e92 100644 --- a/lib/src/layer/tile_provider/network_image_with_retry.dart +++ b/lib/src/layer/tile_provider/network_image_with_retry.dart @@ -9,7 +9,7 @@ class NetworkImageWithRetry extends ImageProvider { /// The scale to place in the [ImageInfo] object of the image. final double scale; - + /// The http RetryClient that is used for the requests final RetryClient retryClient = RetryClient(Client()); @@ -17,13 +17,11 @@ class NetworkImageWithRetry extends ImageProvider { @override ImageStreamCompleter load(NetworkImageWithRetry key, decode) { - return OneFrameImageStreamCompleter( - _loadWithRetry(key, decode), + return OneFrameImageStreamCompleter(_loadWithRetry(key, decode), informationCollector: () sync* { - yield ErrorDescription('Image provider: $this'); - yield ErrorDescription('Image key: $key'); - } - ); + yield ErrorDescription('Image provider: $this'); + yield ErrorDescription('Image key: $key'); + }); } @override @@ -31,7 +29,8 @@ class NetworkImageWithRetry extends ImageProvider { return SynchronousFuture(this); } - Future _loadWithRetry(NetworkImageWithRetry key, DecoderCallback decode) async { + Future _loadWithRetry( + NetworkImageWithRetry key, DecoderCallback decode) async { assert(key == this); final uri = Uri.parse(url); @@ -44,4 +43,4 @@ class NetworkImageWithRetry extends ImageProvider { scale: key.scale, ); } -} \ No newline at end of file +} From c7da0c93a961be6291189f1a5cb9c226f4bd9be9 Mon Sep 17 00:00:00 2001 From: Kenneth Gulbrandsoy Date: Wed, 19 May 2021 22:24:13 +0200 Subject: [PATCH 33/46] Upgraded to flutter_image ^4.0.1 --- pubspec.yaml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index 2a97c0ad8..58a7dcd70 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ dependencies: positioned_tap_detector_2: ^1.0.0 transparent_image: ^2.0.0 async: ^2.1.0 - flutter_image: any + flutter_image: ^4.0.1 vector_math: ^2.1.0 proj4dart: ^2.0.0 collection: ^1.15.0 @@ -27,11 +27,4 @@ dev_dependencies: flutter_test: sdk: flutter test: ^1.16.5 - mockito: ^5.0.2 - -dependency_overrides: - flutter_image: - git: - url: "https://github.com/flutter/packages" - ref: master - path: packages/flutter_image \ No newline at end of file + mockito: ^5.0.2 \ No newline at end of file From 793b4f0996df29716fa00ec27a635fb3c2d3b289 Mon Sep 17 00:00:00 2001 From: Kenneth Gulbrandsoy Date: Wed, 19 May 2021 22:27:59 +0200 Subject: [PATCH 34/46] Reformatted files to standard settings --- example/lib/pages/marker_rotate.dart | 10 ++++-- example/lib/pages/scalebar_utils.dart | 35 ++++++++++++++----- lib/src/gestures/gestures.dart | 10 +++--- lib/src/layer/polyline_layer.dart | 48 +++++++++++++++++---------- 4 files changed, 70 insertions(+), 33 deletions(-) diff --git a/example/lib/pages/marker_rotate.dart b/example/lib/pages/marker_rotate.dart index b976a32a7..a63ba2bef 100644 --- a/example/lib/pages/marker_rotate.dart +++ b/example/lib/pages/marker_rotate.dart @@ -108,7 +108,8 @@ class MarkerRotatePageState extends State { children: [ Padding( padding: EdgeInsets.only(top: 8.0, bottom: 8.0), - child: Text('Markers can be counter rotated to the map rotation.'), + child: + Text('Markers can be counter rotated to the map rotation.'), ), Padding( padding: EdgeInsets.only(top: 8.0, bottom: 8.0), @@ -116,7 +117,8 @@ class MarkerRotatePageState extends State { children: [ MaterialButton( onPressed: _setRotateMarkerLayerOptions, - child: Text('Set by LayerOptions: $rotateMarkerLayerOptions'), + child: + Text('Set by LayerOptions: $rotateMarkerLayerOptions'), ), MaterialButton( onPressed: _setRotateMarkerLondon, @@ -141,7 +143,9 @@ class MarkerRotatePageState extends State { ), layers: [ TileLayerOptions( - urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', subdomains: ['a', 'b', 'c']), + urlTemplate: + 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', + subdomains: ['a', 'b', 'c']), MarkerLayerOptions( rotate: rotateMarkerLayerOptions, markers: markers, diff --git a/example/lib/pages/scalebar_utils.dart b/example/lib/pages/scalebar_utils.dart index 826574876..f888e2e8d 100644 --- a/example/lib/pages/scalebar_utils.dart +++ b/example/lib/pages/scalebar_utils.dart @@ -11,7 +11,8 @@ double toRadians(double degrees) { return degrees * piOver180; } -LatLng calculateEndingGlobalCoordinates(LatLng start, double startBearing, double distance) { +LatLng calculateEndingGlobalCoordinates( + LatLng start, double startBearing, double distance) { var mSemiMajorAxis = 6378137.0; //WGS84 major axis var mSemiMinorAxis = (1.0 - 1.0 / 298.257223563) * 6378137.0; var mFlattening = 1.0 / 298.257223563; @@ -42,10 +43,13 @@ LatLng calculateEndingGlobalCoordinates(LatLng start, double startBearing, doubl var uSquared = cos2Alpha * (aSquared - bSquared) / bSquared; // eq. 3 - var A = 1 + (uSquared / 16384) * (4096 + uSquared * (-768 + uSquared * (320 - 175 * uSquared))); + var A = 1 + + (uSquared / 16384) * + (4096 + uSquared * (-768 + uSquared * (320 - 175 * uSquared))); // eq. 4 - var B = (uSquared / 1024) * (256 + uSquared * (-128 + uSquared * (74 - 47 * uSquared))); + var B = (uSquared / 1024) * + (256 + uSquared * (-128 + uSquared * (74 - 47 * uSquared))); // iterate until there is a negligible change in sigma double deltaSigma; @@ -71,7 +75,10 @@ LatLng calculateEndingGlobalCoordinates(LatLng start, double startBearing, doubl (cosSigmaM2 + (B / 4.0) * (cosSignma * (-1 + 2 * cos2SigmaM2) - - (B / 6.0) * cosSigmaM2 * (-3 + 4 * sinSigma * sinSigma) * (-3 + 4 * cos2SigmaM2))); + (B / 6.0) * + cosSigmaM2 * + (-3 + 4 * sinSigma * sinSigma) * + (-3 + 4 * cos2SigmaM2))); // eq. 7 sigma = sOverbA + deltaSigma; @@ -90,8 +97,11 @@ LatLng calculateEndingGlobalCoordinates(LatLng start, double startBearing, doubl sinSigma = sin(sigma); // eq. 8 - var phi2 = atan2(sinU1 * cosSigma + cosU1 * sinSigma * cosAlpha1, - (1.0 - f) * sqrt(sin2Alpha + pow(sinU1 * sinSigma - cosU1 * cosSigma * cosAlpha1, 2.0))); + var phi2 = atan2( + sinU1 * cosSigma + cosU1 * sinSigma * cosAlpha1, + (1.0 - f) * + sqrt(sin2Alpha + + pow(sinU1 * sinSigma - cosU1 * cosSigma * cosAlpha1, 2.0))); // eq. 9 // This fixes the pole crossing defect spotted by Matt Feemster. When a @@ -103,14 +113,21 @@ LatLng calculateEndingGlobalCoordinates(LatLng start, double startBearing, doubl // double tanLambda = sinSigma * sinAlpha1 / (cosU1 * cosSigma - sinU1 * // sinSigma * cosAlpha1); // double lambda = Math.atan(tanLambda); - var lambda = atan2(sinSigma * sinAlpha1, (cosU1 * cosSigma - sinU1 * sinSigma * cosAlpha1)); + var lambda = atan2( + sinSigma * sinAlpha1, (cosU1 * cosSigma - sinU1 * sinSigma * cosAlpha1)); // eq. 10 var C = (f / 16) * cos2Alpha * (4 + f * (4 - 3 * cos2Alpha)); // eq. 11 - var L = - lambda - (1 - C) * f * sinAlpha * (sigma + C * sinSigma * (cosSigmaM2 + C * cosSigma * (-1 + 2 * cos2SigmaM2))); + var L = lambda - + (1 - C) * + f * + sinAlpha * + (sigma + + C * + sinSigma * + (cosSigmaM2 + C * cosSigma * (-1 + 2 * cos2SigmaM2))); // eq. 12 // double alpha2 = Math.atan2(sinAlpha, -sinU1 * sinSigma + cosU1 * diff --git a/lib/src/gestures/gestures.dart b/lib/src/gestures/gestures.dart index 46dcc9d77..08b19d4cb 100644 --- a/lib/src/gestures/gestures.dart +++ b/lib/src/gestures/gestures.dart @@ -162,7 +162,8 @@ abstract class MapGestureMixin extends State } } - int _getMultiFingerGestureFlags({int? gestureWinner, MapOptions? mapOptions}) { + int _getMultiFingerGestureFlags( + {int? gestureWinner, MapOptions? mapOptions}) { gestureWinner ??= _gestureWinner; mapOptions ??= options; @@ -480,9 +481,10 @@ abstract class MapGestureMixin extends State } var direction = details.velocity.pixelsPerSecond / magnitude; - var distance = - (Offset.zero & Size(mapState.originalSize!.x as double, mapState.originalSize!.y as double)) - .shortestSide; + var distance = (Offset.zero & + Size(mapState.originalSize!.x as double, + mapState.originalSize!.y as double)) + .shortestSide; var _flingOffset = _focalStartLocal - _lastFocalLocal; _flingAnimation = Tween( diff --git a/lib/src/layer/polyline_layer.dart b/lib/src/layer/polyline_layer.dart index 981060aa2..b114748bb 100644 --- a/lib/src/layer/polyline_layer.dart +++ b/lib/src/layer/polyline_layer.dart @@ -64,7 +64,8 @@ class PolylineLayer extends StatelessWidget { final MapState map; final Stream? stream; - PolylineLayer(this.polylineOpts, this.map, this.stream) : super(key: polylineOpts.key); + PolylineLayer(this.polylineOpts, this.map, this.stream) + : super(key: polylineOpts.key); @override Widget build(BuildContext context) { @@ -85,7 +86,8 @@ class PolylineLayer extends StatelessWidget { for (var polylineOpt in polylineOpts.polylines) { polylineOpt.offsets.clear(); - if (polylineOpts.polylineCulling && !polylineOpt.boundingBox.isOverlapping(map.bounds)) { + if (polylineOpts.polylineCulling && + !polylineOpt.boundingBox.isOverlapping(map.bounds)) { // skip this polyline as it's offscreen continue; } @@ -112,7 +114,8 @@ class PolylineLayer extends StatelessWidget { var point = points[i]; var pos = map.project(point); - pos = pos.multiplyBy(map.getZoomScale(map.zoom, map.zoom)) - map.getPixelOrigin(); + pos = pos.multiplyBy(map.getZoomScale(map.zoom, map.zoom)) - + map.getPixelOrigin(); offsets.add(Offset(pos.x.toDouble(), pos.y.toDouble())); if (i > 0) { offsets.add(Offset(pos.x.toDouble(), pos.y.toDouble())); @@ -142,7 +145,9 @@ class PolylinePainter extends CustomPainter { if (polylineOpt.gradientColors == null) { paint.color = polylineOpt.color; } else { - polylineOpt.gradientColors!.isNotEmpty ? paint.shader = _paintGradient() : paint.color = polylineOpt.color; + polylineOpt.gradientColors!.isNotEmpty + ? paint.shader = _paintGradient() + : paint.color = polylineOpt.color; } Paint? filterPaint; @@ -158,7 +163,8 @@ class PolylinePainter extends CustomPainter { final borderPaint = polylineOpt.borderStrokeWidth > 0.0 ? (Paint() ..color = polylineOpt.borderColor ?? Color(0x00000000) - ..strokeWidth = polylineOpt.strokeWidth + polylineOpt.borderStrokeWidth + ..strokeWidth = + polylineOpt.strokeWidth + polylineOpt.borderStrokeWidth ..strokeCap = StrokeCap.round ..strokeJoin = StrokeJoin.round ..blendMode = BlendMode.srcOver) @@ -169,8 +175,10 @@ class PolylinePainter extends CustomPainter { var spacing = polylineOpt.strokeWidth * 1.5; canvas.saveLayer(rect, Paint()); if (borderPaint != null && filterPaint != null) { - _paintDottedLine(canvas, polylineOpt.offsets, borderRadius, spacing, borderPaint); - _paintDottedLine(canvas, polylineOpt.offsets, radius, spacing, filterPaint); + _paintDottedLine( + canvas, polylineOpt.offsets, borderRadius, spacing, borderPaint); + _paintDottedLine( + canvas, polylineOpt.offsets, radius, spacing, filterPaint); } _paintDottedLine(canvas, polylineOpt.offsets, radius, spacing, paint); canvas.restore(); @@ -188,7 +196,8 @@ class PolylinePainter extends CustomPainter { } } - void _paintDottedLine(Canvas canvas, List offsets, double radius, double stepLength, Paint paint) { + void _paintDottedLine(Canvas canvas, List offsets, double radius, + double stepLength, Paint paint) { final path = ui.Path(); var startDistance = 0.0; for (var i = 0; i < offsets.length - 1; i++) { @@ -203,9 +212,12 @@ class PolylinePainter extends CustomPainter { path.addOval(Rect.fromCircle(center: offset, radius: radius)); distance += stepLength; } - startDistance = distance < totalDistance ? stepLength - (totalDistance - distance) : distance - totalDistance; + startDistance = distance < totalDistance + ? stepLength - (totalDistance - distance) + : distance - totalDistance; } - path.addOval(Rect.fromCircle(center: polylineOpt.offsets.last, radius: radius)); + path.addOval( + Rect.fromCircle(center: polylineOpt.offsets.last, radius: radius)); canvas.drawPath(path, paint); } @@ -219,18 +231,20 @@ class PolylinePainter extends CustomPainter { } } - ui.Gradient _paintGradient() => ui.Gradient.linear( - polylineOpt.offsets.first, polylineOpt.offsets.last, polylineOpt.gradientColors!, _getColorsStop()); + ui.Gradient _paintGradient() => ui.Gradient.linear(polylineOpt.offsets.first, + polylineOpt.offsets.last, polylineOpt.gradientColors!, _getColorsStop()); - List? _getColorsStop() => - (polylineOpt.colorsStop != null && polylineOpt.colorsStop!.length == polylineOpt.gradientColors!.length) - ? polylineOpt.colorsStop - : _calculateColorsStop(); + 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! - .map((gradientColor) => polylineOpt.gradientColors!.indexOf(gradientColor) * colorsStopInterval) + .map((gradientColor) => + polylineOpt.gradientColors!.indexOf(gradientColor) * + colorsStopInterval) .toList(); } From 6023f61626d9baaee28d1c4d9def533819651643 Mon Sep 17 00:00:00 2001 From: Kenneth Gulbrandsoy Date: Wed, 19 May 2021 22:36:29 +0200 Subject: [PATCH 35/46] Reformatted crs.dart that wasn't changed using command line --- lib/src/geo/crs/crs.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/geo/crs/crs.dart b/lib/src/geo/crs/crs.dart index fad20c1be..522701bd7 100644 --- a/lib/src/geo/crs/crs.dart +++ b/lib/src/geo/crs/crs.dart @@ -183,7 +183,7 @@ class Proj4Crs extends Crs { required this.infinite, List? transformations, required List scales, - }) : _transformations = transformations, + }) : _transformations = transformations, _scales = scales; factory Proj4Crs.fromFactory({ From 1882f32298082a72ca62f8e54d479334a055a55a Mon Sep 17 00:00:00 2001 From: Nico Mexis Date: Thu, 20 May 2021 21:58:03 +0200 Subject: [PATCH 36/46] Random Fixes Everywhere (#910) * Update git repo link * Fix typos * Sort dependencies * Improve pub score --- CHANGELOG.md | 9 +++++++++ README.md | 2 +- analysis_options.yaml | 1 + example/pubspec.yaml | 6 +++--- lib/src/core/bounds.dart | 2 +- lib/src/gestures/gestures.dart | 2 +- lib/src/layer/polyline_layer.dart | 1 + lib/src/layer/tile_layer.dart | 6 +++--- pubspec.yaml | 26 +++++++++++++------------- 9 files changed, 33 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ede305da3..5e5ab3c11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## [0.13.0] - xx/xx/2021 +This version has support for sound null safety. For this purpose, some inactive packages were exchanged with active forks. + +- Sound null safety migration (#851, #870) + - requires flutter version 2.0.0 or higher + - latlong is replaced with latlong2 + +Thanks to escamoteur, ThexXTURBOXx, Sata51, tazik561, kengu, passsy, Ahmed-gubara and johnpryan for this release! + ## [0.12.0] - 3/16/2021 TileLayerOptions now takes some additional options, templateFunction, tileBuilder, tilesContainerBuilder, and evictErrorTileStrategy diff --git a/README.md b/README.md index 3cf88d907..e335ac5a0 100644 --- a/README.md +++ b/README.md @@ -286,6 +286,6 @@ Note that there is also `FileTileProvider()`, which you can use to load tiles fr For the latest roadmap, please see the [Issue Tracker] -[Leaflet]: http://leafletjs.com/ +[Leaflet]: https://leafletjs.com/ [Mapbox]: https://www.mapbox.com/ [Issue Tracker]: https://github.com/johnpryan/flutter_map/issues diff --git a/analysis_options.yaml b/analysis_options.yaml index f2a12ab81..202093b55 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -36,6 +36,7 @@ linter: - prefer_null_aware_operators - prefer_single_quotes - prefer_typing_uninitialized_variables + - sort_pub_dependencies - test_types_in_equals - throw_in_finally - unnecessary_brace_in_string_interps diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 1f6fcc7db..78027d9c4 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -21,19 +21,19 @@ environment: sdk: '>=2.12.0 <3.0.0' dependencies: - flutter: - sdk: flutter # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 + flutter: + sdk: flutter flutter_map: path: ../ location: ^4.1.1 dev_dependencies: - pedantic: ^1.11.0 flutter_test: sdk: flutter + pedantic: ^1.11.0 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/lib/src/core/bounds.dart b/lib/src/core/bounds.dart index 4801b1b8f..fbb204b17 100644 --- a/lib/src/core/bounds.dart +++ b/lib/src/core/bounds.dart @@ -31,7 +31,7 @@ class Bounds { ); } - /// This [Bounds] cental point. + /// This [Bounds] central point. CustomPoint getCenter() { //TODO should this be a getter? return CustomPoint( diff --git a/lib/src/gestures/gestures.dart b/lib/src/gestures/gestures.dart index 08b19d4cb..308e31196 100644 --- a/lib/src/gestures/gestures.dart +++ b/lib/src/gestures/gestures.dart @@ -2,13 +2,13 @@ import 'dart:async'; import 'dart:math' as math; import 'package:flutter/material.dart'; +import 'package:flutter/physics.dart'; 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:latlong2/latlong.dart'; import 'package:positioned_tap_detector_2/positioned_tap_detector_2.dart'; -import 'package:flutter/physics.dart'; abstract class MapGestureMixin extends State with TickerProviderStateMixin { diff --git a/lib/src/layer/polyline_layer.dart b/lib/src/layer/polyline_layer.dart index b114748bb..5d0127f18 100644 --- a/lib/src/layer/polyline_layer.dart +++ b/lib/src/layer/polyline_layer.dart @@ -50,6 +50,7 @@ class Polyline { class PolylineLayerWidget extends StatelessWidget { final PolylineLayerOptions options; + PolylineLayerWidget({Key? key, required this.options}) : super(key: key); @override diff --git a/lib/src/layer/tile_layer.dart b/lib/src/layer/tile_layer.dart index bf11ba77d..34f6061eb 100644 --- a/lib/src/layer/tile_layer.dart +++ b/lib/src/layer/tile_layer.dart @@ -146,7 +146,7 @@ class TileLayerOptions extends LayerOptions { /// Tile image to show in place of the tile that failed to load. final ImageProvider? errorImage; - /// Static informations that should replace placeholders in the [urlTemplate]. + /// Static information that should replace placeholders in the [urlTemplate]. /// Applying API keys is a good example on how to use this parameter. /// /// Example: @@ -333,7 +333,7 @@ class WMSTileLayerOptions { /// Version of the WMS service to use final String version; - /// tile transperency flag + /// tile transparency flag final bool transparent; // TODO find a way to implicit pass of current map [Crs] @@ -1205,7 +1205,7 @@ class Tile implements Comparable { : animationController!.value; // callback when tile is ready / error occurred - // it maybe be null forinstance when download aborted + // it maybe be null for instance when download aborted TileReady? tileReady; ImageInfo? imageInfo; ImageStream? _imageStream; diff --git a/pubspec.yaml b/pubspec.yaml index 58a7dcd70..adea5ab69 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,30 +1,30 @@ name: flutter_map -description: A Dart implementation of Leaflet for Flutter apps -version: 0.12.0 -repository: https://github.com/johnpryan/flutter_map +description: A Dart implementation of Leaflet to provide a Map widget for Flutter apps +version: 0.13.0 +repository: https://github.com/fleaflet/flutter_map environment: sdk: '>=2.12.0 <3.0.0' - flutter: ">=2.0.0" + flutter: '>=2.0.0' dependencies: + async: ^2.1.0 + collection: ^1.15.0 flutter: sdk: flutter - tuple: ^2.0.0 + flutter_image: ^4.0.1 intl: ^0.17.0 latlong2: ^0.8.0 positioned_tap_detector_2: ^1.0.0 + proj4dart: ^2.0.0 transparent_image: ^2.0.0 - async: ^2.1.0 - flutter_image: ^4.0.1 + tuple: ^2.0.0 vector_math: ^2.1.0 - proj4dart: ^2.0.0 - collection: ^1.15.0 dev_dependencies: - pedantic: ^1.11.0 - location: ^4.1.1 flutter_test: sdk: flutter - test: ^1.16.5 - mockito: ^5.0.2 \ No newline at end of file + location: ^4.1.1 + mockito: ^5.0.2 + pedantic: ^1.11.0 + test: ^1.16.5 \ No newline at end of file From 8378acb391486ccb30b16ef97b8e25e6cdd86076 Mon Sep 17 00:00:00 2001 From: John Ryan Date: Fri, 4 Jun 2021 07:29:12 -0700 Subject: [PATCH 37/46] remove TODO --- example/lib/pages/custom_crs/custom_crs.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/example/lib/pages/custom_crs/custom_crs.dart b/example/lib/pages/custom_crs/custom_crs.dart index 0cc0e8682..bdb7a7536 100644 --- a/example/lib/pages/custom_crs/custom_crs.dart +++ b/example/lib/pages/custom_crs/custom_crs.dart @@ -37,7 +37,6 @@ 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.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'); From 705e32cd57cf44164e93475dc92773ea9bdb1ee9 Mon Sep 17 00:00:00 2001 From: Luka S <58115698+JaffaKetchup@users.noreply.github.com> Date: Fri, 4 Jun 2021 15:32:45 +0100 Subject: [PATCH 38/46] Clarification of all options available for offline mapping (#913) * Update README.md - Clarified all options for offline mapping - Fixed some capitalisation inconsistencies. * Update README.md --- README.md | 76 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 65 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index e335ac5a0..b803eb051 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ MapOptions( ), ``` -### Azure Maps provider +### Azure Maps Provider Configure the map to use [Azure Maps](https://azure.com/maps) by using the following `MapOptions` and layer options: @@ -103,7 +103,7 @@ Widget build(BuildContext context) { To use Azure Maps you will need to [setup an account and get a subscription key](https://docs.microsoft.com/en-us/azure/azure-maps/quick-demo-map-app) -### Open Street Map provider +### Open Street Maps Provider Configure the map to use [Open Street Map](https://openstreetmap.org) by using the following `MapOptions` and layer options: @@ -229,21 +229,74 @@ child: FlutterMap( For more details visit [Custom CRS demo page](./example/lib/pages/custom_crs/Readme.md). -## Run the example +## Run the Example See the `example/` folder for a working example app. To run it, in a terminal cd into the folder. -Then execute `ulimit -S -n 2048` ([ref](https://github.com/trentpiercy/trace/issues/1#issuecomment-404494469)). +You may need to then execute `ulimit -S -n 2048` ([ref](https://github.com/trentpiercy/trace/issues/1#issuecomment-404494469)). Then execute `flutter run` with a running emulator. -## Preconfigured offline maps +## Dynamically Downloading & Caching Offline Maps -This method is only to use preconfigured and prepackaged offline maps. For advanced caching and ability to dynamically download an area, see the [flutter_map_tile_caching](https://github.com/JaffaKetchup/flutter_map_tile_caching) plugin. +In `flutter_map`, there are no available tile providers that will provide fully reliable caching or downloading, due to the extra dependencies needed to make this work. The only included tile provider that will handle caching at all is described below, but be aware that this is not fully functional. This section will guide through setting up caching and downloading functionality. If you would like to provide preconfigured and prepackaged map tiles to your app users, see the 'Preconfigured Offline Maps' section below. -First, [follow this guide to grab the tiles](https://tilemill-project.github.io/tilemill/docs/guides/osm-bright-mac-quickstart/).
-Once you have your map exported to `.mbtiles`, you can use [mbtilesToPng](https://github.com/alfanhui/mbtilesToPngs) to unpack into `/{z}/{x}/{y}.png`. -Move this to Assets folder and add asset directories to `pubspec.yaml`. Minimum required fields for offline maps are: +Full offline functionality, including caching and ability to download an area of map, is provided by the [`flutter_map_tile_caching`](https://github.com/JaffaKetchup/flutter_map_tile_caching) plugin package that is independently maintained. This will give you everything you need, however has the downsides of being an extra dependency for your app and having extra included dependencies for your app, both of which will increase your app's size and reliance on other developers. + +If you would like to setup this functionality using minimal or no extra dependencies and without the plugin mentioned above, follow one of the two options below depending on your required use case (number 2 is recommended): + +### 1. Use Flutter's built-in `NetworkImage` through the `NonCachingNetworkTileProvider`: + +Whilst the name might make you think differently, it is designed to prevent you from using it and expecting it to cache; because it doesn't. + +The `FlutterMap` `NonCachingNetworkTileProvider` implementaion uses `NetworkImage` which should cache images in memory until the app restart (through `Image.network`). However this is made even more confusing in the official Flutter docs. See the differences about caching between these two pages: https://api.flutter.dev/flutter/widgets/Image/Image.network.html and https://flutter.dev/docs/cookbook/images/network-image#placeholders-and-caching. + +These two lines conflict: +> All network images are cached regardless of HTTP headers. + +, and: + +> The default Image.network constructor doesn’t handle more advanced functionality, such as [...] caching images to the device after they’re downloaded. + +Therefore, unless you want to only cache until the app is restarted, you must use the second option below. + +### 2. Using the `cached_network_image` dependency: + +This dependency has an `ImageProvider` that caches images to disk, which means the cache persists through an app restart. You'll need to [include the package](https://pub.dev/packages/cached_network_image/install) in your `pubspec.yaml`. + +Create your own provider using the code below: +```dart +import 'package:cached_network_image/cached_network_image.dart'; +class CachedTileProvider extends TileProvider { + const CachedTileProvider(); + @override + ImageProvider getImage(Coords coords, TileLayerOptions options) { + return CachedNetworkImageProvider( + getTileUrl(coords, options), + //Now you can set options that determine how the image gets cached via whichever plugin you use. + ); + } +} +``` +Then, add the `CachedTileProvider` `TileProvider` to the appropriate `TileLayerOptions`: +```dart +TileLayerOptions( + urlTemplate: 'https://example.com/{x}/{y}/{z}', + tileProvider: const CachedTileProvider() +) +``` + +## Preconfigured Offline Maps + +This method is only to use preconfigured and prepackaged offline maps. For more flexibility, and to see how to setup caching and downloading, see the 'Dynamically Downloading & Caching Offline Maps' section above. + +This guide uses an open source program called [TileMill](https://tilemill-project.github.io/tilemill/). There is, however, an issue with lack of maintanace of this software. As of writing/updating on the 04th June 2021, the repo has not had an update since 13th October 2019, and there is [an issue debating what TileMill's future is](https://github.com/tilemill-project/tilemill/issues/2740). However, TileMill does still work, if not with some complicated installation process. + +First, install TileMill on your machine. This may be from source, or there may be a package available for your operating system. It is recommended to install the newest version. Installation instructions can be found here https://tilemill-project.github.io/tilemill/docs/install/. + +Then, [follow this guide to grab the tiles](https://tilemill-project.github.io/tilemill/docs/guides/osm-bright-mac-quickstart/). Once you have your map exported to `.mbtiles`, you can use [mbtilesToPng](https://github.com/alfanhui/mbtilesToPngs) to unpack into `/{z}/{x}/{y}.png`. + +Move this to assets folder and add the appropriate asset directories to `pubspec.yaml`. Minimum required fields for this solution are: ```dart Widget build(ctx) { @@ -264,8 +317,9 @@ Widget build(ctx) { } ``` -Make sure PanBoundaries are within offline map boundary to stop missing asset errors.
-See the `flutter_map_example/` folder for a working example. +Make sure PanBoundaries are within offline map boundary to stop missing asset errors. + +See the example folder for a working example. Note that there is also `FileTileProvider()`, which you can use to load tiles from the filesystem. From b870970c33647fcb268b1d9ecd52e7c250ace9a0 Mon Sep 17 00:00:00 2001 From: 6y Date: Fri, 4 Jun 2021 22:59:59 +0800 Subject: [PATCH 39/46] fix Group Layer Options constructor wrong nullability (#921) Co-authored-by: 6y --- lib/src/layer/group_layer.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/layer/group_layer.dart b/lib/src/layer/group_layer.dart index 68b79761a..30a3ea3bd 100644 --- a/lib/src/layer/group_layer.dart +++ b/lib/src/layer/group_layer.dart @@ -7,9 +7,9 @@ class GroupLayerOptions extends LayerOptions { List group = []; GroupLayerOptions({ - required Key key, - required this.group, - required Stream rebuild, + Key? key, + this.group = const [], + Stream? rebuild, }) : super(key: key, rebuild: rebuild); } From 36154f4c3661b83e424410ce1ab74ccfd392863f Mon Sep 17 00:00:00 2001 From: John Ryan Date: Fri, 4 Jun 2021 08:03:18 -0700 Subject: [PATCH 40/46] null check regex in template() --- lib/src/core/util.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/src/core/util.dart b/lib/src/core/util.dart index c670a459c..43a53d72e 100644 --- a/lib/src/core/util.dart +++ b/lib/src/core/util.dart @@ -6,10 +6,16 @@ var _templateRe = RegExp(r'\{ *([\w_-]+) *\}'); /// Replaces the templating placeholders with the provided data map. /// +/// Example input: https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png +/// /// 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 firstMatch = match.group(1); + if (firstMatch == null) { + throw Exception('incorrect URL template: $str'); + } + var value = data[firstMatch]; if (value == null) { throw Exception('No value provided for variable ${match.group(1)}'); } else { From 9e6dd847d8292dc01e5975b4a309d1168b89fcec Mon Sep 17 00:00:00 2001 From: John Ryan Date: Fri, 4 Jun 2021 08:17:36 -0700 Subject: [PATCH 41/46] re-apply #913 into null safety branch --- README.md | 75 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 66 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 26cf9a2e0..79b803ec0 100644 --- a/README.md +++ b/README.md @@ -243,18 +243,71 @@ See the `example/` folder for a working example app. To run it, in a terminal cd into the folder. Then execute `ulimit -S -n 2048` ([ref][ulimit-comment]). Then execute `flutter run` with a running emulator. -## Preconfigured offline maps +## Downloading and caching offline maps -This method is only to use preconfigured and prepackaged offline maps. For -advanced caching and ability to dynamically download an area, see the -[flutter_map_tile_caching][flutter_map_tile_caching] plugin. +This section provides an overview of the available caching tile providers. If +you would like to provide preconfigured and prepackaged map tiles to your app +users, see the 'Preconfigured Offline Maps' section below. -First, find which tiles you would like to use through a service such as -[tilemill][tilemill]. You should have tiles exported into the `.mbtiles` format. +The two available options included in flutter_map -Then use [mbtilesToPng][mbtilesToPngs] to unpack into `/{z}/{x}/{y}.png`. Move -this to the assets folder and add the asset directories to `pubspec.yaml`. The -minimum required fields for offline maps are: +### 1. Use `NetworkImage` by using `NonCachingNetworkTileProvider` + +Whilst the name might make you think differently, it is designed to prevent you +from using it and expecting it to cache; because it doesn't. + +The `FlutterMap` `NonCachingNetworkTileProvider` implementaion uses +`NetworkImage` which should cache images in memory until the app restart +(through `Image.network`). See the [Image.network][Image.network] docs and +[NetworkImage][NetworkImage-caching] docs for more details. + +### 2. Using the `cached_network_image` dependency + +This dependency has an `ImageProvider` that caches images to disk, which means +the cache persists through an app restart. You'll need to [include the +package](https://pub.dev/packages/cached_network_image/install) in your +`pubspec.yaml`. + +Create your own provider using the code below: +```dart +import 'package:cached_network_image/cached_network_image.dart'; +class CachedTileProvider extends TileProvider { + const CachedTileProvider(); + @override + ImageProvider getImage(Coords coords, TileLayerOptions options) { + return CachedNetworkImageProvider( + getTileUrl(coords, options), + //Now you can set options that determine how the image gets cached via whichever plugin you use. + ); + } +} +``` +Then, add the `CachedTileProvider` `TileProvider` to the appropriate +`TileLayerOptions`: + +```dart +TileLayerOptions( + urlTemplate: 'https://example.com/{x}/{y}/{z}', + tileProvider: const CachedTileProvider() +) +``` + +## Offline Maps using TileMill + +This section provides instructions for preconfigured and prepackaged offline +maps. To see how to setup caching and downloading, see the 'Dynamically +Downloading & Caching Offline Maps' section above. + +This guide uses an open source program called [TileMill][tilemill-homepage]. + +First, [install TileMill][install-tilemill] on your machine. Then, follow [these +instructions][tilemill]. + +Once you have your map exported to `.mbtiles`, you can use +[mbtilesToPng][mbTilesToPngs] to unpack into `/{z}/{x}/{y}.png`. + +Move this to assets folder and add the appropriate asset directories to +`pubspec.yaml`. Minimum required fields for this solution are: ```dart Widget build(ctx) { @@ -309,4 +362,8 @@ For the latest roadmap, please see the [Issue Tracker] [open-street-map]: https://openstreetmap.org [proj4dart]: https://github.com/maRci002/proj4dart [tilemill]: https://tilemill-project.github.io/tilemill/docs/guides/osm-bright-mac-quickstart/ +[install-tilemill]: https://tilemill-project.github.io/tilemill/docs/install/ [ulimit-comment]: https://github.com/trentpiercy/trace/issues/1#issuecomment-404494469 +[Image.network]: https://api.flutter.dev/flutter/widgets/Image/Image.network.html +[NetworkImage-caching]: https://flutter.dev/docs/cookbook/images/network-image#placeholders-and-caching +[tilemill-homepage]: https://tilemill-project.github.io/tilemill/ From c3659d91284c9df4116ec7b28e3e36e014701264 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Andersson?= Date: Fri, 4 Jun 2021 17:18:18 +0200 Subject: [PATCH 42/46] Review comments from issues/829-nullsafety (#919) * fix: remove deprecated properties Removes deprecated properties, updates documentation and changed bounds getCenter to a getter. * fix: simplify center getter * docs: improve documentation for NetworkTileProvider * docs: update documentation for tileProvider --- CHANGELOG.md | 7 ++++++- example/lib/pages/network_tile_provider.dart | 4 ++-- lib/flutter_map.dart | 19 +++---------------- lib/src/core/bounds.dart | 11 ++++------- lib/src/layer/tile_layer.dart | 10 +++++----- lib/src/map/map.dart | 4 ---- 6 files changed, 20 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4746ab90c..09acf58e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,15 @@ This version has support for sound null safety. For this purpose, some inactive - Sound null safety migration (#851, #870) - requires flutter version 2.0.0 or higher - latlong is replaced with latlong2 + - ready-flag on map has been removed - Remove the package flutter_image and add http instead (#894) - http has to be version 0.13.2 or higher for this package (#894) +- Removed deprecated properties + - debug property has been removed + - interactive has been replaced by interactiveFlags +- Bounds getCenter has been replaced by center getter -Thanks to escamoteur, ThexXTURBOXx, Sata51, tazik561, kengu, passsy, Ahmed-gubara, johnpryan and josxha for this release! +Thanks to escamoteur, ThexXTURBOXx, Sata51, tazik561, kengu, passsy, Ahmed-gubara, johnpryan, josxha and andreandersson for this release! ## [0.12.0] - 3/16/2021 TileLayerOptions now takes some additional options, templateFunction, diff --git a/example/lib/pages/network_tile_provider.dart b/example/lib/pages/network_tile_provider.dart index e9eba1ffc..3d9ebccec 100644 --- a/example/lib/pages/network_tile_provider.dart +++ b/example/lib/pages/network_tile_provider.dart @@ -55,8 +55,8 @@ class NetworkTileProviderPage extends StatelessWidget { Padding( padding: EdgeInsets.only(top: 8.0, bottom: 8.0), child: Wrap(children: [ - Text('This is a map that is using NetworkTileProvider.'), - Text('Turn on flight mode to see that images are cached.'), + Text('This Provider does not provide caching.'), + Text('For further options about that, check flutter_map\'s README on GitHub.'), ]), ), Flexible( diff --git a/lib/flutter_map.dart b/lib/flutter_map.dart index 6db99f69e..7fade1536 100644 --- a/lib/flutter_map.dart +++ b/lib/flutter_map.dart @@ -122,8 +122,6 @@ abstract class MapController { /// through the [options] parameter. void fitBounds(LatLngBounds bounds, {FitBoundsOptions? options}); - bool get ready; - Future get onReady; LatLng get center; @@ -221,10 +219,6 @@ class MapOptions { 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; /// see [InteractiveFlag] for custom settings final int interactiveFlags; @@ -268,12 +262,7 @@ class MapOptions { MultiFingerGesture.pinchZoom | MultiFingerGesture.pinchMove, this.minZoom, this.maxZoom, - @Deprecated('') this.debug = false, - @Deprecated('Use interactiveFlags instead') this.interactive, - // TODO: Change when [interactive] is removed. - // Change this to [this.interactiveFlags = InteractiveFlag.all] and remove - // [interactiveFlags] from initializer list - int? interactiveFlags, + this.interactiveFlags = InteractiveFlag.all, this.allowPanning = true, this.onTap, this.onLongPress, @@ -286,9 +275,7 @@ class MapOptions { this.controller, this.swPanBoundary, this.nePanBoundary, - }) : interactiveFlags = interactiveFlags ?? - (interactive == false ? InteractiveFlag.none : InteractiveFlag.all), - center = center ?? LatLng(50.5, 30.51), + }) : center = center ?? LatLng(50.5, 30.51), assert(rotationThreshold >= 0.0), assert(pinchZoomThreshold >= 0.0), assert(pinchMoveThreshold >= 0.0) { @@ -365,7 +352,7 @@ class MapOptions { double _calculateScreenHeightInDegrees() => screenSize!.height * 170.102258 / pow(2, _getControllerZoom() + 8); - double _getControllerZoom() => controller!.ready ? controller!.zoom : zoom; + double _getControllerZoom() => controller!.zoom; } class FitBoundsOptions { diff --git a/lib/src/core/bounds.dart b/lib/src/core/bounds.dart index fbb204b17..3aa96eb5d 100644 --- a/lib/src/core/bounds.dart +++ b/lib/src/core/bounds.dart @@ -32,13 +32,10 @@ class Bounds { } /// This [Bounds] central point. - CustomPoint getCenter() { - //TODO should this be a getter? - return CustomPoint( - (min.x + max.x) / 2, - (min.y + max.y) / 2, - ); - } + CustomPoint get center => CustomPoint( + (min.x + max.x) / 2, + (min.y + max.y) / 2, + ); /// Bottom-Left corner's point. CustomPoint get bottomLeft => CustomPoint(min.x, max.y); diff --git a/lib/src/layer/tile_layer.dart b/lib/src/layer/tile_layer.dart index 34f6061eb..f7330e6ef 100644 --- a/lib/src/layer/tile_layer.dart +++ b/lib/src/layer/tile_layer.dart @@ -110,10 +110,10 @@ class TileLayerOptions extends LayerOptions { /// Opacity of the rendered tile final double opacity; - /// Provider to load the tiles. The default is CachedNetworkTileProvider, - /// which loads tile images from network and caches them offline. - /// - /// If you don't want to cache the tiles, use NetworkTileProvider instead. + /// Provider to load the tiles. The default is `NonCachingNetworkTileProvider()` which + /// doesn't cache tiles and won't retry the HTTP request. Use `NetworkTileProvider()` for + /// a provider which will retry requests. For the best caching implementations, see the + /// flutter_map readme. /// /// In order to use images from the asset folder set this option to /// AssetTileProvider() Note that it requires the urlTemplate to target @@ -925,7 +925,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { var pixelBounds = _getTiledPixelBounds(center); var tileRange = _pxBoundsToTileRange(pixelBounds); - var tileCenter = tileRange.getCenter(); + var tileCenter = tileRange.center; final queue = >[]; var margin = options.keepBuffer; var noPruneRange = Bounds( diff --git a/lib/src/map/map.dart b/lib/src/map/map.dart index 408f4eee4..3706f365e 100644 --- a/lib/src/map/map.dart +++ b/lib/src/map/map.dart @@ -51,10 +51,6 @@ class MapControllerImpl implements MapController { _state.fitBounds(bounds, options!); } - @override - // TODO Remove getter since ready is always true (breaking change, was '=> _state != null' when state is never null) - bool get ready => true; - @override LatLng get center => _state.center; From a86cacaf3d3f005c60d97e22ff67df562e201d34 Mon Sep 17 00:00:00 2001 From: John Ryan Date: Fri, 4 Jun 2021 08:20:28 -0700 Subject: [PATCH 43/46] dart format --- example/lib/pages/network_tile_provider.dart | 3 ++- lib/src/core/bounds.dart | 6 +++--- lib/src/layer/tile_layer.dart | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/example/lib/pages/network_tile_provider.dart b/example/lib/pages/network_tile_provider.dart index 3d9ebccec..b93c6a858 100644 --- a/example/lib/pages/network_tile_provider.dart +++ b/example/lib/pages/network_tile_provider.dart @@ -56,7 +56,8 @@ class NetworkTileProviderPage extends StatelessWidget { padding: EdgeInsets.only(top: 8.0, bottom: 8.0), child: Wrap(children: [ Text('This Provider does not provide caching.'), - Text('For further options about that, check flutter_map\'s README on GitHub.'), + Text( + 'For further options about that, check flutter_map\'s README on GitHub.'), ]), ), Flexible( diff --git a/lib/src/core/bounds.dart b/lib/src/core/bounds.dart index 3aa96eb5d..c1408faf8 100644 --- a/lib/src/core/bounds.dart +++ b/lib/src/core/bounds.dart @@ -33,9 +33,9 @@ class Bounds { /// This [Bounds] central point. CustomPoint get center => CustomPoint( - (min.x + max.x) / 2, - (min.y + max.y) / 2, - ); + (min.x + max.x) / 2, + (min.y + max.y) / 2, + ); /// Bottom-Left corner's point. CustomPoint get bottomLeft => CustomPoint(min.x, max.y); diff --git a/lib/src/layer/tile_layer.dart b/lib/src/layer/tile_layer.dart index f7330e6ef..7e69aeff7 100644 --- a/lib/src/layer/tile_layer.dart +++ b/lib/src/layer/tile_layer.dart @@ -113,7 +113,7 @@ class TileLayerOptions extends LayerOptions { /// Provider to load the tiles. The default is `NonCachingNetworkTileProvider()` which /// doesn't cache tiles and won't retry the HTTP request. Use `NetworkTileProvider()` for /// a provider which will retry requests. For the best caching implementations, see the - /// flutter_map readme. + /// flutter_map readme. /// /// In order to use images from the asset folder set this option to /// AssetTileProvider() Note that it requires the urlTemplate to target From 40d3a59b2433d4b327350f64d75a9d63f520c948 Mon Sep 17 00:00:00 2001 From: John Ryan Date: Fri, 4 Jun 2021 08:27:53 -0700 Subject: [PATCH 44/46] make urlTemplate required, make throttleSTreamTransformerWithTrailingCall updateInterval required. --- lib/src/core/util.dart | 4 ++-- lib/src/layer/tile_layer.dart | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/src/core/util.dart b/lib/src/core/util.dart index 43a53d72e..5b8ab54b3 100644 --- a/lib/src/core/util.dart +++ b/lib/src/core/util.dart @@ -32,7 +32,7 @@ double wrapNum(double x, Tuple2 range, [bool? includeMax]) { } StreamTransformer throttleStreamTransformerWithTrailingCall( - Duration? duration) { + Duration duration) { Timer? timer; T recentData; var trailingCall = false; @@ -43,7 +43,7 @@ StreamTransformer throttleStreamTransformerWithTrailingCall( if (timer == null) { sink.add(recentData); - timer = Timer(duration!, () { + timer = Timer(duration, () { timer = null; if (trailingCall) { diff --git a/lib/src/layer/tile_layer.dart b/lib/src/layer/tile_layer.dart index 7e69aeff7..b723aa7e6 100644 --- a/lib/src/layer/tile_layer.dart +++ b/lib/src/layer/tile_layer.dart @@ -49,7 +49,7 @@ 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). @@ -242,7 +242,7 @@ class TileLayerOptions extends LayerOptions { TileLayerOptions({ Key? key, - this.urlTemplate, + required this.urlTemplate, double tileSize = 256.0, double minZoom = 0.0, double maxZoom = 18.0, @@ -530,7 +530,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { _throttleUpdate!.stream .transform( util.throttleStreamTransformerWithTrailingCall( - options.updateInterval, + options.updateInterval!, ), ) .listen(_update); @@ -893,7 +893,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { _setZoomTransforms(map.center, map.zoom); } else { - if (null == _throttleUpdate) { + if (_throttleUpdate == null) { _update(null); } else { _throttleUpdate!.add(null); From 3ea0500d291cb9b653f3eccf004d4ebdea309a34 Mon Sep 17 00:00:00 2001 From: John Ryan Date: Fri, 4 Jun 2021 08:35:51 -0700 Subject: [PATCH 45/46] use late final where possible --- example/ios/Runner.xcodeproj/project.pbxproj | 68 +++++++++++++++++++ .../contents.xcworkspacedata | 3 + .../lib/pages/animated_map_controller.dart | 2 +- example/lib/pages/custom_crs/custom_crs.dart | 6 +- example/lib/pages/interactive_test_page.dart | 4 +- example/lib/pages/live_location.dart | 2 +- example/lib/pages/map_controller.dart | 4 +- example/lib/pages/moving_markers.dart | 2 +- example/lib/pages/stateful_markers.dart | 2 +- lib/src/core/util.dart | 3 +- lib/src/gestures/gestures.dart | 24 +++---- lib/src/layer/polygon_layer.dart | 2 +- lib/src/layer/polyline_layer.dart | 2 +- lib/src/layer/tile_layer.dart | 6 +- lib/src/map/flutter_map_state.dart | 2 +- lib/src/map/map.dart | 2 +- 16 files changed, 103 insertions(+), 31 deletions(-) diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 6725d457a..ab9fc9ecf 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 127B2300FA5CE87549434CC2 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3A72EECE5117AE803156E244 /* Pods_Runner.framework */; }; 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; @@ -31,7 +32,9 @@ /* Begin PBXFileReference section */ 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 3A72EECE5117AE803156E244 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 4928082F7E2BC0BADA4A6955 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; @@ -42,6 +45,8 @@ 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + CF9AFCBF84244C1D44C2E795 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; + E1DF330ADC8450B8B567025E /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -49,12 +54,32 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 127B2300FA5CE87549434CC2 /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 13FB0627975E846BA76A343C /* Pods */ = { + isa = PBXGroup; + children = ( + CF9AFCBF84244C1D44C2E795 /* Pods-Runner.debug.xcconfig */, + 4928082F7E2BC0BADA4A6955 /* Pods-Runner.release.xcconfig */, + E1DF330ADC8450B8B567025E /* Pods-Runner.profile.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; + 1DB0744A0D67D7FBC7C14ADA /* Frameworks */ = { + isa = PBXGroup; + children = ( + 3A72EECE5117AE803156E244 /* Pods_Runner.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( @@ -72,6 +97,8 @@ 9740EEB11CF90186004384FC /* Flutter */, 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, + 13FB0627975E846BA76A343C /* Pods */, + 1DB0744A0D67D7FBC7C14ADA /* Frameworks */, ); sourceTree = ""; }; @@ -105,12 +132,14 @@ isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( + 2655651DCB6AEB0882B90CC1 /* [CP] Check Pods Manifest.lock */, 9740EEB61CF901F6004384FC /* Run Script */, 97C146EA1CF9000F007C117D /* Sources */, 97C146EB1CF9000F007C117D /* Frameworks */, 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + C1C85694F6D3CCB2E45E23F9 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -169,6 +198,28 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + 2655651DCB6AEB0882B90CC1 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -197,6 +248,23 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; }; + C1C85694F6D3CCB2E45E23F9 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ diff --git a/example/ios/Runner.xcworkspace/contents.xcworkspacedata b/example/ios/Runner.xcworkspace/contents.xcworkspacedata index 1d526a16e..21a3cc14c 100644 --- a/example/ios/Runner.xcworkspace/contents.xcworkspacedata +++ b/example/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -4,4 +4,7 @@ + + diff --git a/example/lib/pages/animated_map_controller.dart b/example/lib/pages/animated_map_controller.dart index 4deb55ce1..00de5c0f8 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); - late MapController mapController; + late final 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 bdb7a7536..e670f316a 100644 --- a/example/lib/pages/custom_crs/custom_crs.dart +++ b/example/lib/pages/custom_crs/custom_crs.dart @@ -14,7 +14,7 @@ class CustomCrsPage extends StatefulWidget { } class _CustomCrsPageState extends State { - late Proj4Crs epsg3413CRS; + late final Proj4Crs epsg3413CRS; double? maxZoom; @@ -23,9 +23,9 @@ class _CustomCrsPageState extends State { String initText = 'Map centered to'; - late proj4.Projection epsg4326; + late final proj4.Projection epsg4326; - late proj4.Projection epsg3413; + late final proj4.Projection epsg3413; @override void initState() { diff --git a/example/lib/pages/interactive_test_page.dart b/example/lib/pages/interactive_test_page.dart index 7bc127622..40fdc50e4 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 { - late MapController mapController; + late final MapController mapController; // Enable pinchZoom and doubleTapZoomBy by default int flags = InteractiveFlag.pinchZoom | InteractiveFlag.doubleTapZoom; - late StreamSubscription subscription; + late final StreamSubscription subscription; @override void initState() { diff --git a/example/lib/pages/live_location.dart b/example/lib/pages/live_location.dart index 1566131d1..4d2f4e34e 100644 --- a/example/lib/pages/live_location.dart +++ b/example/lib/pages/live_location.dart @@ -15,7 +15,7 @@ class LiveLocationPage extends StatefulWidget { class _LiveLocationPageState extends State { LocationData? _currentLocation; - late MapController _mapController; + late final MapController _mapController; bool _liveUpdate = false; bool _permission = false; diff --git a/example/lib/pages/map_controller.dart b/example/lib/pages/map_controller.dart index 433084247..ec3e4658e 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); - late MapController mapController; + late final MapController mapController; double rotation = 0.0; @override @@ -192,7 +192,7 @@ class _CurrentLocationState extends State { int _eventKey = 0; var icon = Icons.gps_not_fixed; - late StreamSubscription mapEventSubscription; + late final StreamSubscription mapEventSubscription; @override void initState() { diff --git a/example/lib/pages/moving_markers.dart b/example/lib/pages/moving_markers.dart index f92046bf3..7d015a288 100644 --- a/example/lib/pages/moving_markers.dart +++ b/example/lib/pages/moving_markers.dart @@ -17,7 +17,7 @@ class MovingMarkersPage extends StatefulWidget { class _MovingMarkersPageState extends State { Marker? _marker; - late Timer _timer; + late final Timer _timer; int _markerIndex = 0; @override diff --git a/example/lib/pages/stateful_markers.dart b/example/lib/pages/stateful_markers.dart index 929e4c49c..c48469bd7 100644 --- a/example/lib/pages/stateful_markers.dart +++ b/example/lib/pages/stateful_markers.dart @@ -91,7 +91,7 @@ class _ColorMarker extends StatefulWidget { } class _ColorMarkerState extends State<_ColorMarker> { - late Color color; + late final Color color; @override void initState() { diff --git a/lib/src/core/util.dart b/lib/src/core/util.dart index 5b8ab54b3..f7a1de8a7 100644 --- a/lib/src/core/util.dart +++ b/lib/src/core/util.dart @@ -37,7 +37,8 @@ StreamTransformer throttleStreamTransformerWithTrailingCall( T recentData; var trailingCall = false; - late void Function(T data, EventSink sink) throttleHandler; + late final void Function(T data, EventSink sink) throttleHandler; + throttleHandler = (T data, EventSink sink) { recentData = data; diff --git a/lib/src/gestures/gestures.dart b/lib/src/gestures/gestures.dart index 308e31196..47b7822ad 100644 --- a/lib/src/gestures/gestures.dart +++ b/lib/src/gestures/gestures.dart @@ -31,22 +31,22 @@ abstract class MapGestureMixin extends State // Helps to reset ScaleUpdateDetails.scale back to 1.0 when a multi finger // gesture wins - late double _scaleCorrector; + late final double _scaleCorrector; - late double _lastRotation; - late double _lastScale; - late Offset _lastFocalLocal; + late final double _lastRotation; + late final double _lastScale; + late final Offset _lastFocalLocal; - late LatLng _mapCenterStart; - late double _mapZoomStart; - late Offset _focalStartLocal; + late final LatLng _mapCenterStart; + late final double _mapZoomStart; + late final Offset _focalStartLocal; - late AnimationController _flingController; - late Animation _flingAnimation; + late final AnimationController _flingController; + late final Animation _flingAnimation; - late AnimationController _doubleTapController; - late Animation _doubleTapZoomAnimation; - late Animation _doubleTapCenterAnimation; + late final AnimationController _doubleTapController; + late final Animation _doubleTapZoomAnimation; + late final Animation _doubleTapCenterAnimation; int _tapUpCounter = 0; Timer? _doubleTapHoldMaxDelay; diff --git a/lib/src/layer/polygon_layer.dart b/lib/src/layer/polygon_layer.dart index 7284aec53..05ab0be6f 100644 --- a/lib/src/layer/polygon_layer.dart +++ b/lib/src/layer/polygon_layer.dart @@ -35,7 +35,7 @@ class Polygon { final Color borderColor; final bool disableHolesBorder; final bool isDotted; - late LatLngBounds boundingBox; + late final LatLngBounds boundingBox; Polygon({ required this.points, diff --git a/lib/src/layer/polyline_layer.dart b/lib/src/layer/polyline_layer.dart index 5d0127f18..5bba99771 100644 --- a/lib/src/layer/polyline_layer.dart +++ b/lib/src/layer/polyline_layer.dart @@ -34,7 +34,7 @@ class Polyline { final List? gradientColors; final List? colorsStop; final bool isDotted; - late LatLngBounds boundingBox; + late final LatLngBounds boundingBox; Polyline({ required this.points, diff --git a/lib/src/layer/tile_layer.dart b/lib/src/layer/tile_layer.dart index b723aa7e6..382abc709 100644 --- a/lib/src/layer/tile_layer.dart +++ b/lib/src/layer/tile_layer.dart @@ -342,9 +342,9 @@ class WMSTileLayerOptions { /// other request parameters final Map otherParameters; - late String _encodedBaseUrl; + late final String _encodedBaseUrl; - late double _versionNumber; + late final double _versionNumber; WMSTileLayerOptions({ required this.baseUrl, @@ -435,7 +435,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { MapState get map => widget.mapState; TileLayerOptions get options => widget.options; - late Bounds _globalTileRange; + late final Bounds _globalTileRange; Tuple2? _wrapX; Tuple2? _wrapY; double? _tileZoom; diff --git a/lib/src/map/flutter_map_state.dart b/lib/src/map/flutter_map_state.dart index a2a0f78c4..e66f4ddc3 100644 --- a/lib/src/map/flutter_map_state.dart +++ b/lib/src/map/flutter_map_state.dart @@ -19,7 +19,7 @@ class FlutterMapState extends MapGestureMixin { MapOptions get options => widget.options; @override - late MapState mapState; + late final MapState mapState; FlutterMapState(MapController? mapController) : mapController = mapController as MapControllerImpl? ?? diff --git a/lib/src/map/map.dart b/lib/src/map/map.dart index 3706f365e..e32c92a17 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; - late MapState _state; + late final MapState _state; @override Future get onReady => _readyCompleter.future; From 2765f26fa41752a5428056902561c910493db116 Mon Sep 17 00:00:00 2001 From: John Ryan Date: Fri, 4 Jun 2021 08:36:59 -0700 Subject: [PATCH 46/46] revert making urlTemplate non-nullable --- lib/src/layer/tile_layer.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/src/layer/tile_layer.dart b/lib/src/layer/tile_layer.dart index 382abc709..1f040217c 100644 --- a/lib/src/layer/tile_layer.dart +++ b/lib/src/layer/tile_layer.dart @@ -49,7 +49,7 @@ 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). @@ -242,7 +242,8 @@ class TileLayerOptions extends LayerOptions { TileLayerOptions({ Key? key, - required this.urlTemplate, + // TODO: make required + this.urlTemplate, double tileSize = 256.0, double minZoom = 0.0, double maxZoom = 18.0,