From 10245f6d6e09811bc13d205d68341fc5f171e5ed Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 25 Jul 2022 20:31:45 +0200 Subject: [PATCH 1/9] chore: strong-mode is deprecated --- analysis_options.yaml | 9 +++++---- lib/src/geo/crs/crs.dart | 3 ++- lib/src/layer/marker_layer.dart | 9 +++++---- lib/src/layer/tile_layer/tile.dart | 4 +--- lib/src/layer/tile_layer/tile_layer.dart | 4 ++-- .../tile_provider/network_no_retry_image_provider.dart | 1 - 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 1740187e9..e7a5a419c 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,9 +1,10 @@ include: package:flutter_lints/flutter.yaml analyzer: - strong-mode: - implicit-casts: false - implicit-dynamic: false + language: + strict-casts: true + strict-inference: true + strict-raw-types: true errors: close_sinks: ignore missing_required_param: error @@ -17,4 +18,4 @@ linter: always_use_package_imports: true type_annotate_public_apis: true prefer_int_literals: true - use_named_constants: true \ No newline at end of file + use_named_constants: true diff --git a/lib/src/geo/crs/crs.dart b/lib/src/geo/crs/crs.dart index e7f8a7b3a..01ebf3df5 100644 --- a/lib/src/geo/crs/crs.dart +++ b/lib/src/geo/crs/crs.dart @@ -350,7 +350,8 @@ abstract class Projection { LatLng unproject(CustomPoint point); - double _inclusive(Comparable start, Comparable end, double value) { + double _inclusive( + Comparable start, Comparable end, double value) { if (value.compareTo(start as num) < 0) return start as double; if (value.compareTo(end as num) > 0) return end as double; diff --git a/lib/src/layer/marker_layer.dart b/lib/src/layer/marker_layer.dart index 1a258c2e8..02d45e43b 100644 --- a/lib/src/layer/marker_layer.dart +++ b/lib/src/layer/marker_layer.dart @@ -85,7 +85,7 @@ class Anchor { } } - factory Anchor.forPos(AnchorPos? pos, double width, double height) { + 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 as AnchorAlign); @@ -98,8 +98,9 @@ class Anchor { class AnchorPos { AnchorPos._(this.value); T value; - static AnchorPos exactly(Anchor anchor) => AnchorPos._(anchor); - static AnchorPos align(AnchorAlign alignOpt) => + static AnchorPos exactly(Anchor anchor) => + AnchorPos._(anchor); + static AnchorPos align(AnchorAlign alignOpt) => AnchorPos._(alignOpt); } @@ -161,7 +162,7 @@ class Marker { this.rotate, this.rotateOrigin, this.rotateAlignment, - AnchorPos? anchorPos, + AnchorPos? anchorPos, }) : anchor = Anchor.forPos(anchorPos, width, height); } diff --git a/lib/src/layer/tile_layer/tile.dart b/lib/src/layer/tile_layer/tile.dart index 9fb54c5f6..4cf99afce 100644 --- a/lib/src/layer/tile_layer/tile.dart +++ b/lib/src/layer/tile_layer/tile.dart @@ -63,9 +63,7 @@ class Tile { void dispose([bool evict = false]) { if (evict) { try { - // ignore: return_type_invalid_for_catch_error - // ignore: implicit_dynamic_parameter - imageProvider.evict().catchError((e) { + imageProvider.evict().catchError((Object e) { debugPrint(e.toString()); }); } catch (e) { diff --git a/lib/src/layer/tile_layer/tile_layer.dart b/lib/src/layer/tile_layer/tile_layer.dart index 1d442759e..c416e2ef4 100644 --- a/lib/src/layer/tile_layer/tile_layer.dart +++ b/lib/src/layer/tile_layer/tile_layer.dart @@ -59,8 +59,8 @@ class _TileLayerState extends State with TickerProviderStateMixin { Tuple2? _wrapY; double? _tileZoom; - StreamSubscription? _moveSub; - StreamSubscription? _resetSub; + StreamSubscription? _moveSub; + StreamSubscription? _resetSub; StreamController? _throttleUpdate; late CustomPoint _tileSize; diff --git a/lib/src/layer/tile_layer/tile_provider/network_no_retry_image_provider.dart b/lib/src/layer/tile_layer/tile_provider/network_no_retry_image_provider.dart index 61a98d6d5..4d47f601c 100644 --- a/lib/src/layer/tile_layer/tile_provider/network_no_retry_image_provider.dart +++ b/lib/src/layer/tile_layer/tile_provider/network_no_retry_image_provider.dart @@ -29,7 +29,6 @@ class FMNetworkNoRetryImageProvider FMNetworkNoRetryImageProvider key, DecoderCallback decode, ) { - //ignore: close_sinks final StreamController chunkEvents = StreamController(); From 719d5f67b0f461065542427aa8fa4abd323a35bc Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 25 Jul 2022 20:32:49 +0200 Subject: [PATCH 2/9] fix: Exception on flutter_map_test --- test/flutter_map_test.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/flutter_map_test.dart b/test/flutter_map_test.dart index b70f1d8be..4ffd8158b 100644 --- a/test/flutter_map_test.dart +++ b/test/flutter_map_test.dart @@ -34,7 +34,12 @@ class MockHttpClientResponse extends Mock implements HttpClientResponse { static Stream> readFile() => File('test/res/map.png').openRead(); } +class MockHttpHeaders extends Mock implements HttpHeaders {} + class MockHttpClientRequest extends Mock implements HttpClientRequest { + @override + HttpHeaders get headers => MockHttpHeaders(); + @override Future close() => Future.value(MockHttpClientResponse()); } From 6edd0249362bb3cfc36321e40797c2ed9f900f64 Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 25 Jul 2022 22:12:51 +0200 Subject: [PATCH 3/9] chore: Example has the same rules as the package --- example/analysis_options.yaml | 18 ++++++ example/lib/main.dart | 62 +++++++++---------- .../lib/pages/animated_map_controller.dart | 47 +++++++------- example/lib/pages/circle.dart | 11 ++-- example/lib/pages/custom_crs/custom_crs.dart | 19 +++--- example/lib/pages/epsg3413_crs.dart | 15 +++-- example/lib/pages/epsg4326_crs.dart | 9 ++- example/lib/pages/esri.dart | 9 ++- example/lib/pages/home.dart | 23 ++++--- example/lib/pages/interactive_test_page.dart | 9 ++- example/lib/pages/live_location.dart | 19 +++--- example/lib/pages/many_markers.dart | 9 ++- example/lib/pages/map_controller.dart | 51 ++++++++------- example/lib/pages/map_inside_listview.dart | 9 ++- example/lib/pages/marker_anchor.dart | 29 +++++---- example/lib/pages/marker_rotate.dart | 25 ++++---- example/lib/pages/max_bounds.dart | 13 ++-- example/lib/pages/moving_markers.dart | 21 +++---- example/lib/pages/network_tile_provider.dart | 23 ++++--- example/lib/pages/offline_map.dart | 15 +++-- example/lib/pages/on_tap.dart | 27 ++++---- example/lib/pages/overlay_image.dart | 11 ++-- example/lib/pages/plugin_api.dart | 11 ++-- example/lib/pages/plugin_scalebar.dart | 9 ++- example/lib/pages/plugin_zoombuttons.dart | 9 ++- example/lib/pages/point_to_latlng.dart | 15 +++-- example/lib/pages/polygon.dart | 25 ++++---- example/lib/pages/polyline.dart | 23 ++++--- example/lib/pages/reset_tile_layer.dart | 17 +++-- .../lib/pages/scale_layer_plugin_option.dart | 32 +++++----- example/lib/pages/scalebar_utils.dart | 60 +++++++++--------- example/lib/pages/sliding_map.dart | 15 +++-- example/lib/pages/stateful_markers.dart | 15 +++-- example/lib/pages/tap_to_add.dart | 15 +++-- example/lib/pages/tile_builder_example.dart | 19 +++--- .../lib/pages/tile_loading_error_handle.dart | 9 ++- example/lib/pages/widgets.dart | 21 +++---- example/lib/pages/wms_tile_layer.dart | 9 ++- .../lib/pages/zoombuttons_plugin_option.dart | 10 +-- example/lib/test_app.dart | 2 +- example/lib/widgets/drawer.dart | 62 +++++++++---------- example/pubspec.yaml | 2 +- 42 files changed, 419 insertions(+), 435 deletions(-) diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml index 9fc02fcf5..445cfcc7a 100644 --- a/example/analysis_options.yaml +++ b/example/analysis_options.yaml @@ -1,4 +1,22 @@ include: package:flutter_lints/flutter.yaml + +analyzer: + language: + strict-casts: true + strict-inference: true + strict-raw-types: true + errors: + close_sinks: ignore + missing_required_param: error + missing_return: error + linter: rules: library_private_types_in_public_api: false + prefer_final_locals: true + prefer_final_in_for_each: true + avoid_dynamic_calls: true + always_use_package_imports: true + type_annotate_public_apis: true + prefer_int_literals: true + use_named_constants: true diff --git a/example/lib/main.dart b/example/lib/main.dart index 5e874f338..dd3c6e1c0 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,39 +1,39 @@ import 'package:flutter/material.dart'; + +import 'package:flutter_map_example/pages/animated_map_controller.dart'; +import 'package:flutter_map_example/pages/circle.dart'; +import 'package:flutter_map_example/pages/custom_crs/custom_crs.dart'; +import 'package:flutter_map_example/pages/epsg3413_crs.dart'; import 'package:flutter_map_example/pages/epsg4326_crs.dart'; +import 'package:flutter_map_example/pages/esri.dart'; +import 'package:flutter_map_example/pages/home.dart'; +import 'package:flutter_map_example/pages/interactive_test_page.dart'; +import 'package:flutter_map_example/pages/live_location.dart'; +import 'package:flutter_map_example/pages/many_markers.dart'; +import 'package:flutter_map_example/pages/map_controller.dart'; import 'package:flutter_map_example/pages/map_inside_listview.dart'; +import 'package:flutter_map_example/pages/marker_anchor.dart'; +import 'package:flutter_map_example/pages/marker_rotate.dart'; +import 'package:flutter_map_example/pages/max_bounds.dart'; +import 'package:flutter_map_example/pages/moving_markers.dart'; import 'package:flutter_map_example/pages/network_tile_provider.dart'; +import 'package:flutter_map_example/pages/offline_map.dart'; +import 'package:flutter_map_example/pages/on_tap.dart'; +import 'package:flutter_map_example/pages/overlay_image.dart'; +import 'package:flutter_map_example/pages/plugin_api.dart'; +import 'package:flutter_map_example/pages/plugin_scalebar.dart'; +import 'package:flutter_map_example/pages/plugin_zoombuttons.dart'; import 'package:flutter_map_example/pages/point_to_latlng.dart'; - -import './pages/animated_map_controller.dart'; -import './pages/circle.dart'; -import './pages/custom_crs/custom_crs.dart'; -import './pages/esri.dart'; -import './pages/home.dart'; -import './pages/interactive_test_page.dart'; -import './pages/live_location.dart'; -import './pages/many_markers.dart'; -import './pages/map_controller.dart'; -import './pages/marker_anchor.dart'; -import './pages/marker_rotate.dart'; -import './pages/max_bounds.dart'; -import './pages/moving_markers.dart'; -import './pages/offline_map.dart'; -import './pages/on_tap.dart'; -import './pages/overlay_image.dart'; -import './pages/plugin_api.dart'; -import './pages/plugin_scalebar.dart'; -import './pages/plugin_zoombuttons.dart'; -import './pages/polygon.dart'; -import './pages/polyline.dart'; -import './pages/reset_tile_layer.dart'; -import './pages/sliding_map.dart'; -import './pages/stateful_markers.dart'; -import './pages/tap_to_add.dart'; -import './pages/tile_builder_example.dart'; -import './pages/tile_loading_error_handle.dart'; -import './pages/widgets.dart'; -import './pages/wms_tile_layer.dart'; -import './pages/epsg3413_crs.dart'; +import 'package:flutter_map_example/pages/polygon.dart'; +import 'package:flutter_map_example/pages/polyline.dart'; +import 'package:flutter_map_example/pages/reset_tile_layer.dart'; +import 'package:flutter_map_example/pages/sliding_map.dart'; +import 'package:flutter_map_example/pages/stateful_markers.dart'; +import 'package:flutter_map_example/pages/tap_to_add.dart'; +import 'package:flutter_map_example/pages/tile_builder_example.dart'; +import 'package:flutter_map_example/pages/tile_loading_error_handle.dart'; +import 'package:flutter_map_example/pages/widgets.dart'; +import 'package:flutter_map_example/pages/wms_tile_layer.dart'; void main() => runApp(const MyApp()); diff --git a/example/lib/pages/animated_map_controller.dart b/example/lib/pages/animated_map_controller.dart index fbc0ab7f2..1c661f193 100644 --- a/example/lib/pages/animated_map_controller.dart +++ b/example/lib/pages/animated_map_controller.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; -import '../widgets/drawer.dart'; - class AnimatedMapControllerPage extends StatefulWidget { static const String route = 'map_controller_animated'; @@ -49,11 +48,11 @@ class AnimatedMapControllerPageState extends State final zoomTween = Tween(begin: mapController.zoom, end: destZoom); // Create a animation controller that has a duration and a TickerProvider. - var controller = AnimationController( + final controller = AnimationController( duration: const Duration(milliseconds: 500), vsync: this); // The animation determines what path the animation will take. You can try different Curves values, although I found // fastOutSlowIn to be my favorite. - Animation animation = + final Animation animation = CurvedAnimation(parent: controller, curve: Curves.fastOutSlowIn); controller.addListener(() { @@ -75,10 +74,10 @@ class AnimatedMapControllerPageState extends State @override Widget build(BuildContext context) { - var markers = [ + final markers = [ Marker( - width: 80.0, - height: 80.0, + width: 80, + height: 80, point: london, builder: (ctx) => Container( key: const Key('blue'), @@ -86,8 +85,8 @@ class AnimatedMapControllerPageState extends State ), ), Marker( - width: 80.0, - height: 80.0, + width: 80, + height: 80, point: dublin, builder: (ctx) => const FlutterLogo( key: Key('green'), @@ -95,8 +94,8 @@ class AnimatedMapControllerPageState extends State ), ), Marker( - width: 80.0, - height: 80.0, + width: 80, + height: 80, point: paris, builder: (ctx) => Container( key: const Key('purple'), @@ -109,28 +108,28 @@ class AnimatedMapControllerPageState extends State appBar: AppBar(title: const Text('Animated MapController')), drawer: buildDrawer(context, AnimatedMapControllerPage.route), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Column( children: [ Padding( - padding: const EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: const EdgeInsets.only(top: 8, bottom: 8), child: Row( children: [ MaterialButton( onPressed: () { - _animatedMapMove(london, 10.0); + _animatedMapMove(london, 10); }, child: const Text('London'), ), MaterialButton( onPressed: () { - _animatedMapMove(paris, 5.0); + _animatedMapMove(paris, 5); }, child: const Text('Paris'), ), MaterialButton( onPressed: () { - _animatedMapMove(dublin, 5.0); + _animatedMapMove(dublin, 5); }, child: const Text('Dublin'), ), @@ -138,19 +137,19 @@ class AnimatedMapControllerPageState extends State ), ), Padding( - padding: const EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: const EdgeInsets.only(top: 8, bottom: 8), child: Row( children: [ MaterialButton( onPressed: () { - var bounds = LatLngBounds(); + final bounds = LatLngBounds(); bounds.extend(dublin); bounds.extend(paris); bounds.extend(london); mapController.fitBounds( bounds, options: const FitBoundsOptions( - padding: EdgeInsets.only(left: 15.0, right: 15.0), + padding: EdgeInsets.only(left: 15, right: 15), ), ); }, @@ -158,12 +157,12 @@ class AnimatedMapControllerPageState extends State ), MaterialButton( onPressed: () { - var bounds = LatLngBounds(); + final bounds = LatLngBounds(); bounds.extend(dublin); bounds.extend(paris); bounds.extend(london); - var centerZoom = + final centerZoom = mapController.centerZoomFitBounds(bounds); _animatedMapMove(centerZoom.center, centerZoom.zoom); }, @@ -177,9 +176,9 @@ class AnimatedMapControllerPageState extends State mapController: mapController, options: MapOptions( center: LatLng(51.5, -0.09), - zoom: 5.0, - maxZoom: 10.0, - minZoom: 3.0), + zoom: 5, + maxZoom: 10, + minZoom: 3), layers: [ TileLayerOptions( urlTemplate: diff --git a/example/lib/pages/circle.dart b/example/lib/pages/circle.dart index 90fdcd835..9b40c8fcf 100644 --- a/example/lib/pages/circle.dart +++ b/example/lib/pages/circle.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; -import '../widgets/drawer.dart'; - class CirclePage extends StatelessWidget { static const String route = 'circle'; @@ -11,7 +10,7 @@ class CirclePage extends StatelessWidget { @override Widget build(BuildContext context) { - var circleMarkers = [ + final circleMarkers = [ CircleMarker( point: LatLng(51.5, -0.09), color: Colors.blue.withOpacity(0.7), @@ -25,18 +24,18 @@ class CirclePage extends StatelessWidget { appBar: AppBar(title: const Text('Circle')), drawer: buildDrawer(context, route), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Column( children: [ const Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: EdgeInsets.only(top: 8, bottom: 8), child: Text('This is a map that is showing (51.5, -0.9).'), ), Flexible( child: FlutterMap( options: MapOptions( center: LatLng(51.5, -0.09), - zoom: 11.0, + zoom: 11, ), layers: [ TileLayerOptions( diff --git a/example/lib/pages/custom_crs/custom_crs.dart b/example/lib/pages/custom_crs/custom_crs.dart index 165a292f9..ade2ec8fa 100644 --- a/example/lib/pages/custom_crs/custom_crs.dart +++ b/example/lib/pages/custom_crs/custom_crs.dart @@ -1,10 +1,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/plugin_api.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; import 'package:proj4dart/proj4dart.dart' as proj4; -import '../../widgets/drawer.dart'; - class CustomCrsPage extends StatefulWidget { static const String route = 'custom_crs'; @@ -93,34 +92,34 @@ class _CustomCrsPageState extends State { appBar: AppBar(title: const Text('Custom CRS')), drawer: buildDrawer(context, CustomCrsPage.route), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Column( children: [ const Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 2.0), + padding: EdgeInsets.only(top: 8, bottom: 2), child: Text( 'This map is in EPSG:3413', style: TextStyle( fontWeight: FontWeight.bold, color: Colors.blue, - fontSize: 16.0, + fontSize: 16, ), ), ), Padding( - padding: const EdgeInsets.only(top: 8.0, bottom: 2.0), + padding: const EdgeInsets.only(top: 8, bottom: 2), child: Text( '$initText (${point.x.toStringAsFixed(5)}, ${point.y.toStringAsFixed(5)}) in EPSG:4326.', ), ), Padding( - padding: const EdgeInsets.only(top: 2.0, bottom: 2.0), + padding: const EdgeInsets.only(top: 2, bottom: 2), child: Text( 'Which is (${epsg4326.transform(epsg3413, point).x.toStringAsFixed(2)}, ${epsg4326.transform(epsg3413, point).y.toStringAsFixed(2)}) in EPSG:3413.', ), ), const Padding( - padding: EdgeInsets.only(top: 2.0, bottom: 8.0), + padding: EdgeInsets.only(top: 2, bottom: 8), child: Text('Tap on map to get more coordinates!'), ), Flexible( @@ -129,7 +128,7 @@ class _CustomCrsPageState extends State { // Set the default CRS crs: epsg3413CRS, center: LatLng(point.x, point.y), - zoom: 3.0, + zoom: 3, // Set maxZoom usually scales.length - 1 OR resolutions.length - 1 // but not greater maxZoom: maxZoom, @@ -140,7 +139,7 @@ class _CustomCrsPageState extends State { ), layers: [ TileLayerOptions( - opacity: 1.0, + opacity: 1, backgroundColor: Colors.transparent, wmsOptions: WMSTileLayerOptions( // Set the WMS layer's CRS diff --git a/example/lib/pages/epsg3413_crs.dart b/example/lib/pages/epsg3413_crs.dart index e12d4f534..14718d9ce 100644 --- a/example/lib/pages/epsg3413_crs.dart +++ b/example/lib/pages/epsg3413_crs.dart @@ -1,10 +1,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/plugin_api.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; import 'package:proj4dart/proj4dart.dart' as proj4; -import '../../widgets/drawer.dart'; - class EPSG3413Page extends StatefulWidget { static const String route = 'EPSG3413 Page'; @@ -90,31 +89,31 @@ class _EPSG3413PageState extends State { useRadiusInMeter: true, color: Colors.transparent, borderColor: Colors.black, - borderStrokeWidth: 1.0, + borderStrokeWidth: 1, )); return Scaffold( appBar: AppBar(title: const Text('EPSG:3413 CRS')), drawer: buildDrawer(context, EPSG3413Page.route), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Column( children: [ const Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 2.0), + padding: EdgeInsets.only(top: 8, bottom: 2), child: Text( 'Tricky edge-cases with polar projections', style: TextStyle( fontWeight: FontWeight.bold, color: Colors.blue, - fontSize: 16.0, + fontSize: 16, ), ), ), const Text( 'Details: https://github.com/fleaflet/flutter_map/pull/1295'), const Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 2.0), + padding: EdgeInsets.only(top: 8, bottom: 2), child: SizedBox( width: 500, child: Text( @@ -131,7 +130,7 @@ class _EPSG3413PageState extends State { options: MapOptions( crs: epsg3413CRS, center: LatLng(90, 0), - zoom: 3.0, + zoom: 3, maxZoom: maxZoom, ), layers: [ diff --git a/example/lib/pages/epsg4326_crs.dart b/example/lib/pages/epsg4326_crs.dart index 8ad4cbd0f..0f4d3103c 100644 --- a/example/lib/pages/epsg4326_crs.dart +++ b/example/lib/pages/epsg4326_crs.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; -import '../widgets/drawer.dart'; - class EPSG4326Page extends StatelessWidget { static const String route = 'EPSG4326 Page'; @@ -15,11 +14,11 @@ class EPSG4326Page extends StatelessWidget { appBar: AppBar(title: const Text('EPSG4326')), drawer: buildDrawer(context, route), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Column( children: [ const Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: EdgeInsets.only(top: 8, bottom: 8), child: Text('This is a map that is showing (42.58, 12.43).'), ), Flexible( @@ -28,7 +27,7 @@ class EPSG4326Page extends StatelessWidget { minZoom: 0, crs: const Epsg4326(), center: LatLng(0, 0), - zoom: 0.0, + zoom: 0, ), layers: [ TileLayerOptions( diff --git a/example/lib/pages/esri.dart b/example/lib/pages/esri.dart index d1130d83c..417dff46f 100644 --- a/example/lib/pages/esri.dart +++ b/example/lib/pages/esri.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; -import '../widgets/drawer.dart'; - class EsriPage extends StatelessWidget { static const String route = 'esri'; @@ -15,18 +14,18 @@ class EsriPage extends StatelessWidget { appBar: AppBar(title: const Text('Esri')), drawer: buildDrawer(context, route), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Column( children: [ const Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: EdgeInsets.only(top: 8, bottom: 8), child: Text('Esri'), ), Flexible( child: FlutterMap( options: MapOptions( center: LatLng(45.5231, -122.6765), - zoom: 13.0, + zoom: 13, ), layers: [ TileLayerOptions( diff --git a/example/lib/pages/home.dart b/example/lib/pages/home.dart index 5c949d19b..f12ef4e49 100644 --- a/example/lib/pages/home.dart +++ b/example/lib/pages/home.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; -import '../widgets/drawer.dart'; - class HomePage extends StatelessWidget { static const String route = '/'; @@ -11,10 +10,10 @@ class HomePage extends StatelessWidget { @override Widget build(BuildContext context) { - var markers = [ + final markers = [ Marker( - width: 80.0, - height: 80.0, + width: 80, + height: 80, point: LatLng(51.5, -0.09), builder: (ctx) => const FlutterLogo( textColor: Colors.blue, @@ -22,8 +21,8 @@ class HomePage extends StatelessWidget { ), ), Marker( - width: 80.0, - height: 80.0, + width: 80, + height: 80, point: LatLng(53.3498, -6.2603), builder: (ctx) => const FlutterLogo( textColor: Colors.green, @@ -31,8 +30,8 @@ class HomePage extends StatelessWidget { ), ), Marker( - width: 80.0, - height: 80.0, + width: 80, + height: 80, point: LatLng(48.8566, 2.3522), builder: (ctx) => const FlutterLogo( textColor: Colors.purple, @@ -45,18 +44,18 @@ class HomePage extends StatelessWidget { appBar: AppBar(title: const Text('Home')), drawer: buildDrawer(context, route), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Column( children: [ const Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: EdgeInsets.only(top: 8, bottom: 8), child: Text('This is a map that is showing (51.5, -0.9).'), ), Flexible( child: FlutterMap( options: MapOptions( center: LatLng(51.5, -0.09), - zoom: 5.0, + zoom: 5, ), layers: [ TileLayerOptions( diff --git a/example/lib/pages/interactive_test_page.dart b/example/lib/pages/interactive_test_page.dart index e0a43cfa4..f04ad46db 100644 --- a/example/lib/pages/interactive_test_page.dart +++ b/example/lib/pages/interactive_test_page.dart @@ -2,10 +2,9 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; -import '../widgets/drawer.dart'; - class InteractiveTestPage extends StatefulWidget { static const String route = 'interactive_test_page'; @@ -63,7 +62,7 @@ class _InteractiveTestPageState extends State { appBar: AppBar(title: const Text('Test out Interactive flags!')), drawer: buildDrawer(context, InteractiveTestPage.route), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Column( children: [ Row( @@ -147,7 +146,7 @@ class _InteractiveTestPageState extends State { ], ), Padding( - padding: const EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: const EdgeInsets.only(top: 8, bottom: 8), child: Center( child: StreamBuilder( stream: mapController.mapEventStream, @@ -173,7 +172,7 @@ class _InteractiveTestPageState extends State { mapController: mapController, options: MapOptions( center: LatLng(51.5, -0.09), - zoom: 11.0, + zoom: 11, interactiveFlags: flags, ), layers: [ diff --git a/example/lib/pages/live_location.dart b/example/lib/pages/live_location.dart index 1f32e4095..ecc77089f 100644 --- a/example/lib/pages/live_location.dart +++ b/example/lib/pages/live_location.dart @@ -1,11 +1,10 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; import 'package:location/location.dart'; -import '../widgets/drawer.dart'; - class LiveLocationPage extends StatefulWidget { static const String route = '/live_location'; @@ -24,7 +23,7 @@ class _LiveLocationPageState extends State { String? _serviceError = ''; - var interActiveFlags = InteractiveFlag.all; + int interActiveFlags = InteractiveFlag.all; final Location _locationService = Location(); @@ -49,7 +48,7 @@ class _LiveLocationPageState extends State { serviceEnabled = await _locationService.serviceEnabled(); if (serviceEnabled) { - var permission = await _locationService.requestPermission(); + final permission = await _locationService.requestPermission(); _permission = permission == PermissionStatus.granted; if (_permission) { @@ -103,10 +102,10 @@ class _LiveLocationPageState extends State { currentLatLng = LatLng(0, 0); } - var markers = [ + final markers = [ Marker( - width: 80.0, - height: 80.0, + width: 80, + height: 80, point: currentLatLng, builder: (ctx) => const FlutterLogo( textColor: Colors.blue, @@ -119,11 +118,11 @@ class _LiveLocationPageState extends State { appBar: AppBar(title: const Text('Home')), drawer: buildDrawer(context, LiveLocationPage.route), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Column( children: [ Padding( - padding: const EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: const EdgeInsets.only(top: 8, bottom: 8), child: _serviceError!.isEmpty ? Text('This is a map that is showing ' '(${currentLatLng.latitude}, ${currentLatLng.longitude}).') @@ -137,7 +136,7 @@ class _LiveLocationPageState extends State { options: MapOptions( center: LatLng(currentLatLng.latitude, currentLatLng.longitude), - zoom: 5.0, + zoom: 5, interactiveFlags: interActiveFlags, ), layers: [ diff --git a/example/lib/pages/many_markers.dart b/example/lib/pages/many_markers.dart index 163fa398d..8a39e45c2 100644 --- a/example/lib/pages/many_markers.dart +++ b/example/lib/pages/many_markers.dart @@ -2,10 +2,9 @@ import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; -import '../widgets/drawer.dart'; - const maxMarkersCount = 5000; /// On this page, [maxMarkersCount] markers are randomly generated @@ -32,7 +31,7 @@ class _ManyMarkersPageState extends State { void initState() { super.initState(); Future.microtask(() { - var r = Random(); + final r = Random(); for (var x = 0; x < maxMarkersCount; x++) { allMarkers.add( Marker( @@ -43,7 +42,7 @@ class _ManyMarkersPageState extends State { builder: (context) => const Icon( Icons.circle, color: Colors.red, - size: 12.0, + size: 12, ), ), ); @@ -75,7 +74,7 @@ class _ManyMarkersPageState extends State { child: FlutterMap( options: MapOptions( center: LatLng(50, 20), - zoom: 5.0, + zoom: 5, interactiveFlags: InteractiveFlag.all - InteractiveFlag.rotate, ), layers: [ diff --git a/example/lib/pages/map_controller.dart b/example/lib/pages/map_controller.dart index 072eba33a..98ac8c024 100644 --- a/example/lib/pages/map_controller.dart +++ b/example/lib/pages/map_controller.dart @@ -2,11 +2,10 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; import 'package:location/location.dart'; -import '../widgets/drawer.dart'; - class MapControllerPage extends StatefulWidget { static const String route = 'map_controller'; @@ -24,7 +23,7 @@ class MapControllerPageState extends State { static LatLng dublin = LatLng(53.3498, -6.2603); late final MapController mapController; - double rotation = 0.0; + double rotation = 0; @override void initState() { @@ -34,10 +33,10 @@ class MapControllerPageState extends State { @override Widget build(BuildContext context) { - var markers = [ + final markers = [ Marker( - width: 80.0, - height: 80.0, + width: 80, + height: 80, point: london, builder: (ctx) => Container( key: const Key('blue'), @@ -45,8 +44,8 @@ class MapControllerPageState extends State { ), ), Marker( - width: 80.0, - height: 80.0, + width: 80, + height: 80, point: dublin, builder: (ctx) => const FlutterLogo( key: Key('green'), @@ -54,8 +53,8 @@ class MapControllerPageState extends State { ), ), Marker( - width: 80.0, - height: 80.0, + width: 80, + height: 80, point: paris, builder: (ctx) => Container( key: const Key('purple'), @@ -68,28 +67,28 @@ class MapControllerPageState extends State { appBar: AppBar(title: const Text('MapController')), drawer: buildDrawer(context, MapControllerPage.route), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Column( children: [ Padding( - padding: const EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: const EdgeInsets.only(top: 8, bottom: 8), child: Row( children: [ MaterialButton( onPressed: () { - mapController.move(london, 18.0); + mapController.move(london, 18); }, child: const Text('London'), ), MaterialButton( onPressed: () { - mapController.move(paris, 5.0); + mapController.move(paris, 5); }, child: const Text('Paris'), ), MaterialButton( onPressed: () { - mapController.move(dublin, 5.0); + mapController.move(dublin, 5); }, child: const Text('Dublin'), ), @@ -98,19 +97,19 @@ class MapControllerPageState extends State { ), ), Padding( - padding: const EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: const EdgeInsets.only(top: 8, bottom: 8), child: Row( children: [ MaterialButton( onPressed: () { - var bounds = LatLngBounds(); + final bounds = LatLngBounds(); bounds.extend(dublin); bounds.extend(paris); bounds.extend(london); mapController.fitBounds( bounds, options: const FitBoundsOptions( - padding: EdgeInsets.only(left: 15.0, right: 15.0), + padding: EdgeInsets.only(left: 15, right: 15), ), ); }, @@ -138,7 +137,7 @@ class MapControllerPageState extends State { Expanded( child: Slider( value: rotation, - min: 0.0, + min: 0, max: 360, onChanged: (degree) { setState(() { @@ -156,9 +155,9 @@ class MapControllerPageState extends State { mapController: mapController, options: MapOptions( center: LatLng(51.5, -0.09), - zoom: 5.0, - maxZoom: 5.0, - minZoom: 3.0, + zoom: 5, + maxZoom: 5, + minZoom: 3, ), layers: [ TileLayerOptions( @@ -193,7 +192,7 @@ class CurrentLocation extends StatefulWidget { class _CurrentLocationState extends State { int _eventKey = 0; - var icon = Icons.gps_not_fixed; + IconData icon = Icons.gps_not_fixed; late final StreamSubscription mapEventSubscription; @override @@ -226,11 +225,11 @@ class _CurrentLocationState extends State { void _moveToCurrent() async { _eventKey++; - var location = Location(); + final location = Location(); try { - var currentLocation = await location.getLocation(); - var moved = widget.mapController.move( + final currentLocation = await location.getLocation(); + final moved = widget.mapController.move( LatLng(currentLocation.latitude!, currentLocation.longitude!), 18, id: _eventKey.toString(), diff --git a/example/lib/pages/map_inside_listview.dart b/example/lib/pages/map_inside_listview.dart index f3b199032..e4b57527d 100644 --- a/example/lib/pages/map_inside_listview.dart +++ b/example/lib/pages/map_inside_listview.dart @@ -1,10 +1,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/plugin_api.dart'; +import 'package:flutter_map_example/pages/zoombuttons_plugin_option.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; -import '../pages/zoombuttons_plugin_option.dart'; -import '../widgets/drawer.dart'; - class MapInsideListViewPage extends StatelessWidget { static const String route = 'map_inside_listview'; @@ -16,7 +15,7 @@ class MapInsideListViewPage extends StatelessWidget { appBar: AppBar(title: const Text('Map inside ListView')), drawer: buildDrawer(context, MapInsideListViewPage.route), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: ListView( scrollDirection: Axis.vertical, children: [ @@ -25,7 +24,7 @@ class MapInsideListViewPage extends StatelessWidget { child: FlutterMap( options: MapOptions( center: LatLng(51.5, -0.09), - zoom: 5.0, + zoom: 5, plugins: [ ZoomButtonsPlugin(), ], diff --git a/example/lib/pages/marker_anchor.dart b/example/lib/pages/marker_anchor.dart index 4efee60b1..3017f1106 100644 --- a/example/lib/pages/marker_anchor.dart +++ b/example/lib/pages/marker_anchor.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; -import '../widgets/drawer.dart'; - class MarkerAnchorPage extends StatefulWidget { static const String route = '/marker_anchors'; @@ -16,7 +15,7 @@ class MarkerAnchorPage extends StatefulWidget { } class MarkerAnchorPageState extends State { - late AnchorPos anchorPos; + late AnchorPos anchorPos; @override void initState() { @@ -38,17 +37,17 @@ class MarkerAnchorPageState extends State { @override Widget build(BuildContext context) { - var markers = [ + final markers = [ Marker( - width: 80.0, - height: 80.0, + width: 80, + height: 80, point: LatLng(51.5, -0.09), builder: (ctx) => const FlutterLogo(), anchorPos: anchorPos, ), Marker( - width: 80.0, - height: 80.0, + width: 80, + height: 80, point: LatLng(53.3498, -6.2603), builder: (ctx) => const FlutterLogo( textColor: Colors.green, @@ -56,8 +55,8 @@ class MarkerAnchorPageState extends State { anchorPos: anchorPos, ), Marker( - width: 80.0, - height: 80.0, + width: 80, + height: 80, point: LatLng(48.8566, 2.3522), builder: (ctx) => const FlutterLogo(textColor: Colors.purple), anchorPos: anchorPos, @@ -68,16 +67,16 @@ class MarkerAnchorPageState extends State { appBar: AppBar(title: const Text('Marker Anchor Points')), drawer: buildDrawer(context, MarkerAnchorPage.route), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Column( children: [ const Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: EdgeInsets.only(top: 8, bottom: 8), child: Text( 'Markers can be anchored to the top, bottom, left or right.'), ), Padding( - padding: const EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: const EdgeInsets.only(top: 8, bottom: 8), child: Wrap( children: [ MaterialButton( @@ -101,7 +100,7 @@ class MarkerAnchorPageState extends State { child: const Text('Center'), ), MaterialButton( - onPressed: () => _setAnchorExactlyPos(Anchor(80.0, 80.0)), + onPressed: () => _setAnchorExactlyPos(Anchor(80, 80)), child: const Text('Custom'), ), ], @@ -111,7 +110,7 @@ class MarkerAnchorPageState extends State { child: FlutterMap( options: MapOptions( center: LatLng(51.5, -0.09), - zoom: 5.0, + zoom: 5, ), layers: [ TileLayerOptions( diff --git a/example/lib/pages/marker_rotate.dart b/example/lib/pages/marker_rotate.dart index 40911e8a1..1e5431b56 100644 --- a/example/lib/pages/marker_rotate.dart +++ b/example/lib/pages/marker_rotate.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; -import '../widgets/drawer.dart'; - class MarkerRotatePage extends StatefulWidget { static const String route = '/marker_rotate'; @@ -70,17 +69,17 @@ class MarkerRotatePageState extends State { @override Widget build(BuildContext context) { - var markers = [ + final markers = [ Marker( - width: 80.0, - height: 80.0, + width: 80, + height: 80, point: LatLng(51.5, -0.09), rotate: rotateMarkerLondon, builder: (ctx) => const FlutterLogo(), ), Marker( - width: 80.0, - height: 80.0, + width: 80, + height: 80, point: LatLng(53.3498, -6.2603), rotate: rotateMarkerDublin, builder: (ctx) => const FlutterLogo( @@ -88,8 +87,8 @@ class MarkerRotatePageState extends State { ), ), Marker( - width: 80.0, - height: 80.0, + width: 80, + height: 80, point: LatLng(48.8566, 2.3522), rotate: rotateMarkerParis, builder: (ctx) => const FlutterLogo(textColor: Colors.purple), @@ -100,16 +99,16 @@ class MarkerRotatePageState extends State { appBar: AppBar(title: const Text('Marker rotate by Map')), drawer: buildDrawer(context, MarkerRotatePage.route), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Column( children: [ const Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: EdgeInsets.only(top: 8, bottom: 8), child: Text('Markers can be counter rotated to the map rotation.'), ), Padding( - padding: const EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: const EdgeInsets.only(top: 8, bottom: 8), child: Wrap( children: [ MaterialButton( @@ -136,7 +135,7 @@ class MarkerRotatePageState extends State { child: FlutterMap( options: MapOptions( center: LatLng(51.5, -0.09), - zoom: 5.0, + zoom: 5, ), layers: [ TileLayerOptions( diff --git a/example/lib/pages/max_bounds.dart b/example/lib/pages/max_bounds.dart index 5b29256ed..0c0cb2778 100644 --- a/example/lib/pages/max_bounds.dart +++ b/example/lib/pages/max_bounds.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; -import '../widgets/drawer.dart'; - class MaxBoundsPage extends StatelessWidget { static const String route = '/max_bounds'; @@ -15,11 +14,11 @@ class MaxBoundsPage extends StatelessWidget { appBar: AppBar(title: const Text('Max Bounds edges check')), drawer: buildDrawer(context, route), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Column( children: [ const Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: EdgeInsets.only(top: 8, bottom: 8), child: Text( 'This is a map that has edges constrained to a latlng bounds.'), ), @@ -27,14 +26,14 @@ class MaxBoundsPage extends StatelessWidget { child: FlutterMap( options: MapOptions( center: LatLng(56.704173, 11.543808), - zoom: 3.0, + zoom: 3, maxBounds: - LatLngBounds(LatLng(-90, -180.0), LatLng(90.0, 180.0)), + LatLngBounds(LatLng(-90, -180), LatLng(90, 180)), screenSize: MediaQuery.of(context).size, ), layers: [ TileLayerOptions( - maxZoom: 15.0, + maxZoom: 15, urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', subdomains: ['a', 'b', 'c'], diff --git a/example/lib/pages/moving_markers.dart b/example/lib/pages/moving_markers.dart index 3313c363a..ecb7d6673 100644 --- a/example/lib/pages/moving_markers.dart +++ b/example/lib/pages/moving_markers.dart @@ -2,10 +2,9 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; -import '../widgets/drawer.dart'; - class MovingMarkersPage extends StatefulWidget { static const String route = '/moving_markers'; @@ -46,18 +45,18 @@ class _MovingMarkersPageState extends State { appBar: AppBar(title: const Text('Home')), drawer: buildDrawer(context, MovingMarkersPage.route), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Column( children: [ const Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: EdgeInsets.only(top: 8, bottom: 8), child: Text('This is a map that is showing (51.5, -0.9).'), ), Flexible( child: FlutterMap( options: MapOptions( center: LatLng(51.5, -0.09), - zoom: 5.0, + zoom: 5, ), layers: [ TileLayerOptions( @@ -79,20 +78,20 @@ class _MovingMarkersPageState extends State { List _markers = [ Marker( - width: 80.0, - height: 80.0, + width: 80, + height: 80, point: LatLng(51.5, -0.09), builder: (ctx) => const FlutterLogo(), ), Marker( - width: 80.0, - height: 80.0, + width: 80, + height: 80, point: LatLng(53.3498, -6.2603), builder: (ctx) => const FlutterLogo(), ), Marker( - width: 80.0, - height: 80.0, + width: 80, + height: 80, point: 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 cd26ea582..3f957dc7b 100644 --- a/example/lib/pages/network_tile_provider.dart +++ b/example/lib/pages/network_tile_provider.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; -import '../widgets/drawer.dart'; - class NetworkTileProviderPage extends StatelessWidget { static const String route = 'NetworkTileProvider'; @@ -11,10 +10,10 @@ class NetworkTileProviderPage extends StatelessWidget { @override Widget build(BuildContext context) { - var markers = [ + final markers = [ Marker( - width: 80.0, - height: 80.0, + width: 80, + height: 80, point: LatLng(51.5, -0.09), builder: (ctx) => const FlutterLogo( textColor: Colors.blue, @@ -22,8 +21,8 @@ class NetworkTileProviderPage extends StatelessWidget { ), ), Marker( - width: 80.0, - height: 80.0, + width: 80, + height: 80, point: LatLng(53.3498, -6.2603), builder: (ctx) => const FlutterLogo( textColor: Colors.green, @@ -31,8 +30,8 @@ class NetworkTileProviderPage extends StatelessWidget { ), ), Marker( - width: 80.0, - height: 80.0, + width: 80, + height: 80, point: LatLng(48.8566, 2.3522), builder: (ctx) => const FlutterLogo( textColor: Colors.purple, @@ -45,11 +44,11 @@ class NetworkTileProviderPage extends StatelessWidget { appBar: AppBar(title: const Text('NetworkTileProvider')), drawer: buildDrawer(context, route), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Column( children: [ Padding( - padding: const EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: const EdgeInsets.only(top: 8, bottom: 8), child: Wrap( children: const [ Text( @@ -63,7 +62,7 @@ class NetworkTileProviderPage extends StatelessWidget { child: FlutterMap( options: MapOptions( center: LatLng(51.5, -0.09), - zoom: 5.0, + zoom: 5, ), layers: [ TileLayerOptions( diff --git a/example/lib/pages/offline_map.dart b/example/lib/pages/offline_map.dart index 510131e43..cef4ca252 100644 --- a/example/lib/pages/offline_map.dart +++ b/example/lib/pages/offline_map.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; -import '../widgets/drawer.dart'; - class OfflineMapPage extends StatelessWidget { static const String route = '/offline_map'; @@ -15,11 +14,11 @@ class OfflineMapPage extends StatelessWidget { appBar: AppBar(title: const Text('Offline Map')), drawer: buildDrawer(context, route), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Column( children: [ const Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: EdgeInsets.only(top: 8, bottom: 8), child: Text( 'This is an offline map that is showing Anholt Island, Denmark.'), ), @@ -27,16 +26,16 @@ class OfflineMapPage extends StatelessWidget { child: FlutterMap( options: MapOptions( center: LatLng(56.704173, 11.543808), - minZoom: 12.0, - maxZoom: 14.0, - zoom: 13.0, + minZoom: 12, + maxZoom: 14, + zoom: 13, swPanBoundary: LatLng(56.6877, 11.5089), nePanBoundary: LatLng(56.7378, 11.6644), ), layers: [ TileLayerOptions( tileProvider: AssetTileProvider(), - maxZoom: 14.0, + maxZoom: 14, urlTemplate: 'assets/map/anholt_osmbright/{z}/{x}/{y}.png', ), ], diff --git a/example/lib/pages/on_tap.dart b/example/lib/pages/on_tap.dart index 85c490057..8c9798605 100644 --- a/example/lib/pages/on_tap.dart +++ b/example/lib/pages/on_tap.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; -import '../widgets/drawer.dart'; - class OnTapPage extends StatefulWidget { static const String route = 'on_tap'; @@ -22,10 +21,10 @@ class OnTapPageState extends State { @override Widget build(BuildContext context) { - var markers = [ + final markers = [ Marker( - width: 80.0, - height: 80.0, + width: 80, + height: 80, point: london, builder: (ctx) => GestureDetector( onTap: () { @@ -37,8 +36,8 @@ class OnTapPageState extends State { ), ), Marker( - width: 80.0, - height: 80.0, + width: 80, + height: 80, point: dublin, builder: (ctx) => GestureDetector( onTap: () { @@ -52,8 +51,8 @@ class OnTapPageState extends State { ), ), Marker( - width: 80.0, - height: 80.0, + width: 80, + height: 80, point: paris, builder: (ctx) => GestureDetector( onTap: () { @@ -70,20 +69,20 @@ class OnTapPageState extends State { appBar: AppBar(title: const Text('OnTap')), drawer: buildDrawer(context, OnTapPage.route), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Column( children: [ const Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: EdgeInsets.only(top: 8, bottom: 8), child: Text('Try tapping on the markers'), ), Flexible( child: FlutterMap( options: MapOptions( center: LatLng(51.5, -0.09), - zoom: 5.0, - maxZoom: 5.0, - minZoom: 3.0, + zoom: 5, + maxZoom: 5, + minZoom: 3, ), layers: [ TileLayerOptions( diff --git a/example/lib/pages/overlay_image.dart b/example/lib/pages/overlay_image.dart index 1eb577cae..a89886a66 100644 --- a/example/lib/pages/overlay_image.dart +++ b/example/lib/pages/overlay_image.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; -import '../widgets/drawer.dart'; - class OverlayImagePage extends StatelessWidget { static const String route = 'overlay_image'; @@ -11,7 +10,7 @@ class OverlayImagePage extends StatelessWidget { @override Widget build(BuildContext context) { - var overlayImages = [ + final overlayImages = [ OverlayImage( bounds: LatLngBounds(LatLng(51.5, -0.09), LatLng(48.8566, 2.3522)), opacity: 0.8, @@ -23,18 +22,18 @@ class OverlayImagePage extends StatelessWidget { appBar: AppBar(title: const Text('Overlay Image')), drawer: buildDrawer(context, route), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Column( children: [ const Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: EdgeInsets.only(top: 8, bottom: 8), child: Text('This is a map that is showing (51.5, -0.9).'), ), Flexible( child: FlutterMap( options: MapOptions( center: LatLng(51.5, -0.09), - zoom: 6.0, + zoom: 6, ), layers: [ TileLayerOptions( diff --git a/example/lib/pages/plugin_api.dart b/example/lib/pages/plugin_api.dart index d39a0b9cf..6b25f3424 100644 --- a/example/lib/pages/plugin_api.dart +++ b/example/lib/pages/plugin_api.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/plugin_api.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; -import '../widgets/drawer.dart'; - class PluginPage extends StatelessWidget { static const String route = 'plugins'; @@ -15,14 +14,14 @@ class PluginPage extends StatelessWidget { appBar: AppBar(title: const Text('Plugins')), drawer: buildDrawer(context, PluginPage.route), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Column( children: [ Flexible( child: FlutterMap( options: MapOptions( center: LatLng(51.5, -0.09), - zoom: 5.0, + zoom: 5, plugins: [ MyCustomPlugin(), ], @@ -61,9 +60,9 @@ class MyCustomPlugin implements MapPlugin { Widget createLayer( LayerOptions options, MapState mapState, Stream stream) { if (options is MyCustomPluginOptions) { - var style = const TextStyle( + const style = TextStyle( fontWeight: FontWeight.bold, - fontSize: 24.0, + fontSize: 24, color: Colors.red, ); return Text( diff --git a/example/lib/pages/plugin_scalebar.dart b/example/lib/pages/plugin_scalebar.dart index c4aaa19f1..d2139506b 100644 --- a/example/lib/pages/plugin_scalebar.dart +++ b/example/lib/pages/plugin_scalebar.dart @@ -1,10 +1,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/plugin_api.dart'; +import 'package:flutter_map_example/pages/scale_layer_plugin_option.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; -import '../widgets/drawer.dart'; -import 'scale_layer_plugin_option.dart'; - class PluginScaleBar extends StatelessWidget { static const String route = '/plugin_scalebar'; @@ -16,14 +15,14 @@ class PluginScaleBar extends StatelessWidget { appBar: AppBar(title: const Text('ScaleBarPlugins')), drawer: buildDrawer(context, PluginScaleBar.route), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Column( children: [ Flexible( child: FlutterMap( options: MapOptions( center: LatLng(51.5, -0.09), - zoom: 5.0, + zoom: 5, plugins: [ ScaleLayerPlugin(), ], diff --git a/example/lib/pages/plugin_zoombuttons.dart b/example/lib/pages/plugin_zoombuttons.dart index 051a2989e..e8509daf9 100644 --- a/example/lib/pages/plugin_zoombuttons.dart +++ b/example/lib/pages/plugin_zoombuttons.dart @@ -1,10 +1,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/plugin_api.dart'; +import 'package:flutter_map_example/pages/zoombuttons_plugin_option.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; -import '../widgets/drawer.dart'; -import 'zoombuttons_plugin_option.dart'; - class PluginZoomButtons extends StatelessWidget { static const String route = '/plugin_zoombuttons'; @@ -16,14 +15,14 @@ class PluginZoomButtons extends StatelessWidget { appBar: AppBar(title: const Text('ZoomButtonsPlugins')), drawer: buildDrawer(context, PluginZoomButtons.route), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Column( children: [ Flexible( child: FlutterMap( options: MapOptions( center: LatLng(51.5, -0.09), - zoom: 5.0, + zoom: 5, plugins: [ ZoomButtonsPlugin(), ], diff --git a/example/lib/pages/point_to_latlng.dart b/example/lib/pages/point_to_latlng.dart index 54bb75231..608f6b1a7 100644 --- a/example/lib/pages/point_to_latlng.dart +++ b/example/lib/pages/point_to_latlng.dart @@ -2,10 +2,9 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; -import '../widgets/drawer.dart'; - class PointToLatLngPage extends StatefulWidget { static const String route = 'point_to_latlng'; @@ -19,7 +18,7 @@ class PointToLatLngPage extends StatefulWidget { class PointToLatlngPage extends State { late final MapController mapController; - late final StreamSubscription mapEventSubscription; + late final StreamSubscription mapEventSubscription; final pointSize = 40.0; final pointY = 200.0; @@ -47,12 +46,12 @@ class PointToLatlngPage extends State { children: [ FloatingActionButton( child: const Icon(Icons.rotate_right), - onPressed: () => mapController.rotate(60.0), + onPressed: () => mapController.rotate(60), ), const SizedBox(height: 15), FloatingActionButton( child: const Icon(Icons.cancel), - onPressed: () => mapController.rotate(0.0), + onPressed: () => mapController.rotate(0), ), ], ), @@ -63,8 +62,8 @@ class PointToLatlngPage extends State { mapController: mapController, options: MapOptions( center: LatLng(51.5, -0.09), - zoom: 5.0, - minZoom: 3.0, + zoom: 5, + minZoom: 3, ), children: [ TileLayerWidget( @@ -114,7 +113,7 @@ class PointToLatlngPage extends State { _updatePointLatLng(context); } - void _updatePointLatLng(context) { + void _updatePointLatLng(BuildContext context) { final pointX = _getPointX(context); final latLng = mapController.pointToLatLng(CustomPoint(pointX, pointY)); diff --git a/example/lib/pages/polygon.dart b/example/lib/pages/polygon.dart index c019f8b83..35e28f351 100644 --- a/example/lib/pages/polygon.dart +++ b/example/lib/pages/polygon.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; -import '../widgets/drawer.dart'; - class PolygonPage extends StatelessWidget { static const String route = 'polygon'; @@ -11,26 +10,26 @@ class PolygonPage extends StatelessWidget { @override Widget build(BuildContext context) { - var notFilledPoints = [ + final notFilledPoints = [ LatLng(51.5, -0.09), LatLng(53.3498, -6.2603), LatLng(48.8566, 2.3522), ]; - var filledPoints = [ + final filledPoints = [ LatLng(55.5, -0.09), LatLng(54.3498, -6.2603), LatLng(52.8566, 2.3522), ]; - var notFilledDotedPoints = [ + final notFilledDotedPoints = [ LatLng(49.29, -2.57), LatLng(51.46, -6.43), LatLng(49.86, -8.17), LatLng(48.39, -3.49), ]; - var filledDotedPoints = [ + final filledDotedPoints = [ LatLng(46.35, 4.94), LatLng(46.22, -0.11), LatLng(44.399, 1.76), @@ -40,18 +39,18 @@ class PolygonPage extends StatelessWidget { appBar: AppBar(title: const Text('Polygons')), drawer: buildDrawer(context, PolygonPage.route), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Column( children: [ const Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: EdgeInsets.only(top: 8, bottom: 8), child: Text('Polygons'), ), Flexible( child: FlutterMap( options: MapOptions( center: LatLng(51.5, -0.09), - zoom: 5.0, + zoom: 5, ), layers: [ TileLayerOptions( @@ -65,27 +64,27 @@ class PolygonPage extends StatelessWidget { points: notFilledPoints, isFilled: false, // By default it's false borderColor: Colors.red, - borderStrokeWidth: 4.0, + borderStrokeWidth: 4, ), Polygon( points: filledPoints, isFilled: true, color: Colors.purple, borderColor: Colors.purple, - borderStrokeWidth: 4.0, + borderStrokeWidth: 4, ), Polygon( points: notFilledDotedPoints, isFilled: false, isDotted: true, borderColor: Colors.green, - borderStrokeWidth: 4.0, + borderStrokeWidth: 4, ), Polygon( points: filledDotedPoints, isFilled: true, isDotted: true, - borderStrokeWidth: 4.0, + borderStrokeWidth: 4, borderColor: Colors.lightBlue, color: Colors.lightBlue, ), diff --git a/example/lib/pages/polyline.dart b/example/lib/pages/polyline.dart index aca0f705f..6de576a6f 100644 --- a/example/lib/pages/polyline.dart +++ b/example/lib/pages/polyline.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; -import '../widgets/drawer.dart'; - class PolylinePage extends StatefulWidget { static const String route = 'polyline'; @@ -17,18 +16,18 @@ class _PolylinePageState extends State { late Future> polylines; Future> getPolylines() async { - var polyLines = [ + final polyLines = [ Polyline( points: [ LatLng(50.5, -0.09), LatLng(51.3498, -6.2603), LatLng(53.8566, 2.3522), ], - strokeWidth: 4.0, + strokeWidth: 4, color: Colors.amber, ), ]; - await Future.delayed(const Duration(seconds: 3)); + await Future.delayed(const Duration(seconds: 3)); return polyLines; } @@ -40,13 +39,13 @@ class _PolylinePageState extends State { @override Widget build(BuildContext context) { - var points = [ + final points = [ LatLng(51.5, -0.09), LatLng(53.3498, -6.2603), LatLng(48.8566, 2.3522), ]; - var pointsGradient = [ + final pointsGradient = [ LatLng(55.5, -0.09), LatLng(54.3498, -6.2603), LatLng(52.8566, 2.3522), @@ -56,7 +55,7 @@ class _PolylinePageState extends State { appBar: AppBar(title: const Text('Polylines')), drawer: buildDrawer(context, PolylinePage.route), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: FutureBuilder>( future: polylines, builder: @@ -66,14 +65,14 @@ class _PolylinePageState extends State { return Column( children: [ const Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: EdgeInsets.only(top: 8, bottom: 8), child: Text('Polylines'), ), Flexible( child: FlutterMap( options: MapOptions( center: LatLng(51.5, -0.09), - zoom: 5.0, + zoom: 5, onTap: (tapPosition, point) { setState(() { debugPrint('onTap'); @@ -93,7 +92,7 @@ class _PolylinePageState extends State { polylines: [ Polyline( points: points, - strokeWidth: 4.0, + strokeWidth: 4, color: Colors.purple), ], ), @@ -101,7 +100,7 @@ class _PolylinePageState extends State { polylines: [ Polyline( points: pointsGradient, - strokeWidth: 4.0, + strokeWidth: 4, gradientColors: [ const Color(0xffE40203), const Color(0xffFEED00), diff --git a/example/lib/pages/reset_tile_layer.dart b/example/lib/pages/reset_tile_layer.dart index 6a72203c6..0156211e1 100644 --- a/example/lib/pages/reset_tile_layer.dart +++ b/example/lib/pages/reset_tile_layer.dart @@ -2,10 +2,9 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; -import '../widgets/drawer.dart'; - class ResetTileLayerPage extends StatefulWidget { static const String route = '/reset_tilelayer'; @@ -38,10 +37,10 @@ class ResetTileLayerPageState extends State { @override Widget build(BuildContext context) { - var markers = [ + final markers = [ Marker( - width: 80.0, - height: 80.0, + width: 80, + height: 80, point: LatLng(51.5, -0.09), builder: (ctx) => const FlutterLogo(), ), @@ -51,16 +50,16 @@ class ResetTileLayerPageState extends State { appBar: AppBar(title: const Text('TileLayer Reset')), drawer: buildDrawer(context, ResetTileLayerPage.route), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Column( children: [ const Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: EdgeInsets.only(top: 8, bottom: 8), child: Text( 'TileLayers can be progromatically reset, disposing of cached files'), ), Padding( - padding: const EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: const EdgeInsets.only(top: 8, bottom: 8), child: Wrap( children: [ MaterialButton( @@ -74,7 +73,7 @@ class ResetTileLayerPageState extends State { child: FlutterMap( options: MapOptions( center: LatLng(51.5, -0.09), - zoom: 5.0, + zoom: 5, ), layers: [ TileLayerOptions( diff --git a/example/lib/pages/scale_layer_plugin_option.dart b/example/lib/pages/scale_layer_plugin_option.dart index fc01d0e36..1ff52bb00 100644 --- a/example/lib/pages/scale_layer_plugin_option.dart +++ b/example/lib/pages/scale_layer_plugin_option.dart @@ -4,7 +4,7 @@ import 'dart:ui' as ui; import 'package:flutter/material.dart'; import 'package:flutter_map/plugin_api.dart'; -import './scalebar_utils.dart' as util; +import 'package:flutter_map_example/pages/scalebar_utils.dart' as util; class ScaleLayerPluginOption extends LayerOptions { TextStyle? textStyle; @@ -87,17 +87,17 @@ class ScaleLayer extends StatelessWidget { @override Widget build(BuildContext context) { - var zoom = map.zoom; - var distance = scale[max(0, min(20, zoom.round() + 2))].toDouble(); - var center = map.center; - var start = map.project(center); - var targetPoint = + final zoom = map.zoom; + final distance = scale[max(0, min(20, zoom.round() + 2))].toDouble(); + final center = map.center; + final start = map.project(center); + final targetPoint = util.calculateEndingGlobalCoordinates(center, 90, distance); - var end = map.project(targetPoint); - var displayDistance = distance > 999 + final end = map.project(targetPoint); + final displayDistance = distance > 999 ? '${(distance / 1000).toStringAsFixed(0)} km' : '${distance.toStringAsFixed(0)} m'; - var width = (end.x - (start.x as double)); + final width = (end.x - (start.x as double)); return LayoutBuilder( builder: (BuildContext context, BoxConstraints bc) { @@ -133,25 +133,25 @@ class ScalePainter extends CustomPainter { ..strokeCap = StrokeCap.square ..strokeWidth = lineWidth!; - var sizeForStartEnd = 4; - var paddingLeft = padding == null ? 0 : padding!.left + sizeForStartEnd / 2; + const sizeForStartEnd = 4; + final paddingLeft = padding == null ? 0 : padding!.left + sizeForStartEnd / 2; var paddingTop = padding == null ? 0 : padding!.top; - var textSpan = TextSpan(style: textStyle, text: text); - var textPainter = + final textSpan = TextSpan(style: textStyle, text: text); + final textPainter = TextPainter(text: textSpan, textDirection: TextDirection.ltr)..layout(); textPainter.paint( canvas, Offset(width / 2 - textPainter.width / 2 + paddingLeft, paddingTop as double)); paddingTop += textPainter.height; - var p1 = Offset(paddingLeft as double, sizeForStartEnd + paddingTop); - var p2 = Offset(paddingLeft + width, sizeForStartEnd + paddingTop); + final p1 = Offset(paddingLeft as double, sizeForStartEnd + paddingTop); + final 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; + final 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/scalebar_utils.dart b/example/lib/pages/scalebar_utils.dart index f888e2e8d..a6510ac66 100644 --- a/example/lib/pages/scalebar_utils.dart +++ b/example/lib/pages/scalebar_utils.dart @@ -13,47 +13,47 @@ double toRadians(double degrees) { 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; + const mSemiMajorAxis = 6378137.0; //WGS84 major axis + const mSemiMinorAxis = (1.0 - 1.0 / 298.257223563) * 6378137.0; + const mFlattening = 1.0 / 298.257223563; // double mInverseFlattening = 298.257223563; - var a = mSemiMajorAxis; - var b = mSemiMinorAxis; - var aSquared = a * a; - var bSquared = b * b; - var f = mFlattening; - var phi1 = toRadians(start.latitude); - var alpha1 = toRadians(startBearing); - var cosAlpha1 = cos(alpha1); - var sinAlpha1 = sin(alpha1); - var s = distance; - var tanU1 = (1.0 - f) * tan(phi1); - var cosU1 = 1.0 / sqrt(1.0 + tanU1 * tanU1); - var sinU1 = tanU1 * cosU1; + const a = mSemiMajorAxis; + const b = mSemiMinorAxis; + const aSquared = a * a; + const bSquared = b * b; + const f = mFlattening; + final phi1 = toRadians(start.latitude); + final alpha1 = toRadians(startBearing); + final cosAlpha1 = cos(alpha1); + final sinAlpha1 = sin(alpha1); + final s = distance; + final tanU1 = (1.0 - f) * tan(phi1); + final cosU1 = 1.0 / sqrt(1.0 + tanU1 * tanU1); + final sinU1 = tanU1 * cosU1; // eq. 1 - var sigma1 = atan2(tanU1, cosAlpha1); + final sigma1 = atan2(tanU1, cosAlpha1); // eq. 2 - var sinAlpha = cosU1 * sinAlpha1; + final sinAlpha = cosU1 * sinAlpha1; - var sin2Alpha = sinAlpha * sinAlpha; - var cos2Alpha = 1 - sin2Alpha; - var uSquared = cos2Alpha * (aSquared - bSquared) / bSquared; + final sin2Alpha = sinAlpha * sinAlpha; + final cos2Alpha = 1 - sin2Alpha; + final uSquared = cos2Alpha * (aSquared - bSquared) / bSquared; // eq. 3 - var A = 1 + + final A = 1 + (uSquared / 16384) * (4096 + uSquared * (-768 + uSquared * (320 - 175 * uSquared))); // eq. 4 - var B = (uSquared / 1024) * + final B = (uSquared / 1024) * (256 + uSquared * (-128 + uSquared * (74 - 47 * uSquared))); // iterate until there is a negligible change in sigma double deltaSigma; - var sOverbA = s / (b * A); + final sOverbA = s / (b * A); var sigma = sOverbA; double sinSigma; var prevSigma = sOverbA; @@ -67,7 +67,7 @@ LatLng calculateEndingGlobalCoordinates( cosSigmaM2 = cos(sigmaM2); cos2SigmaM2 = cosSigmaM2 * cosSigmaM2; sinSigma = sin(sigma); - var cosSignma = cos(sigma); + final cosSignma = cos(sigma); // eq. 6 deltaSigma = B * @@ -93,11 +93,11 @@ LatLng calculateEndingGlobalCoordinates( cosSigmaM2 = cos(sigmaM2); cos2SigmaM2 = cosSigmaM2 * cosSigmaM2; - var cosSigma = cos(sigma); + final cosSigma = cos(sigma); sinSigma = sin(sigma); // eq. 8 - var phi2 = atan2( + final phi2 = atan2( sinU1 * cosSigma + cosU1 * sinSigma * cosAlpha1, (1.0 - f) * sqrt(sin2Alpha + @@ -113,14 +113,14 @@ LatLng calculateEndingGlobalCoordinates( // double tanLambda = sinSigma * sinAlpha1 / (cosU1 * cosSigma - sinU1 * // sinSigma * cosAlpha1); // double lambda = Math.atan(tanLambda); - var lambda = atan2( + final lambda = atan2( sinSigma * sinAlpha1, (cosU1 * cosSigma - sinU1 * sinSigma * cosAlpha1)); // eq. 10 - var C = (f / 16) * cos2Alpha * (4 + f * (4 - 3 * cos2Alpha)); + final C = (f / 16) * cos2Alpha * (4 + f * (4 - 3 * cos2Alpha)); // eq. 11 - var L = lambda - + final L = lambda - (1 - C) * f * sinAlpha * diff --git a/example/lib/pages/sliding_map.dart b/example/lib/pages/sliding_map.dart index 364c13318..bc74030ea 100644 --- a/example/lib/pages/sliding_map.dart +++ b/example/lib/pages/sliding_map.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; -import '../widgets/drawer.dart'; - class SlidingMapPage extends StatelessWidget { static const String route = '/sliding_map'; @@ -15,11 +14,11 @@ class SlidingMapPage extends StatelessWidget { appBar: AppBar(title: const Text('Sliding Map')), drawer: buildDrawer(context, route), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Column( children: [ const Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: EdgeInsets.only(top: 8, bottom: 8), child: Text( 'This is a map that can be panned smoothly when the boundaries are reached.'), ), @@ -27,9 +26,9 @@ class SlidingMapPage extends StatelessWidget { child: FlutterMap( options: MapOptions( center: LatLng(56.704173, 11.543808), - minZoom: 12.0, - maxZoom: 14.0, - zoom: 13.0, + minZoom: 12, + maxZoom: 14, + zoom: 13, swPanBoundary: LatLng(56.6877, 11.5089), nePanBoundary: LatLng(56.7378, 11.6644), slideOnBoundaries: true, @@ -38,7 +37,7 @@ class SlidingMapPage extends StatelessWidget { layers: [ TileLayerOptions( tileProvider: AssetTileProvider(), - maxZoom: 14.0, + maxZoom: 14, urlTemplate: 'assets/map/anholt_osmbright/{z}/{x}/{y}.png', ), ], diff --git a/example/lib/pages/stateful_markers.dart b/example/lib/pages/stateful_markers.dart index 1fe7b49db..16ffe056f 100644 --- a/example/lib/pages/stateful_markers.dart +++ b/example/lib/pages/stateful_markers.dart @@ -2,10 +2,9 @@ import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; -import '../widgets/drawer.dart'; - class StatefulMarkersPage extends StatefulWidget { static const String route = '/stateful_markers'; @@ -37,8 +36,8 @@ class _StatefulMarkersPageState extends State { void _addMarker(String key) { _markers.add(Marker( - width: 40.0, - height: 40.0, + width: 40, + height: 40, point: LatLng( _random.nextDouble() * 10 + 48, _random.nextDouble() * 10 - 6), builder: (ctx) => const _ColorMarker(), @@ -51,18 +50,18 @@ class _StatefulMarkersPageState extends State { appBar: AppBar(title: const Text('Stateful Markers')), drawer: buildDrawer(context, StatefulMarkersPage.route), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Column( children: [ const Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: EdgeInsets.only(top: 8, bottom: 8), child: Text('This is a map that is showing (51.5, -0.9).'), ), Flexible( child: FlutterMap( options: MapOptions( center: LatLng(51.5, -0.09), - zoom: 5.0, + zoom: 5, ), layers: [ TileLayerOptions( @@ -105,7 +104,7 @@ class _ColorMarkerState extends State<_ColorMarker> { } class _ColorGenerator { - static List colorOptions = [ + static List colorOptions = [ Colors.blue, Colors.red, Colors.green, diff --git a/example/lib/pages/tap_to_add.dart b/example/lib/pages/tap_to_add.dart index 40acd30b2..f79afa4a1 100644 --- a/example/lib/pages/tap_to_add.dart +++ b/example/lib/pages/tap_to_add.dart @@ -1,10 +1,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; import 'package:positioned_tap_detector_2/positioned_tap_detector_2.dart'; -import '../widgets/drawer.dart'; - class TapToAddPage extends StatefulWidget { static const String route = '/tap'; @@ -21,10 +20,10 @@ class TapToAddPageState extends State { @override Widget build(BuildContext context) { - var markers = tappedPoints.map((latlng) { + final markers = tappedPoints.map((latlng) { return Marker( - width: 80.0, - height: 80.0, + width: 80, + height: 80, point: latlng, builder: (ctx) => const FlutterLogo(), ); @@ -34,18 +33,18 @@ class TapToAddPageState extends State { appBar: AppBar(title: const Text('Tap to add pins')), drawer: buildDrawer(context, TapToAddPage.route), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Column( children: [ const Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: EdgeInsets.only(top: 8, bottom: 8), child: Text('Tap to add pins'), ), Flexible( child: FlutterMap( options: MapOptions( center: LatLng(45.5231, -122.6765), - zoom: 13.0, + zoom: 13, onTap: _handleTap), layers: [ TileLayerOptions( diff --git a/example/lib/pages/tile_builder_example.dart b/example/lib/pages/tile_builder_example.dart index 2e382348a..7dc4584d3 100644 --- a/example/lib/pages/tile_builder_example.dart +++ b/example/lib/pages/tile_builder_example.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; -import '../widgets/drawer.dart'; - class TileBuilderPage extends StatefulWidget { static const String route = '/tile_builder_example'; @@ -14,10 +13,10 @@ class TileBuilderPage extends StatefulWidget { } class _TileBuilderPageState extends State { - var darkMode = false; - var loadingTime = false; - var showCoords = false; - var grid = false; + bool darkMode = false; + bool loadingTime = false; + bool showCoords = false; + bool grid = false; // mix of [coordinateDebugTileBuilder] and [loadingTimeDebugTileBuilder] from tile_builder.dart Widget tileBuilder(BuildContext context, Widget tileWidget, Tile tile) { @@ -106,11 +105,11 @@ class _TileBuilderPageState extends State { ], ), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: FlutterMap( options: MapOptions( center: LatLng(51.5, -0.09), - zoom: 5.0, + zoom: 5, ), layers: [ TileLayerOptions( @@ -124,8 +123,8 @@ class _TileBuilderPageState extends State { MarkerLayerOptions( markers: [ Marker( - width: 80.0, - height: 80.0, + width: 80, + height: 80, point: 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 ecd893497..09a55eda3 100644 --- a/example/lib/pages/tile_loading_error_handle.dart +++ b/example/lib/pages/tile_loading_error_handle.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; -import '../widgets/drawer.dart'; - class TileLoadingErrorHandle extends StatefulWidget { static const String route = '/tile_loading_error_handle'; @@ -22,11 +21,11 @@ class _TileLoadingErrorHandleState extends State { appBar: AppBar(title: const Text('Tile Loading Error Handle')), drawer: buildDrawer(context, TileLoadingErrorHandle.route), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Column( children: [ const Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: EdgeInsets.only(top: 8, bottom: 8), child: Text('Turn on Airplane mode and try to move or zoom map'), ), Flexible( @@ -34,7 +33,7 @@ class _TileLoadingErrorHandleState extends State { return FlutterMap( options: MapOptions( center: LatLng(51.5, -0.09), - zoom: 5.0, + zoom: 5, onPositionChanged: (MapPosition mapPosition, bool _) { needLoadingError = true; }, diff --git a/example/lib/pages/widgets.dart b/example/lib/pages/widgets.dart index 11646a743..47689bf6a 100644 --- a/example/lib/pages/widgets.dart +++ b/example/lib/pages/widgets.dart @@ -2,11 +2,10 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_map/plugin_api.dart'; +import 'package:flutter_map_example/pages/zoombuttons_plugin_option.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; -import '../pages/zoombuttons_plugin_option.dart'; -import '../widgets/drawer.dart'; - class WidgetsPage extends StatelessWidget { static const String route = 'widgets'; @@ -18,14 +17,14 @@ class WidgetsPage extends StatelessWidget { appBar: AppBar(title: const Text('Widgets')), drawer: buildDrawer(context, WidgetsPage.route), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Column( children: [ Flexible( child: FlutterMap( options: MapOptions( center: LatLng(51.5, -0.09), - zoom: 5.0, + zoom: 5, plugins: [ ZoomButtonsPlugin(), ], @@ -111,20 +110,20 @@ class _MovingWithoutRefreshAllMapMarkersState List _markers = [ Marker( - width: 80.0, - height: 80.0, + width: 80, + height: 80, point: LatLng(51.5, -0.09), builder: (ctx) => const FlutterLogo(), ), Marker( - width: 80.0, - height: 80.0, + width: 80, + height: 80, point: LatLng(53.3498, -6.2603), builder: (ctx) => const FlutterLogo(), ), Marker( - width: 80.0, - height: 80.0, + width: 80, + height: 80, point: 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 e71ea9271..b800cb007 100644 --- a/example/lib/pages/wms_tile_layer.dart +++ b/example/lib/pages/wms_tile_layer.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_map_example/widgets/drawer.dart'; import 'package:latlong2/latlong.dart'; -import '../widgets/drawer.dart'; - class WMSLayerPage extends StatelessWidget { static const String route = 'WMS layer'; @@ -15,18 +14,18 @@ class WMSLayerPage extends StatelessWidget { appBar: AppBar(title: const Text('WMS Layer')), drawer: buildDrawer(context, route), body: Padding( - padding: const EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8), child: Column( children: [ const Padding( - padding: EdgeInsets.only(top: 8.0, bottom: 8.0), + padding: EdgeInsets.only(top: 8, bottom: 8), child: Text('This is a map that is showing (42.58, 12.43).'), ), Flexible( child: FlutterMap( options: MapOptions( center: LatLng(42.58, 12.43), - zoom: 6.0, + zoom: 6, ), layers: [ TileLayerOptions( diff --git a/example/lib/pages/zoombuttons_plugin_option.dart b/example/lib/pages/zoombuttons_plugin_option.dart index 4cb96af60..132ee0c76 100644 --- a/example/lib/pages/zoombuttons_plugin_option.dart +++ b/example/lib/pages/zoombuttons_plugin_option.dart @@ -52,7 +52,7 @@ class ZoomButtons extends StatelessWidget { final MapState map; final Stream stream; final FitBoundsOptions options = - const FitBoundsOptions(padding: EdgeInsets.all(12.0)); + const FitBoundsOptions(padding: EdgeInsets.all(12)); ZoomButtons(this.zoomButtonsOpts, this.map, this.stream) : super(key: zoomButtonsOpts.key); @@ -75,8 +75,8 @@ class ZoomButtons extends StatelessWidget { backgroundColor: zoomButtonsOpts.zoomInColor ?? Theme.of(context).primaryColor, onPressed: () { - var bounds = map.getBounds(); - var centerZoom = map.getBoundsCenterZoom(bounds, options); + final bounds = map.getBounds(); + final centerZoom = map.getBoundsCenterZoom(bounds, options); var zoom = centerZoom.zoom + 1; if (zoom > zoomButtonsOpts.maxZoom) { zoom = zoomButtonsOpts.maxZoom; @@ -97,8 +97,8 @@ class ZoomButtons extends StatelessWidget { backgroundColor: zoomButtonsOpts.zoomOutColor ?? Theme.of(context).primaryColor, onPressed: () { - var bounds = map.getBounds(); - var centerZoom = map.getBoundsCenterZoom(bounds, options); + final bounds = map.getBounds(); + final centerZoom = map.getBoundsCenterZoom(bounds, options); var zoom = centerZoom.zoom - 1; if (zoom < zoomButtonsOpts.minZoom) { zoom = zoomButtonsOpts.minZoom; diff --git a/example/lib/test_app.dart b/example/lib/test_app.dart index 9908cc7ab..8a0fa89dd 100644 --- a/example/lib/test_app.dart +++ b/example/lib/test_app.dart @@ -30,7 +30,7 @@ class _TestAppState extends State { child: FlutterMap( options: MapOptions( center: LatLng(45.5231, -122.6765), - zoom: 13.0, + zoom: 13, ), layers: [ TileLayerOptions( diff --git a/example/lib/widgets/drawer.dart b/example/lib/widgets/drawer.dart index e2c5925df..8be238fdb 100644 --- a/example/lib/widgets/drawer.dart +++ b/example/lib/widgets/drawer.dart @@ -1,43 +1,43 @@ import 'package:flutter/material.dart'; + +import 'package:flutter_map_example/pages/animated_map_controller.dart'; +import 'package:flutter_map_example/pages/circle.dart'; +import 'package:flutter_map_example/pages/custom_crs/custom_crs.dart'; +import 'package:flutter_map_example/pages/epsg3413_crs.dart'; import 'package:flutter_map_example/pages/epsg4326_crs.dart'; +import 'package:flutter_map_example/pages/esri.dart'; +import 'package:flutter_map_example/pages/home.dart'; +import 'package:flutter_map_example/pages/interactive_test_page.dart'; +import 'package:flutter_map_example/pages/live_location.dart'; +import 'package:flutter_map_example/pages/many_markers.dart'; +import 'package:flutter_map_example/pages/map_controller.dart'; import 'package:flutter_map_example/pages/map_inside_listview.dart'; +import 'package:flutter_map_example/pages/marker_anchor.dart'; import 'package:flutter_map_example/pages/marker_rotate.dart'; +import 'package:flutter_map_example/pages/max_bounds.dart'; +import 'package:flutter_map_example/pages/moving_markers.dart'; import 'package:flutter_map_example/pages/network_tile_provider.dart'; +import 'package:flutter_map_example/pages/offline_map.dart'; +import 'package:flutter_map_example/pages/on_tap.dart'; +import 'package:flutter_map_example/pages/overlay_image.dart'; +import 'package:flutter_map_example/pages/plugin_api.dart'; +import 'package:flutter_map_example/pages/plugin_scalebar.dart'; +import 'package:flutter_map_example/pages/plugin_zoombuttons.dart'; import 'package:flutter_map_example/pages/point_to_latlng.dart'; - -import '../pages/animated_map_controller.dart'; -import '../pages/circle.dart'; -import '../pages/custom_crs/custom_crs.dart'; -import '../pages/epsg3413_crs.dart'; -import '../pages/esri.dart'; -import '../pages/home.dart'; -import '../pages/interactive_test_page.dart'; -import '../pages/live_location.dart'; -import '../pages/many_markers.dart'; -import '../pages/map_controller.dart'; -import '../pages/marker_anchor.dart'; -import '../pages/max_bounds.dart'; -import '../pages/moving_markers.dart'; -import '../pages/offline_map.dart'; -import '../pages/on_tap.dart'; -import '../pages/overlay_image.dart'; -import '../pages/plugin_api.dart'; -import '../pages/plugin_scalebar.dart'; -import '../pages/plugin_zoombuttons.dart'; -import '../pages/polygon.dart'; -import '../pages/polyline.dart'; -import '../pages/reset_tile_layer.dart'; -import '../pages/sliding_map.dart'; -import '../pages/stateful_markers.dart'; -import '../pages/tap_to_add.dart'; -import '../pages/tile_builder_example.dart'; -import '../pages/tile_loading_error_handle.dart'; -import '../pages/widgets.dart'; -import '../pages/wms_tile_layer.dart'; +import 'package:flutter_map_example/pages/polygon.dart'; +import 'package:flutter_map_example/pages/polyline.dart'; +import 'package:flutter_map_example/pages/reset_tile_layer.dart'; +import 'package:flutter_map_example/pages/sliding_map.dart'; +import 'package:flutter_map_example/pages/stateful_markers.dart'; +import 'package:flutter_map_example/pages/tap_to_add.dart'; +import 'package:flutter_map_example/pages/tile_builder_example.dart'; +import 'package:flutter_map_example/pages/tile_loading_error_handle.dart'; +import 'package:flutter_map_example/pages/widgets.dart'; +import 'package:flutter_map_example/pages/wms_tile_layer.dart'; Widget _buildMenuItem( BuildContext context, Widget title, String routeName, String currentRoute) { - var isSelected = routeName == currentRoute; + final isSelected = routeName == currentRoute; return ListTile( title: title, diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 5f478c080..07296df8a 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -17,7 +17,7 @@ dependencies: positioned_tap_detector_2: ^1.0.4 dev_dependencies: - flutter_lints: ">=1.0.4" + flutter_lints: ^2.0.1 flutter_test: sdk: flutter From 5517d7ed6fa34ede6356c7695c1b038a2429a837 Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 25 Jul 2022 22:13:09 +0200 Subject: [PATCH 4/9] refacto: replace dynamic by the right type --- example/lib/pages/max_bounds.dart | 3 +-- example/lib/pages/scale_layer_plugin_option.dart | 3 ++- lib/src/geo/crs/crs.dart | 11 +++++------ lib/src/layer/marker_layer.dart | 4 ++-- lib/src/layer/tile_layer/tile_layer.dart | 4 ++-- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/example/lib/pages/max_bounds.dart b/example/lib/pages/max_bounds.dart index 0c0cb2778..0701cfaf0 100644 --- a/example/lib/pages/max_bounds.dart +++ b/example/lib/pages/max_bounds.dart @@ -27,8 +27,7 @@ class MaxBoundsPage extends StatelessWidget { options: MapOptions( center: LatLng(56.704173, 11.543808), zoom: 3, - maxBounds: - LatLngBounds(LatLng(-90, -180), LatLng(90, 180)), + maxBounds: LatLngBounds(LatLng(-90, -180), LatLng(90, 180)), screenSize: MediaQuery.of(context).size, ), layers: [ diff --git a/example/lib/pages/scale_layer_plugin_option.dart b/example/lib/pages/scale_layer_plugin_option.dart index 1ff52bb00..cfd45efb8 100644 --- a/example/lib/pages/scale_layer_plugin_option.dart +++ b/example/lib/pages/scale_layer_plugin_option.dart @@ -134,7 +134,8 @@ class ScalePainter extends CustomPainter { ..strokeWidth = lineWidth!; const sizeForStartEnd = 4; - final paddingLeft = padding == null ? 0 : padding!.left + sizeForStartEnd / 2; + final paddingLeft = + padding == null ? 0 : padding!.left + sizeForStartEnd / 2; var paddingTop = padding == null ? 0 : padding!.top; final textSpan = TextSpan(style: textStyle, text: text); diff --git a/lib/src/geo/crs/crs.dart b/lib/src/geo/crs/crs.dart index 01ebf3df5..bcba7b5df 100644 --- a/lib/src/geo/crs/crs.dart +++ b/lib/src/geo/crs/crs.dart @@ -350,22 +350,21 @@ abstract class Projection { LatLng unproject(CustomPoint point); - double _inclusive( - Comparable start, Comparable end, double value) { - if (value.compareTo(start as num) < 0) return start as double; - if (value.compareTo(end as num) > 0) return end as double; + double _inclusive(double start, double end, double value) { + if (value.compareTo(start) < 0) return start; + if (value.compareTo(end) > 0) return end; return value; } @protected double inclusiveLat(double value) { - return _inclusive(-90.0, 90.0, value); + return _inclusive(-90, 90, value); } @protected double inclusiveLng(double value) { - return _inclusive(-180.0, 180.0, value); + return _inclusive(-180, 180, value); } } diff --git a/lib/src/layer/marker_layer.dart b/lib/src/layer/marker_layer.dart index 02d45e43b..26b2992b3 100644 --- a/lib/src/layer/marker_layer.dart +++ b/lib/src/layer/marker_layer.dart @@ -98,9 +98,9 @@ class Anchor { class AnchorPos { AnchorPos._(this.value); T value; - static AnchorPos exactly(Anchor anchor) => + static AnchorPos exactly(Anchor anchor) => AnchorPos._(anchor); - static AnchorPos align(AnchorAlign alignOpt) => + static AnchorPos align(AnchorAlign alignOpt) => AnchorPos._(alignOpt); } diff --git a/lib/src/layer/tile_layer/tile_layer.dart b/lib/src/layer/tile_layer/tile_layer.dart index c416e2ef4..ff246fd93 100644 --- a/lib/src/layer/tile_layer/tile_layer.dart +++ b/lib/src/layer/tile_layer/tile_layer.dart @@ -59,8 +59,8 @@ class _TileLayerState extends State with TickerProviderStateMixin { Tuple2? _wrapY; double? _tileZoom; - StreamSubscription? _moveSub; - StreamSubscription? _resetSub; + StreamSubscription? _moveSub; + StreamSubscription? _resetSub; StreamController? _throttleUpdate; late CustomPoint _tileSize; From 860d5d2c29404531585bac47152e37596d6bc446 Mon Sep 17 00:00:00 2001 From: Lucas Date: Fri, 29 Jul 2022 18:07:16 +0200 Subject: [PATCH 5/9] Change OverlayImage to BaseOverlayImage --- example/lib/pages/overlay_image.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/lib/pages/overlay_image.dart b/example/lib/pages/overlay_image.dart index bab64d012..41b8bac6c 100644 --- a/example/lib/pages/overlay_image.dart +++ b/example/lib/pages/overlay_image.dart @@ -14,7 +14,7 @@ class OverlayImagePage extends StatelessWidget { final bottomRightCorner = LatLng(53.475, 0.275); final bottomLeftCorner = LatLng(52.503, -1.868); - final overlayImages = [ + final overlayImages = [ OverlayImage( bounds: LatLngBounds(LatLng(51.5, -0.09), LatLng(48.8566, 2.3522)), opacity: 0.8, From dd45448568cd927b7f381ebbea773d105857d3c5 Mon Sep 17 00:00:00 2001 From: lsaudon Date: Fri, 29 Jul 2022 21:29:29 +0200 Subject: [PATCH 6/9] fix: compareTo is useless now Co-authored-by: Polo --- lib/src/geo/crs/crs.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/geo/crs/crs.dart b/lib/src/geo/crs/crs.dart index bcba7b5df..2e6f262eb 100644 --- a/lib/src/geo/crs/crs.dart +++ b/lib/src/geo/crs/crs.dart @@ -351,8 +351,8 @@ abstract class Projection { LatLng unproject(CustomPoint point); double _inclusive(double start, double end, double value) { - if (value.compareTo(start) < 0) return start; - if (value.compareTo(end) > 0) return end; + if (value < start) return start; + if (value > end) return end; return value; } From 97f8d7613f0031de48ecb7570491864a9430daf7 Mon Sep 17 00:00:00 2001 From: Luka S Date: Sat, 30 Jul 2022 21:23:42 +0100 Subject: [PATCH 7/9] Update analysis_options.yaml --- analysis_options.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index e7a5a419c..8f3350f31 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -6,7 +6,6 @@ analyzer: strict-inference: true strict-raw-types: true errors: - close_sinks: ignore missing_required_param: error missing_return: error From 95fe69eee7d3820141f198b6c53b651e589bd2b6 Mon Sep 17 00:00:00 2001 From: Lucas Date: Sat, 30 Jul 2022 22:32:03 +0200 Subject: [PATCH 8/9] Readded ignore close_sinks --- .../tile_provider/network_no_retry_image_provider.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/layer/tile_layer/tile_provider/network_no_retry_image_provider.dart b/lib/src/layer/tile_layer/tile_provider/network_no_retry_image_provider.dart index b4c790456..1abbdeb09 100644 --- a/lib/src/layer/tile_layer/tile_provider/network_no_retry_image_provider.dart +++ b/lib/src/layer/tile_layer/tile_provider/network_no_retry_image_provider.dart @@ -29,6 +29,7 @@ class FMNetworkNoRetryImageProvider FMNetworkNoRetryImageProvider key, DecoderCallback decode, ) { + //ignore: close_sinks final StreamController chunkEvents = StreamController(); From bf93ac1e5b6f6050417716acb30811c35581c431 Mon Sep 17 00:00:00 2001 From: lsaudon Date: Sun, 31 Jul 2022 08:38:01 +0200 Subject: [PATCH 9/9] Add same rules of pana --- analysis_options.yaml | 18 +++++++++++++----- example/analysis_options.yaml | 22 +++++++++++++++------- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 8f3350f31..58bbcff6c 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -11,10 +11,18 @@ analyzer: linter: rules: - prefer_final_locals: true - prefer_final_in_for_each: true - avoid_dynamic_calls: true + always_declare_return_types: true always_use_package_imports: true - type_annotate_public_apis: true + avoid_dynamic_calls: true + cancel_subscriptions: true + close_sinks: true + package_api_docs: true + prefer_constructors_over_static_methods: true + prefer_final_in_for_each: true + prefer_final_locals: true prefer_int_literals: true - use_named_constants: true + test_types_in_equals: true + throw_in_finally: true + type_annotate_public_apis: true + unnecessary_statements: true + use_named_constants: true \ No newline at end of file diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml index 445cfcc7a..71b37b60c 100644 --- a/example/analysis_options.yaml +++ b/example/analysis_options.yaml @@ -6,17 +6,25 @@ analyzer: strict-inference: true strict-raw-types: true errors: - close_sinks: ignore missing_required_param: error missing_return: error linter: rules: - library_private_types_in_public_api: false - prefer_final_locals: true - prefer_final_in_for_each: true - avoid_dynamic_calls: true + library_private_types_in_public_api: false # Not relevant to the example + + always_declare_return_types: true always_use_package_imports: true - type_annotate_public_apis: true + avoid_dynamic_calls: true + cancel_subscriptions: true + close_sinks: false + package_api_docs: true + prefer_constructors_over_static_methods: true + prefer_final_in_for_each: true + prefer_final_locals: true prefer_int_literals: true - use_named_constants: true + test_types_in_equals: true + throw_in_finally: true + type_annotate_public_apis: true + unnecessary_statements: true + use_named_constants: true \ No newline at end of file