From 64e3a8ec304b999f9ef6d0bece7874216ff76bed Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Tue, 23 May 2023 10:06:52 +0200 Subject: [PATCH] Upgrade 'latlong2' & 'http' dependencies (#1530) --- .../lib/pages/animated_map_controller.dart | 8 +-- example/lib/pages/circle.dart | 4 +- example/lib/pages/epsg3413_crs.dart | 12 ++-- example/lib/pages/epsg4326_crs.dart | 2 +- .../lib/pages/fallback_url_network_page.dart | 2 +- .../lib/pages/fallback_url_offline_page.dart | 2 +- example/lib/pages/home.dart | 8 +-- example/lib/pages/interactive_test_page.dart | 2 +- example/lib/pages/latlng_to_screen_point.dart | 2 +- example/lib/pages/live_location.dart | 2 +- example/lib/pages/many_markers.dart | 2 +- example/lib/pages/map_controller.dart | 8 +-- example/lib/pages/map_inside_listview.dart | 2 +- example/lib/pages/marker_anchor.dart | 8 +-- example/lib/pages/marker_rotate.dart | 8 +-- example/lib/pages/max_bounds.dart | 7 ++- example/lib/pages/moving_markers.dart | 8 +-- example/lib/pages/network_tile_provider.dart | 8 +-- example/lib/pages/offline_map.dart | 6 +- example/lib/pages/on_tap.dart | 8 +-- example/lib/pages/overlay_image.dart | 13 ++-- example/lib/pages/plugin_scalebar.dart | 2 +- example/lib/pages/plugin_zoombuttons.dart | 2 +- example/lib/pages/point_to_latlng.dart | 2 +- example/lib/pages/polygon.dart | 62 +++++++++---------- example/lib/pages/polyline.dart | 34 +++++----- example/lib/pages/reset_tile_layer.dart | 4 +- example/lib/pages/secondary_tap.dart | 2 +- example/lib/pages/sliding_map.dart | 6 +- example/lib/pages/stateful_markers.dart | 2 +- example/lib/pages/tap_to_add.dart | 2 +- example/lib/pages/tile_builder_example.dart | 4 +- .../lib/pages/tile_loading_error_handle.dart | 2 +- example/lib/pages/widgets.dart | 8 +-- example/lib/pages/wms_tile_layer.dart | 2 +- example/lib/test_app.dart | 2 +- example/pubspec.yaml | 2 +- lib/flutter_map.dart | 2 +- lib/src/geo/latlng_bounds.dart | 22 ++++--- lib/src/layer/polyline_layer.dart | 3 +- pubspec.yaml | 4 +- test/flutter_map_controller_test.dart | 22 +++---- test/flutter_map_test.dart | 6 +- test/geo/latlng_bounds_test.dart | 6 +- test/layer/circle_layer_test.dart | 2 +- test/layer/marker_layer_test.dart | 2 +- test/layer/polygon_layer_test.dart | 6 +- .../tile_bounds/tile_bounds_test.dart | 4 +- test/test_utils/test_app.dart | 2 +- 49 files changed, 176 insertions(+), 165 deletions(-) diff --git a/example/lib/pages/animated_map_controller.dart b/example/lib/pages/animated_map_controller.dart index b33592f17..0f0b1529f 100644 --- a/example/lib/pages/animated_map_controller.dart +++ b/example/lib/pages/animated_map_controller.dart @@ -20,9 +20,9 @@ class AnimatedMapControllerPageState extends State static const _inProgressId = 'AnimatedMapController#MoveInProgress'; static const _finishedId = 'AnimatedMapController#MoveFinished'; - static final london = LatLng(51.5, -0.09); - static final paris = LatLng(48.8566, 2.3522); - static final dublin = LatLng(53.3498, -6.2603); + static const london = LatLng(51.5, -0.09); + static const paris = LatLng(48.8566, 2.3522); + static const dublin = LatLng(53.3498, -6.2603); late final MapController mapController; @@ -191,7 +191,7 @@ class AnimatedMapControllerPageState extends State child: FlutterMap( mapController: mapController, options: MapOptions( - center: LatLng(51.5, -0.09), + center: const LatLng(51.5, -0.09), zoom: 5, maxZoom: 10, minZoom: 3), diff --git a/example/lib/pages/circle.dart b/example/lib/pages/circle.dart index ad8ecb2f8..f3a332241 100644 --- a/example/lib/pages/circle.dart +++ b/example/lib/pages/circle.dart @@ -12,7 +12,7 @@ class CirclePage extends StatelessWidget { Widget build(BuildContext context) { final circleMarkers = [ CircleMarker( - point: LatLng(51.5, -0.09), + point: const LatLng(51.5, -0.09), color: Colors.blue.withOpacity(0.7), borderStrokeWidth: 2, useRadiusInMeter: true, @@ -34,7 +34,7 @@ class CirclePage extends StatelessWidget { Flexible( child: FlutterMap( options: MapOptions( - center: LatLng(51.5, -0.09), + center: const LatLng(51.5, -0.09), zoom: 11, ), children: [ diff --git a/example/lib/pages/epsg3413_crs.dart b/example/lib/pages/epsg3413_crs.dart index 732bcc864..3d7d4affd 100644 --- a/example/lib/pages/epsg3413_crs.dart +++ b/example/lib/pages/epsg3413_crs.dart @@ -66,7 +66,7 @@ class _EPSG3413PageState extends State { // These circles should have the same pixel radius on the map final circles = [ CircleMarker( - point: LatLng(90, 0), + point: const LatLng(90, 0), radius: 20000, useRadiusInMeter: true, color: Colors.yellow, @@ -83,9 +83,9 @@ class _EPSG3413PageState extends State { // Add latitude line at 80 degrees final distancePoleToLat80 = - const Distance().distance(LatLng(90, 0), LatLng(80, 0)); + const Distance().distance(const LatLng(90, 0), const LatLng(80, 0)); circles.add(CircleMarker( - point: LatLng(90, 0), + point: const LatLng(90, 0), radius: distancePoleToLat80, useRadiusInMeter: true, color: Colors.transparent, @@ -130,7 +130,7 @@ class _EPSG3413PageState extends State { child: FlutterMap( options: MapOptions( crs: epsg3413CRS, - center: LatLng(90, 0), + center: const LatLng(90, 0), zoom: 3, maxZoom: maxZoom, ), @@ -168,8 +168,8 @@ class _EPSG3413PageState extends State { overlayImages: [ OverlayImage( bounds: LatLngBounds( - LatLng(72.7911372, 162.6196478), - LatLng(85.2802493, 79.794166), + const LatLng(72.7911372, 162.6196478), + const LatLng(85.2802493, 79.794166), ), imageProvider: Image.asset( 'assets/map/epsg3413/amsr2.png', diff --git a/example/lib/pages/epsg4326_crs.dart b/example/lib/pages/epsg4326_crs.dart index 7bd3f8664..544967441 100644 --- a/example/lib/pages/epsg4326_crs.dart +++ b/example/lib/pages/epsg4326_crs.dart @@ -26,7 +26,7 @@ class EPSG4326Page extends StatelessWidget { options: MapOptions( minZoom: 0, crs: const Epsg4326(), - center: LatLng(0, 0), + center: const LatLng(0, 0), zoom: 0, ), children: [ diff --git a/example/lib/pages/fallback_url_network_page.dart b/example/lib/pages/fallback_url_network_page.dart index a61e2ddbe..2d857627b 100644 --- a/example/lib/pages/fallback_url_network_page.dart +++ b/example/lib/pages/fallback_url_network_page.dart @@ -22,7 +22,7 @@ class FallbackUrlNetworkPage extends StatelessWidget { description: 'Map with a fake url should use the fallback, showing (51.5, -0.9).', zoom: 5, - center: LatLng(51.5, -0.09), + center: const LatLng(51.5, -0.09), ); } } diff --git a/example/lib/pages/fallback_url_offline_page.dart b/example/lib/pages/fallback_url_offline_page.dart index 6f74ff1a1..aa4818b93 100644 --- a/example/lib/pages/fallback_url_offline_page.dart +++ b/example/lib/pages/fallback_url_offline_page.dart @@ -23,7 +23,7 @@ class FallbackUrlOfflinePage extends StatelessWidget { 'Map with a fake asset path, should be using the fallback to show Anholt Island, Denmark.', maxZoom: 14, minZoom: 12, - center: LatLng(56.704173, 11.543808), + center: const LatLng(56.704173, 11.543808), ); } } diff --git a/example/lib/pages/home.dart b/example/lib/pages/home.dart index 75e82130c..159575901 100644 --- a/example/lib/pages/home.dart +++ b/example/lib/pages/home.dart @@ -15,7 +15,7 @@ class HomePage extends StatelessWidget { Marker( width: 80, height: 80, - point: LatLng(51.5, -0.09), + point: const LatLng(51.5, -0.09), builder: (ctx) => const FlutterLogo( textColor: Colors.blue, key: ObjectKey(Colors.blue), @@ -24,7 +24,7 @@ class HomePage extends StatelessWidget { Marker( width: 80, height: 80, - point: LatLng(53.3498, -6.2603), + point: const LatLng(53.3498, -6.2603), builder: (ctx) => const FlutterLogo( textColor: Colors.green, key: ObjectKey(Colors.green), @@ -33,7 +33,7 @@ class HomePage extends StatelessWidget { Marker( width: 80, height: 80, - point: LatLng(48.8566, 2.3522), + point: const LatLng(48.8566, 2.3522), builder: (ctx) => const FlutterLogo( textColor: Colors.purple, key: ObjectKey(Colors.purple), @@ -55,7 +55,7 @@ class HomePage extends StatelessWidget { Flexible( child: FlutterMap( options: MapOptions( - center: LatLng(51.5, -0.09), + center: const LatLng(51.5, -0.09), zoom: 5, ), nonRotatedChildren: [ diff --git a/example/lib/pages/interactive_test_page.dart b/example/lib/pages/interactive_test_page.dart index de7689b24..9a8283236 100644 --- a/example/lib/pages/interactive_test_page.dart +++ b/example/lib/pages/interactive_test_page.dart @@ -148,7 +148,7 @@ class _InteractiveTestPageState extends State { child: FlutterMap( options: MapOptions( onMapEvent: onMapEvent, - center: LatLng(51.5, -0.09), + center: const LatLng(51.5, -0.09), zoom: 11, interactiveFlags: flags, ), diff --git a/example/lib/pages/latlng_to_screen_point.dart b/example/lib/pages/latlng_to_screen_point.dart index e8fee6004..9ed50b7f2 100644 --- a/example/lib/pages/latlng_to_screen_point.dart +++ b/example/lib/pages/latlng_to_screen_point.dart @@ -50,7 +50,7 @@ class _LatLngScreenPointTestPageState extends State { _textPos = CustomPoint(pt1!.x, pt1.y); setState(() {}); }, - center: LatLng(51.5, -0.09), + center: const LatLng(51.5, -0.09), zoom: 11, rotation: 0, ), diff --git a/example/lib/pages/live_location.dart b/example/lib/pages/live_location.dart index 63c3ea1b0..92d0ca0f1 100644 --- a/example/lib/pages/live_location.dart +++ b/example/lib/pages/live_location.dart @@ -99,7 +99,7 @@ class _LiveLocationPageState extends State { currentLatLng = LatLng(_currentLocation!.latitude!, _currentLocation!.longitude!); } else { - currentLatLng = LatLng(0, 0); + currentLatLng = const LatLng(0, 0); } final markers = [ diff --git a/example/lib/pages/many_markers.dart b/example/lib/pages/many_markers.dart index 0dd03a31f..b0ad1bf42 100644 --- a/example/lib/pages/many_markers.dart +++ b/example/lib/pages/many_markers.dart @@ -73,7 +73,7 @@ class _ManyMarkersPageState extends State { Flexible( child: FlutterMap( options: MapOptions( - center: LatLng(50, 20), + center: const LatLng(50, 20), zoom: 5, interactiveFlags: InteractiveFlag.all - InteractiveFlag.rotate, ), diff --git a/example/lib/pages/map_controller.dart b/example/lib/pages/map_controller.dart index 7a3b63853..54f336b4d 100644 --- a/example/lib/pages/map_controller.dart +++ b/example/lib/pages/map_controller.dart @@ -17,9 +17,9 @@ class MapControllerPage extends StatefulWidget { } } -final LatLng london = LatLng(51.5, -0.09); -final LatLng paris = LatLng(48.8566, 2.3522); -final LatLng dublin = LatLng(53.3498, -6.2603); +const LatLng london = LatLng(51.5, -0.09); +const LatLng paris = LatLng(48.8566, 2.3522); +const LatLng dublin = LatLng(53.3498, -6.2603); class MapControllerPageState extends State { late final MapController _mapController; @@ -156,7 +156,7 @@ class MapControllerPageState extends State { child: FlutterMap( mapController: _mapController, options: MapOptions( - center: LatLng(51.5, -0.09), + center: const LatLng(51.5, -0.09), zoom: 5, maxZoom: 5, minZoom: 3, diff --git a/example/lib/pages/map_inside_listview.dart b/example/lib/pages/map_inside_listview.dart index dd8c32624..50734e64a 100644 --- a/example/lib/pages/map_inside_listview.dart +++ b/example/lib/pages/map_inside_listview.dart @@ -23,7 +23,7 @@ class MapInsideListViewPage extends StatelessWidget { height: 300, child: FlutterMap( options: MapOptions( - center: LatLng(51.5, -0.09), + center: const LatLng(51.5, -0.09), zoom: 5, ), nonRotatedChildren: const [ diff --git a/example/lib/pages/marker_anchor.dart b/example/lib/pages/marker_anchor.dart index efda278d1..5d2c4ce8b 100644 --- a/example/lib/pages/marker_anchor.dart +++ b/example/lib/pages/marker_anchor.dart @@ -41,14 +41,14 @@ class MarkerAnchorPageState extends State { Marker( width: 80, height: 80, - point: LatLng(51.5, -0.09), + point: const LatLng(51.5, -0.09), builder: (ctx) => const FlutterLogo(), anchorPos: anchorPos, ), Marker( width: 80, height: 80, - point: LatLng(53.3498, -6.2603), + point: const LatLng(53.3498, -6.2603), builder: (ctx) => const FlutterLogo( textColor: Colors.green, ), @@ -57,7 +57,7 @@ class MarkerAnchorPageState extends State { Marker( width: 80, height: 80, - point: LatLng(48.8566, 2.3522), + point: const LatLng(48.8566, 2.3522), builder: (ctx) => const FlutterLogo(textColor: Colors.purple), anchorPos: anchorPos, ), @@ -109,7 +109,7 @@ class MarkerAnchorPageState extends State { Flexible( child: FlutterMap( options: MapOptions( - center: LatLng(51.5, -0.09), + center: const LatLng(51.5, -0.09), zoom: 5, ), children: [ diff --git a/example/lib/pages/marker_rotate.dart b/example/lib/pages/marker_rotate.dart index 4ef08c61d..7bd458e3a 100644 --- a/example/lib/pages/marker_rotate.dart +++ b/example/lib/pages/marker_rotate.dart @@ -73,14 +73,14 @@ class MarkerRotatePageState extends State { Marker( width: 80, height: 80, - point: LatLng(51.5, -0.09), + point: const LatLng(51.5, -0.09), rotate: rotateMarkerLondon, builder: (ctx) => const FlutterLogo(), ), Marker( width: 80, height: 80, - point: LatLng(53.3498, -6.2603), + point: const LatLng(53.3498, -6.2603), rotate: rotateMarkerDublin, builder: (ctx) => const FlutterLogo( textColor: Colors.green, @@ -89,7 +89,7 @@ class MarkerRotatePageState extends State { Marker( width: 80, height: 80, - point: LatLng(48.8566, 2.3522), + point: const LatLng(48.8566, 2.3522), rotate: rotateMarkerParis, builder: (ctx) => const FlutterLogo(textColor: Colors.purple), ), @@ -134,7 +134,7 @@ class MarkerRotatePageState extends State { Flexible( child: FlutterMap( options: MapOptions( - center: LatLng(51.5, -0.09), + center: const LatLng(51.5, -0.09), zoom: 5, ), children: [ diff --git a/example/lib/pages/max_bounds.dart b/example/lib/pages/max_bounds.dart index 1431a9b2a..0d8153710 100644 --- a/example/lib/pages/max_bounds.dart +++ b/example/lib/pages/max_bounds.dart @@ -25,9 +25,12 @@ class MaxBoundsPage extends StatelessWidget { Flexible( child: FlutterMap( options: MapOptions( - center: LatLng(56.704173, 11.543808), + center: const LatLng(56.704173, 11.543808), zoom: 3, - maxBounds: LatLngBounds(LatLng(-90, -180), LatLng(90, 180)), + maxBounds: LatLngBounds( + const LatLng(-90, -180), + const LatLng(90, 180), + ), screenSize: MediaQuery.of(context).size, ), children: [ diff --git a/example/lib/pages/moving_markers.dart b/example/lib/pages/moving_markers.dart index b54913532..6b8d75efe 100644 --- a/example/lib/pages/moving_markers.dart +++ b/example/lib/pages/moving_markers.dart @@ -55,7 +55,7 @@ class _MovingMarkersPageState extends State { Flexible( child: FlutterMap( options: MapOptions( - center: LatLng(51.5, -0.09), + center: const LatLng(51.5, -0.09), zoom: 5, ), children: [ @@ -79,19 +79,19 @@ List _markers = [ Marker( width: 80, height: 80, - point: LatLng(51.5, -0.09), + point: const LatLng(51.5, -0.09), builder: (ctx) => const FlutterLogo(), ), Marker( width: 80, height: 80, - point: LatLng(53.3498, -6.2603), + point: const LatLng(53.3498, -6.2603), builder: (ctx) => const FlutterLogo(), ), Marker( width: 80, height: 80, - point: LatLng(48.8566, 2.3522), + point: const LatLng(48.8566, 2.3522), builder: (ctx) => const FlutterLogo(), ), ]; diff --git a/example/lib/pages/network_tile_provider.dart b/example/lib/pages/network_tile_provider.dart index 5e8336c6b..1b5a7d7b9 100644 --- a/example/lib/pages/network_tile_provider.dart +++ b/example/lib/pages/network_tile_provider.dart @@ -14,7 +14,7 @@ class NetworkTileProviderPage extends StatelessWidget { Marker( width: 80, height: 80, - point: LatLng(51.5, -0.09), + point: const LatLng(51.5, -0.09), builder: (ctx) => const FlutterLogo( textColor: Colors.blue, key: ObjectKey(Colors.blue), @@ -23,7 +23,7 @@ class NetworkTileProviderPage extends StatelessWidget { Marker( width: 80, height: 80, - point: LatLng(53.3498, -6.2603), + point: const LatLng(53.3498, -6.2603), builder: (ctx) => const FlutterLogo( textColor: Colors.green, key: ObjectKey(Colors.green), @@ -32,7 +32,7 @@ class NetworkTileProviderPage extends StatelessWidget { Marker( width: 80, height: 80, - point: LatLng(48.8566, 2.3522), + point: const LatLng(48.8566, 2.3522), builder: (ctx) => const FlutterLogo( textColor: Colors.purple, key: ObjectKey(Colors.purple), @@ -61,7 +61,7 @@ class NetworkTileProviderPage extends StatelessWidget { Flexible( child: FlutterMap( options: MapOptions( - center: LatLng(51.5, -0.09), + center: const LatLng(51.5, -0.09), zoom: 5, ), children: [ diff --git a/example/lib/pages/offline_map.dart b/example/lib/pages/offline_map.dart index 1345ee136..91c9ca41b 100644 --- a/example/lib/pages/offline_map.dart +++ b/example/lib/pages/offline_map.dart @@ -25,11 +25,11 @@ class OfflineMapPage extends StatelessWidget { Flexible( child: FlutterMap( options: MapOptions( - center: LatLng(56.704173, 11.543808), + center: const LatLng(56.704173, 11.543808), minZoom: 12, maxZoom: 14, - swPanBoundary: LatLng(56.6877, 11.5089), - nePanBoundary: LatLng(56.7378, 11.6644), + swPanBoundary: const LatLng(56.6877, 11.5089), + nePanBoundary: const LatLng(56.7378, 11.6644), ), children: [ TileLayer( diff --git a/example/lib/pages/on_tap.dart b/example/lib/pages/on_tap.dart index 9d5f87456..9584ec02d 100644 --- a/example/lib/pages/on_tap.dart +++ b/example/lib/pages/on_tap.dart @@ -15,9 +15,9 @@ class OnTapPage extends StatefulWidget { } class OnTapPageState extends State { - static LatLng london = LatLng(51.5, -0.09); - static LatLng paris = LatLng(48.8566, 2.3522); - static LatLng dublin = LatLng(53.3498, -6.2603); + static LatLng london = const LatLng(51.5, -0.09); + static LatLng paris = const LatLng(48.8566, 2.3522); + static LatLng dublin = const LatLng(53.3498, -6.2603); @override Widget build(BuildContext context) { @@ -79,7 +79,7 @@ class OnTapPageState extends State { Flexible( child: FlutterMap( options: MapOptions( - center: LatLng(51.5, -0.09), + center: const LatLng(51.5, -0.09), zoom: 5, maxZoom: 5, minZoom: 3, diff --git a/example/lib/pages/overlay_image.dart b/example/lib/pages/overlay_image.dart index a8f024b47..2fb86489b 100644 --- a/example/lib/pages/overlay_image.dart +++ b/example/lib/pages/overlay_image.dart @@ -10,13 +10,16 @@ class OverlayImagePage extends StatelessWidget { @override Widget build(BuildContext context) { - final topLeftCorner = LatLng(53.377, -2.999); - final bottomRightCorner = LatLng(53.475, 0.275); - final bottomLeftCorner = LatLng(52.503, -1.868); + const topLeftCorner = LatLng(53.377, -2.999); + const bottomRightCorner = LatLng(53.475, 0.275); + const bottomLeftCorner = LatLng(52.503, -1.868); final overlayImages = [ OverlayImage( - bounds: LatLngBounds(LatLng(51.5, -0.09), LatLng(48.8566, 2.3522)), + bounds: LatLngBounds( + const LatLng(51.5, -0.09), + const LatLng(48.8566, 2.3522), + ), opacity: 0.8, imageProvider: const NetworkImage( 'https://images.pexels.com/photos/231009/pexels-photo-231009.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=300&w=600')), @@ -43,7 +46,7 @@ class OverlayImagePage extends StatelessWidget { Flexible( child: FlutterMap( options: MapOptions( - center: LatLng(51.5, -0.09), + center: const LatLng(51.5, -0.09), zoom: 6, ), children: [ diff --git a/example/lib/pages/plugin_scalebar.dart b/example/lib/pages/plugin_scalebar.dart index 582cd8978..edbe74049 100644 --- a/example/lib/pages/plugin_scalebar.dart +++ b/example/lib/pages/plugin_scalebar.dart @@ -21,7 +21,7 @@ class PluginScaleBar extends StatelessWidget { Flexible( child: FlutterMap( options: MapOptions( - center: LatLng(51.5, -0.09), + center: const LatLng(51.5, -0.09), zoom: 5, ), nonRotatedChildren: [ diff --git a/example/lib/pages/plugin_zoombuttons.dart b/example/lib/pages/plugin_zoombuttons.dart index 7a9ab7b00..3c95f1fe2 100644 --- a/example/lib/pages/plugin_zoombuttons.dart +++ b/example/lib/pages/plugin_zoombuttons.dart @@ -21,7 +21,7 @@ class PluginZoomButtons extends StatelessWidget { Flexible( child: FlutterMap( options: MapOptions( - center: LatLng(51.5, -0.09), + center: const LatLng(51.5, -0.09), zoom: 5, ), nonRotatedChildren: const [ diff --git a/example/lib/pages/point_to_latlng.dart b/example/lib/pages/point_to_latlng.dart index 431470c0a..c00c62e0e 100644 --- a/example/lib/pages/point_to_latlng.dart +++ b/example/lib/pages/point_to_latlng.dart @@ -59,7 +59,7 @@ class PointToLatlngPage extends State { onMapEvent: (event) { updatePoint(null, context); }, - center: LatLng(51.5, -0.09), + center: const LatLng(51.5, -0.09), zoom: 5, minZoom: 3, ), diff --git a/example/lib/pages/polygon.dart b/example/lib/pages/polygon.dart index 063372dc6..9bffd1423 100644 --- a/example/lib/pages/polygon.dart +++ b/example/lib/pages/polygon.dart @@ -11,57 +11,57 @@ class PolygonPage extends StatelessWidget { @override Widget build(BuildContext context) { final notFilledPoints = [ - LatLng(51.5, -0.09), - LatLng(53.3498, -6.2603), - LatLng(48.8566, 2.3522), + const LatLng(51.5, -0.09), + const LatLng(53.3498, -6.2603), + const LatLng(48.8566, 2.3522), ]; final filledPoints = [ - LatLng(55.5, -0.09), - LatLng(54.3498, -6.2603), - LatLng(52.8566, 2.3522), + const LatLng(55.5, -0.09), + const LatLng(54.3498, -6.2603), + const LatLng(52.8566, 2.3522), ]; final notFilledDotedPoints = [ - LatLng(49.29, -2.57), - LatLng(51.46, -6.43), - LatLng(49.86, -8.17), - LatLng(48.39, -3.49), + const LatLng(49.29, -2.57), + const LatLng(51.46, -6.43), + const LatLng(49.86, -8.17), + const LatLng(48.39, -3.49), ]; final filledDotedPoints = [ - LatLng(46.35, 4.94), - LatLng(46.22, -0.11), - LatLng(44.399, 1.76), + const LatLng(46.35, 4.94), + const LatLng(46.22, -0.11), + const LatLng(44.399, 1.76), ]; final labelPoints = [ - LatLng(60.16, -9.38), - LatLng(60.16, -4.16), - LatLng(61.18, -4.16), - LatLng(61.18, -9.38), + const LatLng(60.16, -9.38), + const LatLng(60.16, -4.16), + const LatLng(61.18, -4.16), + const LatLng(61.18, -9.38), ]; final labelRotatedPoints = [ - LatLng(59.77, -10.28), - LatLng(58.21, -10.28), - LatLng(58.21, -7.01), - LatLng(59.77, -7.01), - LatLng(60.77, -6.01), + const LatLng(59.77, -10.28), + const LatLng(58.21, -10.28), + const LatLng(58.21, -7.01), + const LatLng(59.77, -7.01), + const LatLng(60.77, -6.01), ]; final holeOuterPoints = [ - LatLng(50, -18), - LatLng(50, -14), - LatLng(54, -14), - LatLng(54, -18), + const LatLng(50, -18), + const LatLng(50, -14), + const LatLng(54, -14), + const LatLng(54, -18), ]; final holeInnerPoints = [ - LatLng(51, -17), - LatLng(51, -16), - LatLng(52, -16), - LatLng(52, -17), + const LatLng(51, -17), + const LatLng(51, -16), + const LatLng(52, -16), + const LatLng(52, -17), ]; return Scaffold( @@ -78,7 +78,7 @@ class PolygonPage extends StatelessWidget { Flexible( child: FlutterMap( options: MapOptions( - center: LatLng(51.5, -0.09), + center: const LatLng(51.5, -0.09), zoom: 5, ), children: [ diff --git a/example/lib/pages/polyline.dart b/example/lib/pages/polyline.dart index 64116f6cd..2def86729 100644 --- a/example/lib/pages/polyline.dart +++ b/example/lib/pages/polyline.dart @@ -19,9 +19,9 @@ class _PolylinePageState extends State { final polyLines = [ Polyline( points: [ - LatLng(50.5, -0.09), - LatLng(51.3498, -6.2603), - LatLng(53.8566, 2.3522), + const LatLng(50.5, -0.09), + const LatLng(51.3498, -6.2603), + const LatLng(53.8566, 2.3522), ], strokeWidth: 20, color: Colors.blue.withOpacity(0.6), @@ -30,9 +30,9 @@ class _PolylinePageState extends State { ), Polyline( points: [ - LatLng(50.2, -0.08), - LatLng(51.2498, -7.2603), - LatLng(54.8566, 1.3522), + const LatLng(50.2, -0.08), + const LatLng(51.2498, -7.2603), + const LatLng(54.8566, 1.3522), ], strokeWidth: 20, color: Colors.black.withOpacity(0.2), @@ -41,9 +41,9 @@ class _PolylinePageState extends State { ), Polyline( points: [ - LatLng(49.1, -0.06), - LatLng(51.15, -7.4), - LatLng(55.5, 0.8), + const LatLng(49.1, -0.06), + const LatLng(51.15, -7.4), + const LatLng(55.5, 0.8), ], strokeWidth: 10, color: Colors.yellow, @@ -51,7 +51,7 @@ class _PolylinePageState extends State { borderColor: Colors.blue.withOpacity(0.5), ), Polyline( - points: [ + points: const [ LatLng(48.1, -0.03), LatLng(50.5, -7.8), LatLng(56.5, 0.4), @@ -75,15 +75,15 @@ class _PolylinePageState extends State { @override Widget build(BuildContext context) { final points = [ - LatLng(51.5, -0.09), - LatLng(53.3498, -6.2603), - LatLng(48.8566, 2.3522), + const LatLng(51.5, -0.09), + const LatLng(53.3498, -6.2603), + const LatLng(48.8566, 2.3522), ]; final pointsGradient = [ - LatLng(55.5, -0.09), - LatLng(54.3498, -6.2603), - LatLng(52.8566, 2.3522), + const LatLng(55.5, -0.09), + const LatLng(54.3498, -6.2603), + const LatLng(52.8566, 2.3522), ]; return Scaffold( @@ -106,7 +106,7 @@ class _PolylinePageState extends State { Flexible( child: FlutterMap( options: MapOptions( - center: LatLng(51.5, -0.09), + center: const LatLng(51.5, -0.09), zoom: 5, onTap: (tapPosition, point) { setState(() { diff --git a/example/lib/pages/reset_tile_layer.dart b/example/lib/pages/reset_tile_layer.dart index 697504bfd..9c9e35528 100644 --- a/example/lib/pages/reset_tile_layer.dart +++ b/example/lib/pages/reset_tile_layer.dart @@ -41,7 +41,7 @@ class ResetTileLayerPageState extends State { Marker( width: 80, height: 80, - point: LatLng(51.5, -0.09), + point: const LatLng(51.5, -0.09), builder: (ctx) => const FlutterLogo(), ), ]; @@ -72,7 +72,7 @@ class ResetTileLayerPageState extends State { Flexible( child: FlutterMap( options: MapOptions( - center: LatLng(51.5, -0.09), + center: const LatLng(51.5, -0.09), zoom: 5, ), children: [ diff --git a/example/lib/pages/secondary_tap.dart b/example/lib/pages/secondary_tap.dart index a20e498b1..6a82a66f9 100644 --- a/example/lib/pages/secondary_tap.dart +++ b/example/lib/pages/secondary_tap.dart @@ -29,7 +29,7 @@ class SecondaryTapPage extends StatelessWidget { SnackBar(content: Text('Secondary tap at $latLng')), ); }, - center: LatLng(51.5, -0.09), + center: const LatLng(51.5, -0.09), zoom: 5, ), children: [ diff --git a/example/lib/pages/sliding_map.dart b/example/lib/pages/sliding_map.dart index ed0262d22..09bf7eb77 100644 --- a/example/lib/pages/sliding_map.dart +++ b/example/lib/pages/sliding_map.dart @@ -25,12 +25,12 @@ class SlidingMapPage extends StatelessWidget { Flexible( child: FlutterMap( options: MapOptions( - center: LatLng(56.704173, 11.543808), + center: const LatLng(56.704173, 11.543808), minZoom: 12, maxZoom: 14, zoom: 13, - swPanBoundary: LatLng(56.6877, 11.5089), - nePanBoundary: LatLng(56.7378, 11.6644), + swPanBoundary: const LatLng(56.6877, 11.5089), + nePanBoundary: const LatLng(56.7378, 11.6644), slideOnBoundaries: true, screenSize: MediaQuery.of(context).size, ), diff --git a/example/lib/pages/stateful_markers.dart b/example/lib/pages/stateful_markers.dart index 80843fe5c..4b93f7f69 100644 --- a/example/lib/pages/stateful_markers.dart +++ b/example/lib/pages/stateful_markers.dart @@ -60,7 +60,7 @@ class _StatefulMarkersPageState extends State { Flexible( child: FlutterMap( options: MapOptions( - center: LatLng(51.5, -0.09), + center: const LatLng(51.5, -0.09), zoom: 5, ), children: [ diff --git a/example/lib/pages/tap_to_add.dart b/example/lib/pages/tap_to_add.dart index 92287e787..37899ecd2 100644 --- a/example/lib/pages/tap_to_add.dart +++ b/example/lib/pages/tap_to_add.dart @@ -42,7 +42,7 @@ class TapToAddPageState extends State { Flexible( child: FlutterMap( options: MapOptions( - center: LatLng(45.5231, -122.6765), + center: const LatLng(45.5231, -122.6765), zoom: 13, onTap: _handleTap), children: [ diff --git a/example/lib/pages/tile_builder_example.dart b/example/lib/pages/tile_builder_example.dart index d32081149..d080f513d 100644 --- a/example/lib/pages/tile_builder_example.dart +++ b/example/lib/pages/tile_builder_example.dart @@ -121,7 +121,7 @@ class _TileBuilderPageState extends State { padding: const EdgeInsets.all(8), child: FlutterMap( options: MapOptions( - center: LatLng(51.5, -0.09), + center: const LatLng(51.5, -0.09), zoom: 5, ), children: [ @@ -138,7 +138,7 @@ class _TileBuilderPageState extends State { Marker( width: 80, height: 80, - point: LatLng(51.5, -0.09), + point: const LatLng(51.5, -0.09), builder: (ctx) => const FlutterLogo( key: ObjectKey(Colors.blue), ), diff --git a/example/lib/pages/tile_loading_error_handle.dart b/example/lib/pages/tile_loading_error_handle.dart index 502d12ff8..5c1f55cd4 100644 --- a/example/lib/pages/tile_loading_error_handle.dart +++ b/example/lib/pages/tile_loading_error_handle.dart @@ -32,7 +32,7 @@ class _TileLoadingErrorHandleState extends State { child: Builder(builder: (BuildContext context) { return FlutterMap( options: MapOptions( - center: LatLng(51.5, -0.09), + center: const LatLng(51.5, -0.09), zoom: 5, onPositionChanged: (MapPosition mapPosition, bool _) { needLoadingError = true; diff --git a/example/lib/pages/widgets.dart b/example/lib/pages/widgets.dart index 413814d53..c03a7ed27 100644 --- a/example/lib/pages/widgets.dart +++ b/example/lib/pages/widgets.dart @@ -23,7 +23,7 @@ class WidgetsPage extends StatelessWidget { Flexible( child: FlutterMap( options: MapOptions( - center: LatLng(51.5, -0.09), + center: const LatLng(51.5, -0.09), zoom: 5, ), nonRotatedChildren: const [ @@ -104,19 +104,19 @@ List _markers = [ Marker( width: 80, height: 80, - point: LatLng(51.5, -0.09), + point: const LatLng(51.5, -0.09), builder: (ctx) => const FlutterLogo(), ), Marker( width: 80, height: 80, - point: LatLng(53.3498, -6.2603), + point: const LatLng(53.3498, -6.2603), builder: (ctx) => const FlutterLogo(), ), Marker( width: 80, height: 80, - point: LatLng(48.8566, 2.3522), + point: const LatLng(48.8566, 2.3522), builder: (ctx) => const FlutterLogo(), ), ]; diff --git a/example/lib/pages/wms_tile_layer.dart b/example/lib/pages/wms_tile_layer.dart index 24a0c59f3..1459e3598 100644 --- a/example/lib/pages/wms_tile_layer.dart +++ b/example/lib/pages/wms_tile_layer.dart @@ -25,7 +25,7 @@ class WMSLayerPage extends StatelessWidget { Flexible( child: FlutterMap( options: MapOptions( - center: LatLng(42.58, 12.43), + center: const LatLng(42.58, 12.43), zoom: 6, ), nonRotatedChildren: [ diff --git a/example/lib/test_app.dart b/example/lib/test_app.dart index 0a9a67c34..e3c436100 100644 --- a/example/lib/test_app.dart +++ b/example/lib/test_app.dart @@ -29,7 +29,7 @@ class _TestAppState extends State { height: 200, child: FlutterMap( options: MapOptions( - center: LatLng(45.5231, -122.6765), + center: const LatLng(45.5231, -122.6765), zoom: 13, ), children: [ diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 6e60dbfb8..ab0e43b79 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -13,7 +13,7 @@ dependencies: flutter_map: path: ../ location: ^4.4.0 - latlong2: ^0.8.1 + latlong2: ^0.9.0 proj4dart: ^2.1.0 url_launcher: ^6.1.10 diff --git a/lib/flutter_map.dart b/lib/flutter_map.dart index c319cbb67..671f78011 100644 --- a/lib/flutter_map.dart +++ b/lib/flutter_map.dart @@ -333,7 +333,7 @@ class MapOptions { this.nePanBoundary, this.maxBounds, this.keepAlive = false, - }) : center = center ?? LatLng(50.5, 30.51), + }) : center = center ?? const LatLng(50.5, 30.51), assert(rotationThreshold >= 0.0), assert(pinchZoomThreshold >= 0.0), assert(pinchMoveThreshold >= 0.0) { diff --git a/lib/src/geo/latlng_bounds.dart b/lib/src/geo/latlng_bounds.dart index 5f273fd0a..5ddd04df6 100644 --- a/lib/src/geo/latlng_bounds.dart +++ b/lib/src/geo/latlng_bounds.dart @@ -5,8 +5,8 @@ import 'package:latlong2/latlong.dart'; /// Data structure representing rectangular bounding box constrained by its /// northwest and southeast corners class LatLngBounds { - late final LatLng _sw; - late final LatLng _ne; + late LatLng _sw; + late LatLng _ne; LatLngBounds( LatLng corner1, @@ -44,10 +44,10 @@ class LatLngBounds { _ne = LatLng(maxY, maxX); } - /// Expands bounding box by [latlng] coordinate point. This method mutates + /// Expands bounding box by [latLng] coordinate point. This method mutates /// the bounds object on which it is called. - void extend(LatLng latlng) { - _extend(latlng, latlng); + void extend(LatLng latLng) { + _extend(latLng, latLng); } /// Expands bounding box by other [bounds] object. If provided [bounds] object @@ -58,10 +58,14 @@ class LatLngBounds { } void _extend(LatLng sw2, LatLng ne2) { - _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 = LatLng( + math.min(sw2.latitude, _sw.latitude), + math.min(sw2.longitude, _sw.longitude), + ); + _ne = LatLng( + math.max(ne2.latitude, _ne.latitude), + math.max(ne2.longitude, _ne.longitude), + ); } /// Obtain west edge of the bounds diff --git a/lib/src/layer/polyline_layer.dart b/lib/src/layer/polyline_layer.dart index 50b06b3b0..007d526a0 100644 --- a/lib/src/layer/polyline_layer.dart +++ b/lib/src/layer/polyline_layer.dart @@ -20,6 +20,7 @@ class Polyline { final bool useStrokeWidthInMeter; LatLngBounds? _boundingBox; + LatLngBounds get boundingBox { _boundingBox ??= LatLngBounds.fromPoints(points); return _boundingBox!; @@ -64,7 +65,7 @@ class PolylineLayer extends StatelessWidget { this.polylines = const [], this.polylineCulling = false, @Deprecated('No longer needed and will be removed.') - bool saveLayers = false, + bool saveLayers = false, }); @override diff --git a/pubspec.yaml b/pubspec.yaml index be6850bf0..1d537db11 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,8 +15,8 @@ dependencies: collection: ^1.16.0 flutter: sdk: flutter - http: ^0.13.5 - latlong2: ^0.8.0 + http: ^1.0.0 + latlong2: ^0.9.0 meta: ^1.8.0 polylabel: ^1.0.1 proj4dart: ^2.1.0 diff --git a/test/flutter_map_controller_test.dart b/test/flutter_map_controller_test.dart index c219673d0..b17e9a8b5 100644 --- a/test/flutter_map_controller_test.dart +++ b/test/flutter_map_controller_test.dart @@ -11,10 +11,10 @@ void main() { testWidgets('test fit bounds methods', (tester) async { final controller = MapController(); final bounds = LatLngBounds( - LatLng(51, 0), - LatLng(52, 1), + const LatLng(51, 0), + const LatLng(52, 1), ); - final expectedCenter = LatLng(51.50274289405741, 0.49999999999999833); + const expectedCenter = LatLng(51.50274289405741, 0.49999999999999833); await tester.pumpWidget(TestApp(controller: controller)); @@ -22,8 +22,8 @@ void main() { const fitOptions = FitBoundsOptions(); final expectedBounds = LatLngBounds( - LatLng(51.00145915187144, -0.3079873797085076), - LatLng(52.001427481787005, 1.298485398623206), + const LatLng(51.00145915187144, -0.3079873797085076), + const LatLng(52.001427481787005, 1.298485398623206), ); const expectedZoom = 7.451812751543818; @@ -47,8 +47,8 @@ void main() { ); final expectedBounds = LatLngBounds( - LatLng(50.819818262156545, -0.6042480468750001), - LatLng(52.1874047455997, 1.5930175781250002), + const LatLng(50.819818262156545, -0.6042480468750001), + const LatLng(52.1874047455997, 1.5930175781250002), ); const expectedZoom = 7; @@ -72,8 +72,8 @@ void main() { ); final expectedBounds = LatLngBounds( - LatLng(51.19148727133182, -6.195044477408375e-13), - LatLng(51.8139520195805, 0.999999999999397), + const LatLng(51.19148727133182, -6.195044477408375e-13), + const LatLng(51.8139520195805, 0.999999999999397), ); const expectedZoom = 8.135709286104404; @@ -99,8 +99,8 @@ void main() { ); final expectedBounds = LatLngBounds( - LatLng(51.33232774035881, 0.22521972656250003), - LatLng(51.67425842259517, 0.7745361328125), + const LatLng(51.33232774035881, 0.22521972656250003), + const LatLng(51.67425842259517, 0.7745361328125), ); const expectedZoom = 9; diff --git a/test/flutter_map_test.dart b/test/flutter_map_test.dart index 0028589f9..3f2884cfd 100644 --- a/test/flutter_map_test.dart +++ b/test/flutter_map_test.dart @@ -14,13 +14,13 @@ void main() { Marker( width: 80, height: 80, - point: LatLng(45.5231, -122.6765), + point: const LatLng(45.5231, -122.6765), builder: (_) => const FlutterLogo(), ), Marker( width: 80, height: 80, - point: LatLng(40, -120), // not visible + point: const LatLng(40, -120), // not visible builder: (_) => const FlutterLogo(), ), ]; @@ -40,7 +40,7 @@ void main() { final map = FlutterMap( options: MapOptions( - center: LatLng(45.5231, -122.6765), + center: const LatLng(45.5231, -122.6765), zoom: 13, ), children: [ diff --git a/test/geo/latlng_bounds_test.dart b/test/geo/latlng_bounds_test.dart index a4243d96d..ca5fc327b 100644 --- a/test/geo/latlng_bounds_test.dart +++ b/test/geo/latlng_bounds_test.dart @@ -4,9 +4,9 @@ import 'package:latlong2/latlong.dart'; void main() { group('LatLngBounds', () { - final london = LatLng(51.5, -0.09); - final paris = LatLng(48.8566, 2.3522); - final dublin = LatLng(53.3498, -6.2603); + const london = LatLng(51.5, -0.09); + const paris = LatLng(48.8566, 2.3522); + const dublin = LatLng(53.3498, -6.2603); group('LatLngBounds constructor', () { test('with dublin, paris', () { diff --git a/test/layer/circle_layer_test.dart b/test/layer/circle_layer_test.dart index 3eb06096b..e69ba0906 100644 --- a/test/layer/circle_layer_test.dart +++ b/test/layer/circle_layer_test.dart @@ -15,7 +15,7 @@ void main() { final circles = [ CircleMarker( key: key, - point: LatLng(51.5, -0.09), + point: const LatLng(51.5, -0.09), color: Colors.blue.withOpacity(0.7), borderStrokeWidth: 2, useRadiusInMeter: true, diff --git a/test/layer/marker_layer_test.dart b/test/layer/marker_layer_test.dart index e01dc1f01..db0fb1eef 100644 --- a/test/layer/marker_layer_test.dart +++ b/test/layer/marker_layer_test.dart @@ -17,7 +17,7 @@ void main() { key: key, width: 80, height: 80, - point: LatLng(45.5231, -122.6765), + point: const LatLng(45.5231, -122.6765), builder: (_) => const FlutterLogo(), ), ]; diff --git a/test/layer/polygon_layer_test.dart b/test/layer/polygon_layer_test.dart index b20459901..ef5e46c78 100644 --- a/test/layer/polygon_layer_test.dart +++ b/test/layer/polygon_layer_test.dart @@ -19,9 +19,9 @@ void main() { borderStrokeWidth: 4, label: '$i', points: [ - LatLng(55.5, -0.09), - LatLng(54.3498, -6.2603), - LatLng(52.8566, 2.3522), + const LatLng(55.5, -0.09), + const LatLng(54.3498, -6.2603), + const LatLng(52.8566, 2.3522), ], ), ]; diff --git a/test/layer/tile_layer/tile_bounds/tile_bounds_test.dart b/test/layer/tile_layer/tile_bounds/tile_bounds_test.dart index 7ae33bae8..91db2ef29 100644 --- a/test/layer/tile_layer/tile_bounds/tile_bounds_test.dart +++ b/test/layer/tile_layer/tile_bounds/tile_bounds_test.dart @@ -24,7 +24,7 @@ void main() { crs: FakeInfiniteCrs(), tileSize: 256, latLngBounds: LatLngBounds.fromPoints( - [LatLng(-44, -55), LatLng(44, 55)], + [const LatLng(-44, -55), const LatLng(44, 55)], ), ); @@ -90,7 +90,7 @@ void main() { crs: crs, tileSize: 256, latLngBounds: LatLngBounds( - LatLng(0, 0), + const LatLng(0, 0), crs.pointToLatLng(crs.getProjectedBounds(0)!.max, 0)!, ), ); diff --git a/test/test_utils/test_app.dart b/test/test_utils/test_app.dart index df2b842c5..5945ff855 100644 --- a/test/test_utils/test_app.dart +++ b/test/test_utils/test_app.dart @@ -30,7 +30,7 @@ class TestApp extends StatelessWidget { child: FlutterMap( mapController: controller, options: MapOptions( - center: LatLng(45.5231, -122.6765), + center: const LatLng(45.5231, -122.6765), zoom: 13, ), children: [