From d717f2f1ecbd8cf53d0ef939c5a8034162fd2fef Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 00:16:17 +0200 Subject: [PATCH 01/36] avoid_escaping_inner_quotes --- analysis_options.yaml | 1 - example/lib/scrolling_map.dart | 2 +- scripts/lib/generate.dart | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index cde91768d..19a646ac0 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -10,7 +10,6 @@ analyzer: linter: rules: # temporary rules - avoid_escaping_inner_quotes: false prefer_interpolation_to_compose_strings: false prefer_if_elements_to_conditional_expressions: false constant_identifier_names: false diff --git a/example/lib/scrolling_map.dart b/example/lib/scrolling_map.dart index 059d59e66..d173412e5 100644 --- a/example/lib/scrolling_map.dart +++ b/example/lib/scrolling_map.dart @@ -76,7 +76,7 @@ class _ScrollingMapBodyState extends State { padding: const EdgeInsets.symmetric(vertical: 30.0), child: Column( children: [ - const Text('This map doesn\'t consume the vertical drags.'), + const Text("This map doesn't consume the vertical drags."), const Padding( padding: EdgeInsets.only(bottom: 12.0), child: diff --git a/scripts/lib/generate.dart b/scripts/lib/generate.dart index ba657b0a7..c28602d7b 100644 --- a/scripts/lib/generate.dart +++ b/scripts/lib/generate.dart @@ -169,7 +169,7 @@ List buildDocSplit(Map item) { if (values != null) { result.add("Options:"); for (var value in values.entries) { - result.add(" \"${value.key}\""); + result.add(' "${value.key}"'); result.addAll( splitIntoChunks("${value.value["doc"]}", 70, prefix: " ")); } From 855274a9600a3422249b5fc9d8b18e3490304a5e Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 00:17:16 +0200 Subject: [PATCH 02/36] Update analysis_options.yaml --- analysis_options.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 19a646ac0..d7b4f97a6 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -10,7 +10,6 @@ analyzer: linter: rules: # temporary rules - prefer_interpolation_to_compose_strings: false prefer_if_elements_to_conditional_expressions: false constant_identifier_names: false flutter_style_todos: false From a38183e2812f675a020df88d5cb5faab0e86f9af Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 00:18:06 +0200 Subject: [PATCH 03/36] prefer_if_elements_to_conditional_expressions --- analysis_options.yaml | 1 - example/lib/offline_regions.dart | 33 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index d7b4f97a6..c046d3276 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -10,7 +10,6 @@ analyzer: linter: rules: # temporary rules - prefer_if_elements_to_conditional_expressions: false constant_identifier_names: false flutter_style_todos: false one_member_abstracts: false diff --git a/example/lib/offline_regions.dart b/example/lib/offline_regions.dart index 95a9f6040..d58c6d738 100644 --- a/example/lib/offline_regions.dart +++ b/example/lib/offline_regions.dart @@ -157,22 +157,23 @@ class _OfflineRegionsBodyState extends State { ], ), const Spacer(), - _items[index].isDownloading - ? const SizedBox( - height: 16, - width: 16, - child: CircularProgressIndicator(), - ) - : IconButton( - icon: Icon( - _items[index].isDownloaded - ? Icons.delete - : Icons.file_download, - ), - onPressed: _items[index].isDownloaded - ? () => _deleteRegion(_items[index], index) - : () => _downloadRegion(_items[index], index), - ), + if (_items[index].isDownloading) + const SizedBox( + height: 16, + width: 16, + child: CircularProgressIndicator(), + ) + else + IconButton( + icon: Icon( + _items[index].isDownloaded + ? Icons.delete + : Icons.file_download, + ), + onPressed: _items[index].isDownloaded + ? () => _deleteRegion(_items[index], index) + : () => _downloadRegion(_items[index], index), + ), ], ), ), From c82d7105b51a2d0db1e80f02b561e4d62cb9ef1c Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 00:18:32 +0200 Subject: [PATCH 04/36] constant_identifier_names --- analysis_options.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index c046d3276..c79b0cbb0 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -10,7 +10,6 @@ analyzer: linter: rules: # temporary rules - constant_identifier_names: false flutter_style_todos: false one_member_abstracts: false lines_longer_than_80_chars: false From c0cf5dca5d32e9c22be5958b30de074511a64512 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 00:19:22 +0200 Subject: [PATCH 05/36] noop_primitive_operations --- analysis_options.yaml | 1 - example/lib/map_ui.dart | 2 +- lib/src/download_region_status.dart | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index c79b0cbb0..27287604e 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -16,7 +16,6 @@ linter: prefer_int_literals: false unnecessary_lambdas: false avoid_print: false - noop_primitive_operations: false avoid_bool_literals_in_conditional_expressions: false avoid_unused_constructor_parameters: false no_default_cases: false diff --git a/example/lib/map_ui.dart b/example/lib/map_ui.dart index 3d92ba060..12b78d79e 100644 --- a/example/lib/map_ui.dart +++ b/example/lib/map_ui.dart @@ -283,7 +283,7 @@ class MapUiBodyState extends State { ScaffoldMessenger.of(context).showSnackBar(SnackBar( content: Text( - "SW: ${result.southwest.toString()} NE: ${result.northeast.toString()}"), + "SW: ${result.southwest} NE: ${result.northeast}"), )); }, ); diff --git a/lib/src/download_region_status.dart b/lib/src/download_region_status.dart index 4edef4b73..2f9aed2d3 100644 --- a/lib/src/download_region_status.dart +++ b/lib/src/download_region_status.dart @@ -21,5 +21,5 @@ class Error extends DownloadRegionStatus { @override String toString() => - "Instance of 'DownloadRegionStatus.Error', cause = ${cause.toString()}"; + "Instance of 'DownloadRegionStatus.Error', cause = $cause"; } From bb3070ff85ba770168b5af2c94980762ed515f0e Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 00:20:00 +0200 Subject: [PATCH 06/36] avoid_bool_literals_in_conditional_expressions --- analysis_options.yaml | 1 - lib/src/maplibre_map.dart | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 27287604e..4b1761bca 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -16,7 +16,6 @@ linter: prefer_int_literals: false unnecessary_lambdas: false avoid_print: false - avoid_bool_literals_in_conditional_expressions: false avoid_unused_constructor_parameters: false no_default_cases: false sort_pub_dependencies: false diff --git a/lib/src/maplibre_map.dart b/lib/src/maplibre_map.dart index a515dc10d..e8677b7f3 100644 --- a/lib/src/maplibre_map.dart +++ b/lib/src/maplibre_map.dart @@ -60,9 +60,8 @@ class MapLibreMap extends StatefulWidget { AnnotationType.circle, ], }) : assert( - myLocationRenderMode != MyLocationRenderMode.normal - ? myLocationEnabled - : true, + myLocationRenderMode == MyLocationRenderMode.normal || + myLocationEnabled, "$myLocationRenderMode requires [myLocationEnabled] set to true.", ), assert(annotationOrder.length <= 4), From 27eaca2447cbd704cf1110e6816b9ea8d472060e Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 00:21:56 +0200 Subject: [PATCH 07/36] avoid_unused_constructor_parameters --- CHANGELOG.md | 1 + analysis_options.yaml | 1 - maplibre_gl_web/lib/src/ui/map.dart | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2a39bc08..819f15863 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ packages. * Renamed `Maplibre` to `MapLibre` to be in line with maplibre-native (affects for example the classes MaplibreMap and MaplibreMapController). +* Remove the parameter `hash` from `MapOptions` because it was not used. ### Changes diff --git a/analysis_options.yaml b/analysis_options.yaml index 4b1761bca..91ff63d64 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -16,7 +16,6 @@ linter: prefer_int_literals: false unnecessary_lambdas: false avoid_print: false - avoid_unused_constructor_parameters: false no_default_cases: false sort_pub_dependencies: false unnecessary_breaks: false diff --git a/maplibre_gl_web/lib/src/ui/map.dart b/maplibre_gl_web/lib/src/ui/map.dart index 4e462392b..f8eba1bae 100644 --- a/maplibre_gl_web/lib/src/ui/map.dart +++ b/maplibre_gl_web/lib/src/ui/map.dart @@ -1207,7 +1207,6 @@ class MapOptions extends JsObjectWrapper { dynamic get locale => jsObject.locale; factory MapOptions({ - dynamic hash, bool? interactive, dynamic container, num? bearingSnap, From d37c0edb6b01f489cff73873dc8f5e5b856e58a0 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 00:24:21 +0200 Subject: [PATCH 08/36] no_default_cases --- analysis_options.yaml | 1 - lib/src/controller.dart | 1 - .../lib/src/maplibre_web_gl_platform.dart | 24 ++++++------------- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 91ff63d64..9879dfeb0 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -16,7 +16,6 @@ linter: prefer_int_literals: false unnecessary_lambdas: false avoid_print: false - no_default_cases: false sort_pub_dependencies: false unnecessary_breaks: false avoid_redundant_argument_values: false diff --git a/lib/src/controller.dart b/lib/src/controller.dart index 0d45d154c..daa7c4c6a 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -154,7 +154,6 @@ class MapLibreMapController extends ChangeNotifier { onTap: onSymbolTapped.call, enableInteraction: enableInteraction); break; - default: } } if (onStyleLoadedCallback != null) { diff --git a/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart b/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart index f9e601c4b..53ac7408e 100644 --- a/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart +++ b/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart @@ -537,23 +537,13 @@ class MapLibreMapController extends MapLibrePlatform } String? prevPosition = _navigationControlPosition; - String? positionString; - switch (position) { - case CompassViewPosition.topRight: - positionString = 'top-right'; - break; - case CompassViewPosition.topLeft: - positionString = 'top-left'; - break; - case CompassViewPosition.bottomRight: - positionString = 'bottom-right'; - break; - case CompassViewPosition.bottomLeft: - positionString = 'bottom-left'; - break; - default: - positionString = null; - } + String? positionString = switch (position) { + CompassViewPosition.topRight => 'top-right', + CompassViewPosition.topLeft => 'top-left', + CompassViewPosition.bottomRight => 'bottom-right', + CompassViewPosition.bottomLeft => 'bottom-left', + _ => null, + }; bool newShowCompass = compassEnabled ?? prevShowCompass ?? false; String? newPosition = positionString ?? prevPosition; From c13a861cc439464e49b7a694b55259ed30e87b1c Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 00:26:44 +0200 Subject: [PATCH 09/36] sort_pub_dependencies --- analysis_options.yaml | 1 - example/pubspec.yaml | 11 +++++------ maplibre_gl_web/pubspec.yaml | 6 +++--- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 9879dfeb0..4b62f7f45 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -16,7 +16,6 @@ linter: prefer_int_literals: false unnecessary_lambdas: false avoid_print: false - sort_pub_dependencies: false unnecessary_breaks: false avoid_redundant_argument_values: false unawaited_futures: false diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 9cc1af292..71b4a0c82 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -10,20 +10,19 @@ environment: flutter: '>=3.10.0' dependencies: + collection: ^1.17.1 + device_info_plus: ^9.0.2 flutter: sdk: flutter - - maplibre_gl: ^0.19.0 + http: ^1.1.0 location: ^5.0.3 + maplibre_gl: ^0.19.0 path_provider: ^2.0.15 - http: ^1.1.0 - collection: ^1.17.1 - device_info_plus: ^9.0.2 dev_dependencies: - very_good_analysis: ^5.0.0 flutter_test: sdk: flutter + very_good_analysis: ^5.0.0 flutter: uses-material-design: true diff --git a/maplibre_gl_web/pubspec.yaml b/maplibre_gl_web/pubspec.yaml index 67293c970..00fae501e 100644 --- a/maplibre_gl_web/pubspec.yaml +++ b/maplibre_gl_web/pubspec.yaml @@ -16,14 +16,14 @@ flutter: fileName: maplibre_gl_web.dart dependencies: - js: ">=0.6.7 <0.8.0" flutter: sdk: flutter flutter_web_plugins: sdk: flutter - meta: ^1.3.0 - maplibre_gl_platform_interface: ^0.19.0+2 image: ^4.0.17 + js: ">=0.6.7 <0.8.0" + maplibre_gl_platform_interface: ^0.19.0+2 + meta: ^1.3.0 dev_dependencies: very_good_analysis: ^5.0.0 From 4dba61e1b165ed29c8d4b7ce8709e7bbae6c9a4e Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 00:28:36 +0200 Subject: [PATCH 10/36] unnecessary_breaks --- analysis_options.yaml | 1 - lib/src/controller.dart | 4 ---- lib/src/global.dart | 3 --- .../lib/src/method_channel_maplibre_gl.dart | 15 --------------- .../lib/src/maplibre_web_gl_platform.dart | 4 ---- 5 files changed, 27 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 4b62f7f45..a7d0ba22c 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -16,7 +16,6 @@ linter: prefer_int_literals: false unnecessary_lambdas: false avoid_print: false - unnecessary_breaks: false avoid_redundant_argument_values: false unawaited_futures: false overridden_fields: false diff --git a/lib/src/controller.dart b/lib/src/controller.dart index daa7c4c6a..0b3f98332 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -139,21 +139,17 @@ class MapLibreMapController extends ChangeNotifier { case AnnotationType.fill: fillManager = FillManager(this, onTap: onFillTapped.call, enableInteraction: enableInteraction); - break; case AnnotationType.line: lineManager = LineManager(this, onTap: onLineTapped.call, enableInteraction: enableInteraction); - break; case AnnotationType.circle: circleManager = CircleManager(this, onTap: onCircleTapped.call, enableInteraction: enableInteraction); - break; case AnnotationType.symbol: symbolManager = SymbolManager(this, onTap: onSymbolTapped.call, enableInteraction: enableInteraction); - break; } } if (onStyleLoadedCallback != null) { diff --git a/lib/src/global.dart b/lib/src/global.dart index a892ae892..06cb7d73b 100644 --- a/lib/src/global.dart +++ b/lib/src/global.dart @@ -118,7 +118,6 @@ Future downloadOfflineRegion( switch (jsonData['status']) { case 'start': status = InProgress(0.0); - break; case 'progress': final dynamic value = jsonData['progress']; double progress = 0.0; @@ -132,10 +131,8 @@ Future downloadOfflineRegion( } status = InProgress(progress); - break; case 'success': status = Success(); - break; } onEvent(status ?? (throw 'Invalid event status ${jsonData['status']}')); }); diff --git a/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart b/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart index db317365b..297f77669 100644 --- a/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart +++ b/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart @@ -11,7 +11,6 @@ class MapLibreMethodChannel extends MapLibrePlatform { if (symbolId != null) { onInfoWindowTappedPlatform(symbolId); } - break; case 'feature#onTap': final id = call.arguments['id']; @@ -24,7 +23,6 @@ class MapLibreMethodChannel extends MapLibrePlatform { 'point': Point(x, y), 'latLng': LatLng(lat, lng) }); - break; case 'feature#onDrag': final id = call.arguments['id']; final double x = call.arguments['x']; @@ -47,24 +45,18 @@ class MapLibreMethodChannel extends MapLibrePlatform { 'delta': LatLng(deltaLat, deltaLng), 'eventType': eventType, }); - break; - case 'camera#onMoveStarted': onCameraMoveStartedPlatform(null); - break; case 'camera#onMove': final cameraPosition = CameraPosition.fromMap(call.arguments['position'])!; onCameraMovePlatform(cameraPosition); - break; case 'camera#onIdle': final cameraPosition = CameraPosition.fromMap(call.arguments['position']); onCameraIdlePlatform(cameraPosition); - break; case 'map#onStyleLoaded': onMapStyleLoadedPlatform(null); - break; case 'map#onMapClick': final double x = call.arguments['x']; final double y = call.arguments['y']; @@ -72,7 +64,6 @@ class MapLibreMethodChannel extends MapLibrePlatform { final double lat = call.arguments['lat']; onMapClickPlatform( {'point': Point(x, y), 'latLng': LatLng(lat, lng)}); - break; case 'map#onMapLongClick': final double x = call.arguments['x']; final double y = call.arguments['y']; @@ -80,18 +71,13 @@ class MapLibreMethodChannel extends MapLibrePlatform { final double lat = call.arguments['lat']; onMapLongClickPlatform( {'point': Point(x, y), 'latLng': LatLng(lat, lng)}); - - break; case 'map#onCameraTrackingChanged': final int mode = call.arguments['mode']; onCameraTrackingChangedPlatform(MyLocationTrackingMode.values[mode]); - break; case 'map#onCameraTrackingDismissed': onCameraTrackingDismissedPlatform(null); - break; case 'map#onIdle': onMapIdlePlatform(null); - break; case 'map#onUserLocationUpdated': final dynamic userLocation = call.arguments['userLocation']; final dynamic heading = call.arguments['heading']; @@ -119,7 +105,6 @@ class MapLibreMethodChannel extends MapLibrePlatform { ), timestamp: DateTime.fromMillisecondsSinceEpoch( userLocation['timestamp']))); - break; default: throw MissingPluginException(); } diff --git a/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart b/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart index 53ac7408e..00c574cfd 100644 --- a/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart +++ b/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart @@ -577,16 +577,12 @@ class MapLibreMapController extends MapLibrePlatform switch (position) { case AttributionButtonPosition.topRight: positionString = 'top-right'; - break; case AttributionButtonPosition.topLeft: positionString = 'top-left'; - break; case AttributionButtonPosition.bottomRight: positionString = 'bottom-right'; - break; case AttributionButtonPosition.bottomLeft: positionString = 'bottom-left'; - break; } _removeAttributionButton(); From cefcb25386e1053c55a629ff25a686d81a590fe4 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 00:32:11 +0200 Subject: [PATCH 11/36] avoid_redundant_argument_values --- analysis_options.yaml | 1 - example/analysis_options.yaml | 1 + .../lib/src/method_channel_maplibre_gl.dart | 4 ++-- maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index a7d0ba22c..2222d213b 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -16,7 +16,6 @@ linter: prefer_int_literals: false unnecessary_lambdas: false avoid_print: false - avoid_redundant_argument_values: false unawaited_futures: false overridden_fields: false avoid_setters_without_getters: false diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml index cb1978b3a..6bc76834f 100644 --- a/example/analysis_options.yaml +++ b/example/analysis_options.yaml @@ -3,3 +3,4 @@ include: ../analysis_options.yaml linter: rules: public_member_api_docs: false + avoid_redundant_argument_values: false \ No newline at end of file diff --git a/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart b/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart index 297f77669..cfc039d90 100644 --- a/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart +++ b/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart @@ -325,7 +325,7 @@ class MapLibreMethodChannel extends MapLibrePlatform { Future requestMyLocationLatLng() async { try { final Map reply = await _channel.invokeMethod( - 'locationComponent#getLastLocation', null); + 'locationComponent#getLastLocation'); double latitude = 0.0, longitude = 0.0; if (reply.containsKey('latitude') && reply['latitude'] != null) { latitude = double.parse(reply['latitude'].toString()); @@ -343,7 +343,7 @@ class MapLibreMethodChannel extends MapLibrePlatform { Future getVisibleRegion() async { try { final Map reply = - await _channel.invokeMethod('map#getVisibleRegion', null); + await _channel.invokeMethod('map#getVisibleRegion'); final southwest = reply['sw'] as List; final northeast = reply['ne'] as List; return LatLngBounds( diff --git a/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart b/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart index 00c574cfd..e9d5baec7 100644 --- a/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart +++ b/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart @@ -660,7 +660,7 @@ class MapLibreMapController extends MapLibrePlatform @override void setMyLocationEnabled(bool myLocationEnabled) { if (myLocationEnabled) { - _addGeolocateControl(trackUserLocation: false); + _addGeolocateControl(); } else { _removeGeolocateControl(); } @@ -678,7 +678,7 @@ class MapLibreMapController extends MapLibrePlatform return; } if (myLocationTrackingMode == 0) { - _addGeolocateControl(trackUserLocation: false); + _addGeolocateControl(); } else { print('Only one tracking mode available in web'); _addGeolocateControl(trackUserLocation: true); From ae8a5e096cd588efd44f1d303509fa49f7f8b4fa Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 00:33:54 +0200 Subject: [PATCH 12/36] avoid_setters_without_getters --- analysis_options.yaml | 1 - .../lib/src/maplibre_gl_platform_interface.dart | 4 ---- 2 files changed, 5 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 2222d213b..f49a273dc 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -18,7 +18,6 @@ linter: avoid_print: false unawaited_futures: false overridden_fields: false - avoid_setters_without_getters: false cast_nullable_to_non_nullable: false only_throw_errors: false no_runtimeType_toString: false diff --git a/maplibre_gl_platform_interface/lib/src/maplibre_gl_platform_interface.dart b/maplibre_gl_platform_interface/lib/src/maplibre_gl_platform_interface.dart index c54a4dfd2..9f6bb1a86 100644 --- a/maplibre_gl_platform_interface/lib/src/maplibre_gl_platform_interface.dart +++ b/maplibre_gl_platform_interface/lib/src/maplibre_gl_platform_interface.dart @@ -17,10 +17,6 @@ abstract class MapLibrePlatform { static MapLibrePlatform Function() createInstance = () => _instance ?? MapLibreMethodChannel(); - static set instance(MapLibreMethodChannel instance) { - _instance = instance; - } - final onInfoWindowTappedPlatform = ArgumentCallbacks(); final onFeatureTappedPlatform = ArgumentCallbacks>(); From a5998ecc1254c9ecfdce1313c14e31a19c1ee685 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 00:36:23 +0200 Subject: [PATCH 13/36] cast_nullable_to_non_nullable --- analysis_options.yaml | 1 - maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index f49a273dc..f748cdfe6 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -18,7 +18,6 @@ linter: avoid_print: false unawaited_futures: false overridden_fields: false - cast_nullable_to_non_nullable: false only_throw_errors: false no_runtimeType_toString: false always_put_required_named_parameters_first: false diff --git a/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart b/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart index e9d5baec7..554e5ba39 100644 --- a/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart +++ b/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart @@ -101,7 +101,7 @@ class MapLibreMapController extends MapLibrePlatform _onMapResize(); }); }); - resizeObserver.observe(html.document.body as html.Element); + resizeObserver.observe(html.document.body!); } void _loadFromAssets(Event event) async { From 1a71596321719d42129e208aee6572a735d7b060 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 00:41:30 +0200 Subject: [PATCH 14/36] only_throw_errors --- analysis_options.yaml | 1 - lib/src/global.dart | 56 ++++++++++++++++++------------------------- 2 files changed, 23 insertions(+), 34 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index f748cdfe6..53d150281 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -18,7 +18,6 @@ linter: avoid_print: false unawaited_futures: false overridden_fields: false - only_throw_errors: false no_runtimeType_toString: false always_put_required_named_parameters_first: false leading_newlines_in_multiline_strings: false diff --git a/lib/src/global.dart b/lib/src/global.dart index 06cb7d73b..8c628e1c4 100644 --- a/lib/src/global.dart +++ b/lib/src/global.dart @@ -19,7 +19,8 @@ Future installOfflineMapTiles(String tilesDb) async { enum DragEventType { start, drag, end } -Future setOffline(bool offline) => _globalChannel.invokeMethod( +Future setOffline(bool offline) => + _globalChannel.invokeMethod( 'setOffline', { 'offline': offline, @@ -55,8 +56,8 @@ Future> getListOfRegions() async { return regions.map((region) => OfflineRegion.fromMap(region)).toList(); } -Future updateOfflineRegionMetadata( - int id, Map metadata) async { +Future updateOfflineRegionMetadata(int id, + Map metadata) async { final regionJson = await _globalChannel.invokeMethod( 'updateOfflineRegionMetadata', { @@ -76,20 +77,23 @@ Future setOfflineTileCountLimit(int limit) => }, ); -Future deleteOfflineRegion(int id) => _globalChannel.invokeMethod( +Future deleteOfflineRegion(int id) => + _globalChannel.invokeMethod( 'deleteOfflineRegion', { 'id': id, }, ); -Future downloadOfflineRegion( - OfflineRegionDefinition definition, { - Map metadata = const {}, - Function(DownloadRegionStatus event)? onEvent, -}) async { +Future downloadOfflineRegion(OfflineRegionDefinition definition, + { + Map metadata = const {}, + Function(DownloadRegionStatus event)? onEvent, + }) async { String channelName = - 'downloadOfflineRegion_${DateTime.now().microsecondsSinceEpoch}'; + 'downloadOfflineRegion_${DateTime + .now() + .microsecondsSinceEpoch}'; await _globalChannel .invokeMethod('downloadOfflineRegion#setup', { @@ -106,35 +110,21 @@ Future downloadOfflineRegion( PlatformException( code: 'UnknowException', message: - 'This error is unhandled by plugin. Please contact us if needed.', + 'This error is unhandled by plugin. Please contact us if needed.', details: error, ), ); onEvent(unknownError); return unknownError; }).listen((data) { - final Map jsonData = json.decode(data); - DownloadRegionStatus? status; - switch (jsonData['status']) { - case 'start': - status = InProgress(0.0); - case 'progress': - final dynamic value = jsonData['progress']; - double progress = 0.0; - - if (value is int) { - progress = value.toDouble(); - } - - if (value is double) { - progress = value; - } - - status = InProgress(progress); - case 'success': - status = Success(); - } - onEvent(status ?? (throw 'Invalid event status ${jsonData['status']}')); + final Map jsonData = json.decode(data); + final status = switch (jsonData['status']) { + 'start' => InProgress(0.0), + 'progress' => InProgress((jsonData['progress']! as num).toDouble()), + 'success' => Success(), + _ => throw Exception('Invalid event status ${jsonData['status']}'), + }; + onEvent(status); }); } From 4da2620c3fec083cfe716669fd5b8158ebbb48ab Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 00:42:30 +0200 Subject: [PATCH 15/36] no_runtimeType_toString --- analysis_options.yaml | 1 - lib/src/offline_region.dart | 4 ++-- maplibre_gl_platform_interface/lib/src/location.dart | 6 +++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 53d150281..e62932186 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -18,7 +18,6 @@ linter: avoid_print: false unawaited_futures: false overridden_fields: false - no_runtimeType_toString: false always_put_required_named_parameters_first: false leading_newlines_in_multiline_strings: false prefer_constructors_over_static_methods: false diff --git a/lib/src/offline_region.dart b/lib/src/offline_region.dart index 53a8cdab0..04badd120 100644 --- a/lib/src/offline_region.dart +++ b/lib/src/offline_region.dart @@ -19,7 +19,7 @@ class OfflineRegionDefinition { @override String toString() => - "$runtimeType, bounds = $bounds, mapStyleUrl = $mapStyleUrl, minZoom = $minZoom, maxZoom = $maxZoom"; + "OfflineRegionDefinition, bounds = $bounds, mapStyleUrl = $mapStyleUrl, minZoom = $minZoom, maxZoom = $maxZoom"; Map toMap() { final Map data = {}; @@ -72,5 +72,5 @@ class OfflineRegion { @override String toString() => - "$runtimeType, id = $id, definition = $definition, metadata = $metadata"; + "OfflineRegion, id = $id, definition = $definition, metadata = $metadata"; } diff --git a/maplibre_gl_platform_interface/lib/src/location.dart b/maplibre_gl_platform_interface/lib/src/location.dart index 075aa2dc1..7a3a5a775 100644 --- a/maplibre_gl_platform_interface/lib/src/location.dart +++ b/maplibre_gl_platform_interface/lib/src/location.dart @@ -45,7 +45,7 @@ class LatLng { } @override - String toString() => '$runtimeType($latitude, $longitude)'; + String toString() => 'LatLng($latitude, $longitude)'; @override bool operator ==(Object other) { @@ -97,7 +97,7 @@ class LatLngBounds { @override String toString() { - return '$runtimeType($southwest, $northeast)'; + return 'LatLngBounds($southwest, $northeast)'; } @override @@ -153,7 +153,7 @@ class LatLngQuad { @override String toString() { - return '$runtimeType($topLeft, $topRight, $bottomRight, $bottomLeft)'; + return 'LatLngQuad($topLeft, $topRight, $bottomRight, $bottomLeft)'; } @override From bcf733b9b592d62b3330ce5cef4c702d35da01da Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 00:53:34 +0200 Subject: [PATCH 16/36] prefer_constructors_over_static_methods --- analysis_options.yaml | 1 - lib/src/maplibre_map.dart | 45 ++++++------ .../lib/src/camera.dart | 70 +++++++------------ .../lib/src/location.dart | 5 +- maplibre_gl_web/lib/src/geo/lng_lat.dart | 4 +- .../lib/src/geo/lng_lat_bounds.dart | 4 +- 6 files changed, 53 insertions(+), 76 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index e62932186..f3d194f91 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -20,7 +20,6 @@ linter: overridden_fields: false always_put_required_named_parameters_first: false leading_newlines_in_multiline_strings: false - prefer_constructors_over_static_methods: false prefer_null_aware_method_calls: false directives_ordering: false unnecessary_await_in_return: false diff --git a/lib/src/maplibre_map.dart b/lib/src/maplibre_map.dart index e8677b7f3..d169abc6d 100644 --- a/lib/src/maplibre_map.dart +++ b/lib/src/maplibre_map.dart @@ -363,29 +363,28 @@ class _MapLibreMapOptions { this.attributionButtonMargins, }); - static _MapLibreMapOptions fromWidget(MapLibreMap map) { - return _MapLibreMapOptions( - compassEnabled: map.compassEnabled, - cameraTargetBounds: map.cameraTargetBounds, - styleString: map.styleString, - minMaxZoomPreference: map.minMaxZoomPreference, - rotateGesturesEnabled: map.rotateGesturesEnabled, - scrollGesturesEnabled: map.scrollGesturesEnabled, - tiltGesturesEnabled: map.tiltGesturesEnabled, - trackCameraPosition: map.trackCameraPosition, - zoomGesturesEnabled: map.zoomGesturesEnabled, - doubleClickZoomEnabled: - map.doubleClickZoomEnabled ?? map.zoomGesturesEnabled, - myLocationEnabled: map.myLocationEnabled, - myLocationTrackingMode: map.myLocationTrackingMode, - myLocationRenderMode: map.myLocationRenderMode, - logoViewMargins: map.logoViewMargins, - compassViewPosition: map.compassViewPosition, - compassViewMargins: map.compassViewMargins, - attributionButtonPosition: map.attributionButtonPosition, - attributionButtonMargins: map.attributionButtonMargins, - ); - } + _MapLibreMapOptions.fromWidget(MapLibreMap map) + : this( + compassEnabled: map.compassEnabled, + cameraTargetBounds: map.cameraTargetBounds, + styleString: map.styleString, + minMaxZoomPreference: map.minMaxZoomPreference, + rotateGesturesEnabled: map.rotateGesturesEnabled, + scrollGesturesEnabled: map.scrollGesturesEnabled, + tiltGesturesEnabled: map.tiltGesturesEnabled, + trackCameraPosition: map.trackCameraPosition, + zoomGesturesEnabled: map.zoomGesturesEnabled, + doubleClickZoomEnabled: + map.doubleClickZoomEnabled ?? map.zoomGesturesEnabled, + myLocationEnabled: map.myLocationEnabled, + myLocationTrackingMode: map.myLocationTrackingMode, + myLocationRenderMode: map.myLocationRenderMode, + logoViewMargins: map.logoViewMargins, + compassViewPosition: map.compassViewPosition, + compassViewMargins: map.compassViewMargins, + attributionButtonPosition: map.attributionButtonPosition, + attributionButtonMargins: map.attributionButtonMargins, + ); final bool? compassEnabled; diff --git a/maplibre_gl_platform_interface/lib/src/camera.dart b/maplibre_gl_platform_interface/lib/src/camera.dart index 8e9651338..e404262bb 100644 --- a/maplibre_gl_platform_interface/lib/src/camera.dart +++ b/maplibre_gl_platform_interface/lib/src/camera.dart @@ -92,42 +92,34 @@ class CameraUpdate { CameraUpdate._(this._json); /// Returns a camera update that moves the camera to the specified position. - static CameraUpdate newCameraPosition(CameraPosition cameraPosition) { - return CameraUpdate._( - ['newCameraPosition', cameraPosition.toMap()], - ); - } + CameraUpdate.newCameraPosition(CameraPosition cameraPosition) + : this._(['newCameraPosition', cameraPosition.toMap()]); /// Returns a camera update that moves the camera target to the specified /// geographical location. - static CameraUpdate newLatLng(LatLng latLng) { - return CameraUpdate._(['newLatLng', latLng.toJson()]); - } + CameraUpdate.newLatLng(LatLng latLng) + : this._(['newLatLng', latLng.toJson()]); /// Returns a camera update that transforms the camera so that the specified /// geographical bounding box is centered in the map view at the greatest /// possible zoom level. A non-zero [left], [top], [right] and [bottom] padding /// insets the bounding box from the map view's edges. /// The camera's new tilt and bearing will both be 0.0. - static CameraUpdate newLatLngBounds(LatLngBounds bounds, - {double left = 0, double top = 0, double right = 0, double bottom = 0}) { - return CameraUpdate._([ - 'newLatLngBounds', - bounds.toList(), - left, - top, - right, - bottom, - ]); - } + CameraUpdate.newLatLngBounds(LatLngBounds bounds, + {double left = 0, double top = 0, double right = 0, double bottom = 0}) + : this._([ + 'newLatLngBounds', + bounds.toList(), + left, + top, + right, + bottom, + ]); /// Returns a camera update that moves the camera target to the specified /// geographical location and zoom level. - static CameraUpdate newLatLngZoom(LatLng latLng, double zoom) { - return CameraUpdate._( - ['newLatLngZoom', latLng.toJson(), zoom], - ); - } + CameraUpdate.newLatLngZoom(LatLng latLng, double zoom) + : this._(['newLatLngZoom', latLng.toJson(), zoom]); /// Returns a camera update that moves the camera target the specified screen /// distance. @@ -135,16 +127,13 @@ class CameraUpdate { /// For a camera with bearing 0.0 (pointing north), scrolling by 50,75 moves /// the camera's target to a geographical location that is 50 to the east and /// 75 to the south of the current location, measured in screen coordinates. - static CameraUpdate scrollBy(double dx, double dy) { - return CameraUpdate._( - ['scrollBy', dx, dy], - ); - } + CameraUpdate.scrollBy(double dx, double dy) + : this._(['scrollBy', dx, dy]); /// Returns a camera update that modifies the camera zoom level by the /// specified amount. The optional [focus] is a screen point whose underlying /// geographical location should be invariant, if possible, by the movement. - static CameraUpdate zoomBy(double amount, [Offset? focus]) { + factory CameraUpdate.zoomBy(double amount, [Offset? focus]) { if (focus == null) { return CameraUpdate._(['zoomBy', amount]); } else { @@ -160,32 +149,23 @@ class CameraUpdate { /// closer to the surface of the Earth. /// /// Equivalent to the result of calling `zoomBy(1.0)`. - static CameraUpdate zoomIn() { - return CameraUpdate._(['zoomIn']); - } + CameraUpdate.zoomIn() : this._(['zoomIn']); /// Returns a camera update that zooms the camera out, bringing the camera /// further away from the surface of the Earth. /// /// Equivalent to the result of calling `zoomBy(-1.0)`. - static CameraUpdate zoomOut() { - return CameraUpdate._(['zoomOut']); - } + CameraUpdate.zoomOut() : this._(['zoomOut']); /// Returns a camera update that sets the camera zoom level. - static CameraUpdate zoomTo(double zoom) { - return CameraUpdate._(['zoomTo', zoom]); - } + CameraUpdate.zoomTo(double zoom) : this._(['zoomTo', zoom]); /// Returns a camera update that sets the camera bearing. - static CameraUpdate bearingTo(double bearing) { - return CameraUpdate._(['bearingTo', bearing]); - } + CameraUpdate.bearingTo(double bearing) + : this._(['bearingTo', bearing]); /// Returns a camera update that sets the camera bearing. - static CameraUpdate tiltTo(double tilt) { - return CameraUpdate._(['tiltTo', tilt]); - } + CameraUpdate.tiltTo(double tilt) : this._(['tiltTo', tilt]); final dynamic _json; diff --git a/maplibre_gl_platform_interface/lib/src/location.dart b/maplibre_gl_platform_interface/lib/src/location.dart index 7a3a5a775..f13b4121c 100644 --- a/maplibre_gl_platform_interface/lib/src/location.dart +++ b/maplibre_gl_platform_interface/lib/src/location.dart @@ -40,9 +40,7 @@ class LatLng { return [longitude, latitude]; } - static LatLng _fromJson(List json) { - return LatLng(json[0], json[1]); - } + LatLng._fromJson(List json) : this(json[0], json[1]); @override String toString() => 'LatLng($latitude, $longitude)'; @@ -235,6 +233,7 @@ class UserHeading { /// Returns a timestamp for when the magnetic heading was determined. final DateTime timestamp; + const UserHeading( {required this.magneticHeading, required this.trueHeading, diff --git a/maplibre_gl_web/lib/src/geo/lng_lat.dart b/maplibre_gl_web/lib/src/geo/lng_lat.dart index 62a88c2ae..bb50e3c2f 100644 --- a/maplibre_gl_web/lib/src/geo/lng_lat.dart +++ b/maplibre_gl_web/lib/src/geo/lng_lat.dart @@ -80,8 +80,8 @@ class LngLat extends JsObjectWrapper { /// var arr = [-73.9749, 40.7736]; /// var ll = maplibregl.LngLat.convert(arr); /// ll; // = LngLat {lng: -73.9749, lat: 40.7736} - static LngLat convert(dynamic input) => - LngLat.fromJsObject(LngLatJsImpl.convert(input)); + LngLat.convert(dynamic input) + : this.fromJsObject(LngLatJsImpl.convert(input)); /// Creates a new LngLat from a [jsObject]. LngLat.fromJsObject(super.jsObject) : super.fromJsObject(); diff --git a/maplibre_gl_web/lib/src/geo/lng_lat_bounds.dart b/maplibre_gl_web/lib/src/geo/lng_lat_bounds.dart index a620954e0..6e5617427 100644 --- a/maplibre_gl_web/lib/src/geo/lng_lat_bounds.dart +++ b/maplibre_gl_web/lib/src/geo/lng_lat_bounds.dart @@ -139,8 +139,8 @@ class LngLatBounds extends JsObjectWrapper { /// var arr = [[-73.9876, 40.7661], [-73.9397, 40.8002]]; /// var llb = maplibregl.LngLatBounds.convert(arr); /// llb; // = LngLatBounds {_sw: LngLat {lng: -73.9876, lat: 40.7661}, _ne: LngLat {lng: -73.9397, lat: 40.8002}} - static LngLatBounds convert(dynamic input) => - LngLatBounds.fromJsObject(LngLatBoundsJsImpl.convert(input)); + LngLatBounds.convert(dynamic input) + : this.fromJsObject(LngLatBoundsJsImpl.convert(input)); /// Creates a new LngLatBounds from a [jsObject]. LngLatBounds.fromJsObject(super.jsObject) : super.fromJsObject(); From ea66d0aa97b7fb15e92d279e02f42ec2b39bc0c1 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 00:56:38 +0200 Subject: [PATCH 17/36] prefer_null_aware_method_calls --- analysis_options.yaml | 1 - lib/src/controller.dart | 28 +++++++--------------------- lib/src/maplibre_map.dart | 4 +--- 3 files changed, 8 insertions(+), 25 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index f3d194f91..573e6765b 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -20,7 +20,6 @@ linter: overridden_fields: false always_put_required_named_parameters_first: false leading_newlines_in_multiline_strings: false - prefer_null_aware_method_calls: false directives_ordering: false unnecessary_await_in_return: false avoid_multiple_declarations_per_line: false diff --git a/lib/src/controller.dart b/lib/src/controller.dart index 0b3f98332..447fed722 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -125,9 +125,7 @@ class MapLibreMapController extends ChangeNotifier { if (cameraPosition != null) { _cameraPosition = cameraPosition; } - if (onCameraIdle != null) { - onCameraIdle!(); - } + onCameraIdle?.call(); notifyListeners(); }); @@ -152,39 +150,27 @@ class MapLibreMapController extends ChangeNotifier { enableInteraction: enableInteraction); } } - if (onStyleLoadedCallback != null) { - onStyleLoadedCallback!(); - } + onStyleLoadedCallback?.call(); }); _maplibrePlatform.onMapClickPlatform.add((dict) { - if (onMapClick != null) { - onMapClick!(dict['point'], dict['latLng']); - } + onMapClick?.call(dict['point'], dict['latLng']); }); _maplibrePlatform.onMapLongClickPlatform.add((dict) { - if (onMapLongClick != null) { - onMapLongClick!(dict['point'], dict['latLng']); - } + onMapLongClick?.call(dict['point'], dict['latLng']); }); _maplibrePlatform.onCameraTrackingChangedPlatform.add((mode) { - if (onCameraTrackingChanged != null) { - onCameraTrackingChanged!(mode); - } + onCameraTrackingChanged?.call(mode); }); _maplibrePlatform.onCameraTrackingDismissedPlatform.add((_) { - if (onCameraTrackingDismissed != null) { - onCameraTrackingDismissed!(); - } + onCameraTrackingDismissed?.call(); }); _maplibrePlatform.onMapIdlePlatform.add((_) { - if (onMapIdle != null) { - onMapIdle!(); - } + onMapIdle?.call(); }); _maplibrePlatform.onUserLocationUpdatedPlatform.add((location) { onUserLocationUpdated?.call(location); diff --git a/lib/src/maplibre_map.dart b/lib/src/maplibre_map.dart index d169abc6d..de6716d5b 100644 --- a/lib/src/maplibre_map.dart +++ b/lib/src/maplibre_map.dart @@ -331,9 +331,7 @@ class _MapLibreMapState extends State { ); await _maplibrePlatform.initPlatform(id); _controller.complete(controller); - if (widget.onMapCreated != null) { - widget.onMapCreated!(controller); - } + widget.onMapCreated?.call(controller); } } From 86fe37e82b47f3d65dd011309ba203401384918a Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 00:57:55 +0200 Subject: [PATCH 18/36] unnecessary_await_in_return --- analysis_options.yaml | 1 - .../lib/src/method_channel_maplibre_gl.dart | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 573e6765b..5482b9783 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -21,7 +21,6 @@ linter: always_put_required_named_parameters_first: false leading_newlines_in_multiline_strings: false directives_ordering: false - unnecessary_await_in_return: false avoid_multiple_declarations_per_line: false unnecessary_string_escapes: false parameter_assignments: false diff --git a/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart b/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart index cfc039d90..de5e32eba 100644 --- a/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart +++ b/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart @@ -194,7 +194,7 @@ class MapLibreMethodChannel extends MapLibrePlatform { @override Future animateCamera(cameraUpdate, {Duration? duration}) async { - return await _channel.invokeMethod('camera#animate', { + return _channel.invokeMethod('camera#animate', { 'cameraUpdate': cameraUpdate.toJson(), 'duration': duration?.inMilliseconds, }); @@ -202,7 +202,7 @@ class MapLibreMethodChannel extends MapLibrePlatform { @override Future moveCamera(CameraUpdate cameraUpdate) async { - return await _channel.invokeMethod('camera#move', { + return _channel.invokeMethod('camera#move', { 'cameraUpdate': cameraUpdate.toJson(), }); } From e99e99c2b186ea10fdba7ee9671398fad416ab8a Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 00:58:16 +0200 Subject: [PATCH 19/36] avoid_multiple_declarations_per_line --- analysis_options.yaml | 1 - .../lib/src/method_channel_maplibre_gl.dart | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 5482b9783..5aea25988 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -21,7 +21,6 @@ linter: always_put_required_named_parameters_first: false leading_newlines_in_multiline_strings: false directives_ordering: false - avoid_multiple_declarations_per_line: false unnecessary_string_escapes: false parameter_assignments: false combinators_ordering: false diff --git a/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart b/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart index de5e32eba..593681694 100644 --- a/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart +++ b/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart @@ -326,7 +326,8 @@ class MapLibreMethodChannel extends MapLibrePlatform { try { final Map reply = await _channel.invokeMethod( 'locationComponent#getLastLocation'); - double latitude = 0.0, longitude = 0.0; + double latitude = 0.0; + double longitude = 0.0; if (reply.containsKey('latitude') && reply['latitude'] != null) { latitude = double.parse(reply['latitude'].toString()); } From 638ebd8b9a1882c7169ec619d84a859fb5bb2a62 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 00:58:36 +0200 Subject: [PATCH 20/36] unnecessary_string_escapes --- analysis_options.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 5aea25988..4520a543d 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -21,7 +21,6 @@ linter: always_put_required_named_parameters_first: false leading_newlines_in_multiline_strings: false directives_ordering: false - unnecessary_string_escapes: false parameter_assignments: false combinators_ordering: false use_setters_to_change_properties: false From a9dfeac90326889411a40c199dbc57630ab7d2a2 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 00:59:45 +0200 Subject: [PATCH 21/36] combinators_ordering --- analysis_options.yaml | 1 - lib/maplibre_gl.dart | 48 +++++++++++++++++++++---------------------- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 4520a543d..169299d9c 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -22,7 +22,6 @@ linter: leading_newlines_in_multiline_strings: false directives_ordering: false parameter_assignments: false - combinators_ordering: false use_setters_to_change_properties: false avoid_equals_and_hash_code_on_mutable_classes: false type_annotate_public_apis: false diff --git a/lib/maplibre_gl.dart b/lib/maplibre_gl.dart index 3def53d8e..ee1312ae2 100644 --- a/lib/maplibre_gl.dart +++ b/lib/maplibre_gl.dart @@ -48,39 +48,39 @@ import 'package:maplibre_gl_platform_interface/maplibre_gl_platform_interface.da export 'package:maplibre_gl_platform_interface/maplibre_gl_platform_interface.dart' show - LatLng, - LatLngBounds, - LatLngQuad, - CameraPosition, - UserLocation, - UserHeading, - CameraUpdate, + Annotation, ArgumentCallbacks, - Symbol, - SymbolOptions, - CameraTargetBounds, - MinMaxZoomPreference, - MyLocationTrackingMode, - MyLocationRenderMode, - CompassViewPosition, AttributionButtonPosition, - Annotation, + CameraPosition, + CameraTargetBounds, + CameraUpdate, Circle, CircleOptions, - Line, - LineOptions, + CompassViewPosition, Fill, FillOptions, - SourceProperties, - RasterSourceProperties, - VectorSourceProperties, - RasterDemSourceProperties, GeojsonSourceProperties, - VideoSourceProperties, ImageSourceProperties, - MapLibrePlatform, + LatLng, + LatLngBounds, + LatLngQuad, + Line, + LineOptions, MapLibreMethodChannel, - OnPlatformViewCreatedCallback; + MapLibrePlatform, + MinMaxZoomPreference, + MyLocationRenderMode, + MyLocationTrackingMode, + OnPlatformViewCreatedCallback, + RasterDemSourceProperties, + RasterSourceProperties, + SourceProperties, + Symbol, + SymbolOptions, + UserHeading, + UserLocation, + VectorSourceProperties, + VideoSourceProperties; part 'src/controller.dart'; From 3eb7c3776df04cbd8a165a663080c68b2bfd3f1d Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 01:01:06 +0200 Subject: [PATCH 22/36] avoid_equals_and_hash_code_on_mutable_classes --- analysis_options.yaml | 1 - maplibre_gl_platform_interface/lib/src/camera.dart | 1 + maplibre_gl_platform_interface/lib/src/location.dart | 3 +++ maplibre_gl_platform_interface/lib/src/ui.dart | 2 ++ 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 169299d9c..0c820750d 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -23,7 +23,6 @@ linter: directives_ordering: false parameter_assignments: false use_setters_to_change_properties: false - avoid_equals_and_hash_code_on_mutable_classes: false type_annotate_public_apis: false unnecessary_library_directive: false prefer_asserts_with_message: false diff --git a/maplibre_gl_platform_interface/lib/src/camera.dart b/maplibre_gl_platform_interface/lib/src/camera.dart index e404262bb..a9ad87780 100644 --- a/maplibre_gl_platform_interface/lib/src/camera.dart +++ b/maplibre_gl_platform_interface/lib/src/camera.dart @@ -7,6 +7,7 @@ part of '../maplibre_gl_platform_interface.dart'; /// The position of the map "camera", the view point from which the world is /// shown in the map view. Aggregates the camera's [target] geographical /// location, its [zoom] level, [tilt] angle, and [bearing]. +@immutable class CameraPosition { const CameraPosition({ this.bearing = 0.0, diff --git a/maplibre_gl_platform_interface/lib/src/location.dart b/maplibre_gl_platform_interface/lib/src/location.dart index f13b4121c..d8b540aa9 100644 --- a/maplibre_gl_platform_interface/lib/src/location.dart +++ b/maplibre_gl_platform_interface/lib/src/location.dart @@ -5,6 +5,7 @@ part of '../maplibre_gl_platform_interface.dart'; /// A pair of latitude and longitude coordinates, stored as degrees. +@immutable class LatLng { /// Creates a geographical location specified in degrees [latitude] and /// [longitude]. @@ -64,6 +65,7 @@ class LatLng { /// if `southwest.longitude` ≤ `northeast.longitude`, /// * lng ∈ [-180, `northeast.longitude`] ∪ [`southwest.longitude`, 180[, /// if `northeast.longitude` < `southwest.longitude` +@immutable class LatLngBounds { /// Creates geographical bounding box with the specified corners. /// @@ -111,6 +113,7 @@ class LatLngBounds { /// A geographical area representing a non-aligned quadrilateral /// This class does not wrap values to the world bounds +@immutable class LatLngQuad { const LatLngQuad({ required this.topLeft, diff --git a/maplibre_gl_platform_interface/lib/src/ui.dart b/maplibre_gl_platform_interface/lib/src/ui.dart index 2b7212787..abeebfc98 100644 --- a/maplibre_gl_platform_interface/lib/src/ui.dart +++ b/maplibre_gl_platform_interface/lib/src/ui.dart @@ -44,6 +44,7 @@ enum AttributionButtonPosition { /// Used with [_MapLibreMapOptions] to wrap a [LatLngBounds] value. This allows /// distinguishing between specifying an unbounded target (null `LatLngBounds`) /// from not specifying anything (null `CameraTargetBounds`). +@immutable class CameraTargetBounds { /// Creates a camera target bounds with the specified bounding box, or null /// to indicate that the camera target is not bounded. @@ -79,6 +80,7 @@ class CameraTargetBounds { /// Used with [_MapLibreMapOptions] to wrap min and max zoom. This allows /// distinguishing between specifying unbounded zooming (null [minZoom] and /// [maxZoom]) from not specifying anything (null [MinMaxZoomPreference]). +@immutable class MinMaxZoomPreference { const MinMaxZoomPreference(this.minZoom, this.maxZoom) : assert(minZoom == null || maxZoom == null || minZoom <= maxZoom); From 69f0e14bdcd54c27aeb95c12e32f307d565ba424 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 01:04:12 +0200 Subject: [PATCH 23/36] unnecessary_library_directive --- analysis_options.yaml | 1 - maplibre_gl_web/lib/src/geo/geojson.dart | 2 -- maplibre_gl_web/lib/src/geo/lng_lat.dart | 2 -- maplibre_gl_web/lib/src/geo/lng_lat_bounds.dart | 2 -- maplibre_gl_web/lib/src/geo/point.dart | 2 -- maplibre_gl_web/lib/src/interop/interop.dart | 2 -- .../lib/src/interop/style/layers/circle_layer_interop.dart | 2 -- .../lib/src/interop/style/layers/line_layer_interop.dart | 2 -- .../lib/src/interop/style/layers/symbol_layer_interop.dart | 2 -- maplibre_gl_web/lib/src/style/evaluation_parameters.dart | 2 -- maplibre_gl_web/lib/src/style/layers/circle_layer.dart | 2 -- maplibre_gl_web/lib/src/style/layers/layer.dart | 2 -- maplibre_gl_web/lib/src/style/layers/line_layer.dart | 2 -- maplibre_gl_web/lib/src/style/layers/symbol_layer.dart | 2 -- maplibre_gl_web/lib/src/style/sources/geojson_source.dart | 2 -- maplibre_gl_web/lib/src/style/sources/source.dart | 2 -- maplibre_gl_web/lib/src/style/sources/vector_source.dart | 2 -- maplibre_gl_web/lib/src/style/style.dart | 2 -- maplibre_gl_web/lib/src/style/style_image.dart | 2 -- maplibre_gl_web/lib/src/ui/camera.dart | 2 -- maplibre_gl_web/lib/src/ui/control/attribution_control.dart | 2 -- maplibre_gl_web/lib/src/ui/control/geolocate_control.dart | 2 -- maplibre_gl_web/lib/src/ui/control/logo_control.dart | 2 -- maplibre_gl_web/lib/src/ui/control/navigation_control.dart | 2 -- maplibre_gl_web/lib/src/ui/events.dart | 2 -- maplibre_gl_web/lib/src/ui/handler/box_zoom.dart | 2 -- maplibre_gl_web/lib/src/ui/handler/dblclick_zoom.dart | 2 -- maplibre_gl_web/lib/src/ui/handler/drag_pan.dart | 2 -- maplibre_gl_web/lib/src/ui/handler/drag_rotate.dart | 2 -- maplibre_gl_web/lib/src/ui/handler/keyboard.dart | 2 -- maplibre_gl_web/lib/src/ui/handler/scroll_zoom.dart | 2 -- maplibre_gl_web/lib/src/ui/handler/touch_zoom_rotate.dart | 2 -- maplibre_gl_web/lib/src/ui/map.dart | 2 -- maplibre_gl_web/lib/src/ui/marker.dart | 2 -- maplibre_gl_web/lib/src/ui/popup.dart | 2 -- maplibre_gl_web/lib/src/util/evented.dart | 2 -- 36 files changed, 71 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 0c820750d..fb482fdd3 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -24,7 +24,6 @@ linter: parameter_assignments: false use_setters_to_change_properties: false type_annotate_public_apis: false - unnecessary_library_directive: false prefer_asserts_with_message: false public_member_api_docs: false require_trailing_commas: false diff --git a/maplibre_gl_web/lib/src/geo/geojson.dart b/maplibre_gl_web/lib/src/geo/geojson.dart index f523c5544..0450f2c59 100644 --- a/maplibre_gl_web/lib/src/geo/geojson.dart +++ b/maplibre_gl_web/lib/src/geo/geojson.dart @@ -1,5 +1,3 @@ -library maplibre.geo.geojson; - import 'package:js/js_util.dart'; import 'package:maplibre_gl_web/src/interop/interop.dart'; import 'package:maplibre_gl_web/src/utils.dart'; diff --git a/maplibre_gl_web/lib/src/geo/lng_lat.dart b/maplibre_gl_web/lib/src/geo/lng_lat.dart index bb50e3c2f..4a0fbe58d 100644 --- a/maplibre_gl_web/lib/src/geo/lng_lat.dart +++ b/maplibre_gl_web/lib/src/geo/lng_lat.dart @@ -1,5 +1,3 @@ -library maplibre.geo.lng_lat; - import 'package:maplibre_gl_web/src/geo/lng_lat_bounds.dart'; import 'package:maplibre_gl_web/src/interop/interop.dart'; diff --git a/maplibre_gl_web/lib/src/geo/lng_lat_bounds.dart b/maplibre_gl_web/lib/src/geo/lng_lat_bounds.dart index 6e5617427..7eb9110e9 100644 --- a/maplibre_gl_web/lib/src/geo/lng_lat_bounds.dart +++ b/maplibre_gl_web/lib/src/geo/lng_lat_bounds.dart @@ -1,5 +1,3 @@ -library maplibre.geo.lng_lat_bounds; - import 'package:maplibre_gl_web/src/geo/lng_lat.dart'; import 'package:maplibre_gl_web/src/interop/interop.dart'; diff --git a/maplibre_gl_web/lib/src/geo/point.dart b/maplibre_gl_web/lib/src/geo/point.dart index db631abc8..f44065eef 100644 --- a/maplibre_gl_web/lib/src/geo/point.dart +++ b/maplibre_gl_web/lib/src/geo/point.dart @@ -1,5 +1,3 @@ -library maplibre.geo.point; - import 'package:maplibre_gl_web/src/interop/interop.dart'; class Point extends JsObjectWrapper { diff --git a/maplibre_gl_web/lib/src/interop/interop.dart b/maplibre_gl_web/lib/src/interop/interop.dart index 52a797c09..3a31bacfc 100644 --- a/maplibre_gl_web/lib/src/interop/interop.dart +++ b/maplibre_gl_web/lib/src/interop/interop.dart @@ -1,5 +1,3 @@ -library maplibre.interop; - export 'geo/geojson_interop.dart'; export 'geo/lng_lat_bounds_interop.dart'; export 'geo/lng_lat_interop.dart'; diff --git a/maplibre_gl_web/lib/src/interop/style/layers/circle_layer_interop.dart b/maplibre_gl_web/lib/src/interop/style/layers/circle_layer_interop.dart index 8a6eec60a..0fd3f4dbf 100644 --- a/maplibre_gl_web/lib/src/interop/style/layers/circle_layer_interop.dart +++ b/maplibre_gl_web/lib/src/interop/style/layers/circle_layer_interop.dart @@ -1,5 +1,3 @@ -library maplibre.interop.style.layers.circle_layer; - import 'package:js/js_util.dart'; import 'package:maplibre_gl_web/src/style/layers/circle_layer.dart'; diff --git a/maplibre_gl_web/lib/src/interop/style/layers/line_layer_interop.dart b/maplibre_gl_web/lib/src/interop/style/layers/line_layer_interop.dart index d8e548b6c..1948a4027 100644 --- a/maplibre_gl_web/lib/src/interop/style/layers/line_layer_interop.dart +++ b/maplibre_gl_web/lib/src/interop/style/layers/line_layer_interop.dart @@ -1,5 +1,3 @@ -library maplibre.interop.style.layers.line_layer; - import 'package:js/js_util.dart'; import 'package:maplibre_gl_web/src/style/layers/line_layer.dart'; diff --git a/maplibre_gl_web/lib/src/interop/style/layers/symbol_layer_interop.dart b/maplibre_gl_web/lib/src/interop/style/layers/symbol_layer_interop.dart index 5da48e352..400c9b9a7 100644 --- a/maplibre_gl_web/lib/src/interop/style/layers/symbol_layer_interop.dart +++ b/maplibre_gl_web/lib/src/interop/style/layers/symbol_layer_interop.dart @@ -1,5 +1,3 @@ -library maplibre.interop.style.layers.symbol_layer; - import 'package:js/js_util.dart'; import 'package:maplibre_gl_web/src/style/layers/symbol_layer.dart'; diff --git a/maplibre_gl_web/lib/src/style/evaluation_parameters.dart b/maplibre_gl_web/lib/src/style/evaluation_parameters.dart index bacfd9085..ede955fd1 100644 --- a/maplibre_gl_web/lib/src/style/evaluation_parameters.dart +++ b/maplibre_gl_web/lib/src/style/evaluation_parameters.dart @@ -1,5 +1,3 @@ -library maplibre.style.evaluation_parameters; - import 'package:maplibre_gl_web/src/interop/interop.dart'; class EvaluationParameters extends JsObjectWrapper { diff --git a/maplibre_gl_web/lib/src/style/layers/circle_layer.dart b/maplibre_gl_web/lib/src/style/layers/circle_layer.dart index 882b68c9a..247c8b972 100644 --- a/maplibre_gl_web/lib/src/style/layers/circle_layer.dart +++ b/maplibre_gl_web/lib/src/style/layers/circle_layer.dart @@ -1,5 +1,3 @@ -library maplibre.style.layers.circle_layer; - import 'package:maplibre_gl_web/src/interop/style/layers/circle_layer_interop.dart'; import 'package:maplibre_gl_web/src/style/layers/layer.dart'; diff --git a/maplibre_gl_web/lib/src/style/layers/layer.dart b/maplibre_gl_web/lib/src/style/layers/layer.dart index 456c60b2f..d9038f8bf 100644 --- a/maplibre_gl_web/lib/src/style/layers/layer.dart +++ b/maplibre_gl_web/lib/src/style/layers/layer.dart @@ -1,5 +1,3 @@ -library maplibre.style.layers.layer; - abstract class Layer { /// JS object. dynamic get jsObject => throw Exception('jsObject not implemented!'); diff --git a/maplibre_gl_web/lib/src/style/layers/line_layer.dart b/maplibre_gl_web/lib/src/style/layers/line_layer.dart index b5e17f9c8..ba17429c3 100644 --- a/maplibre_gl_web/lib/src/style/layers/line_layer.dart +++ b/maplibre_gl_web/lib/src/style/layers/line_layer.dart @@ -1,5 +1,3 @@ -library maplibre.style.layers.line_layer; - import 'package:maplibre_gl_web/src/interop/style/layers/line_layer_interop.dart'; import 'package:maplibre_gl_web/src/style/layers/layer.dart'; diff --git a/maplibre_gl_web/lib/src/style/layers/symbol_layer.dart b/maplibre_gl_web/lib/src/style/layers/symbol_layer.dart index 974987e06..f9d38e875 100644 --- a/maplibre_gl_web/lib/src/style/layers/symbol_layer.dart +++ b/maplibre_gl_web/lib/src/style/layers/symbol_layer.dart @@ -1,5 +1,3 @@ -library maplibre.style.layers.symbol_layer; - import 'package:maplibre_gl_web/src/interop/style/layers/symbol_layer_interop.dart'; import 'package:maplibre_gl_web/src/style/layers/layer.dart'; diff --git a/maplibre_gl_web/lib/src/style/sources/geojson_source.dart b/maplibre_gl_web/lib/src/style/sources/geojson_source.dart index 0667e4d42..93f8358ea 100644 --- a/maplibre_gl_web/lib/src/style/sources/geojson_source.dart +++ b/maplibre_gl_web/lib/src/style/sources/geojson_source.dart @@ -1,5 +1,3 @@ -library maplibre.style.sources.geojson_source; - import 'package:maplibre_gl_web/src/geo/geojson.dart'; import 'package:maplibre_gl_web/src/interop/style/sources/geojson_source_interop.dart'; import 'package:maplibre_gl_web/src/style/sources/source.dart'; diff --git a/maplibre_gl_web/lib/src/style/sources/source.dart b/maplibre_gl_web/lib/src/style/sources/source.dart index 2907f1fc7..40fa29239 100644 --- a/maplibre_gl_web/lib/src/style/sources/source.dart +++ b/maplibre_gl_web/lib/src/style/sources/source.dart @@ -1,5 +1,3 @@ -library maplibre.style.sources.source; - abstract class Source { final T jsObject; diff --git a/maplibre_gl_web/lib/src/style/sources/vector_source.dart b/maplibre_gl_web/lib/src/style/sources/vector_source.dart index 463b464a4..9f2d3d2c7 100644 --- a/maplibre_gl_web/lib/src/style/sources/vector_source.dart +++ b/maplibre_gl_web/lib/src/style/sources/vector_source.dart @@ -1,5 +1,3 @@ -library maplibre.style.sources.vector_source; - import 'package:maplibre_gl_web/src/interop/style/sources/vector_source_interop.dart'; import 'package:maplibre_gl_web/src/style/sources/source.dart'; diff --git a/maplibre_gl_web/lib/src/style/style.dart b/maplibre_gl_web/lib/src/style/style.dart index 2805ceaca..338393e0b 100644 --- a/maplibre_gl_web/lib/src/style/style.dart +++ b/maplibre_gl_web/lib/src/style/style.dart @@ -1,5 +1,3 @@ -library maplibre.style.style; - import 'package:maplibre_gl_web/src/interop/interop.dart'; import 'package:maplibre_gl_web/src/style/evaluation_parameters.dart'; import 'package:maplibre_gl_web/src/style/style_image.dart'; diff --git a/maplibre_gl_web/lib/src/style/style_image.dart b/maplibre_gl_web/lib/src/style/style_image.dart index 74977965f..05cb61f0d 100644 --- a/maplibre_gl_web/lib/src/style/style_image.dart +++ b/maplibre_gl_web/lib/src/style/style_image.dart @@ -1,5 +1,3 @@ -library maplibre.style.style_image; - import 'package:maplibre_gl_web/src/interop/interop.dart'; class StyleImage extends JsObjectWrapper { diff --git a/maplibre_gl_web/lib/src/ui/camera.dart b/maplibre_gl_web/lib/src/ui/camera.dart index ef72be799..e98beead4 100644 --- a/maplibre_gl_web/lib/src/ui/camera.dart +++ b/maplibre_gl_web/lib/src/ui/camera.dart @@ -1,5 +1,3 @@ -library maplibre.ui.camera; - import 'package:js/js_util.dart'; import 'package:maplibre_gl_web/src/geo/lng_lat.dart'; import 'package:maplibre_gl_web/src/geo/lng_lat_bounds.dart'; diff --git a/maplibre_gl_web/lib/src/ui/control/attribution_control.dart b/maplibre_gl_web/lib/src/ui/control/attribution_control.dart index 325fcb813..ec5935c91 100644 --- a/maplibre_gl_web/lib/src/ui/control/attribution_control.dart +++ b/maplibre_gl_web/lib/src/ui/control/attribution_control.dart @@ -1,5 +1,3 @@ -library maplibre.ui.control.attribution_control; - import 'package:maplibre_gl_web/src/interop/interop.dart'; import 'package:maplibre_gl_web/src/interop/ui/control/attribution_control_interop.dart'; import 'package:maplibre_gl_web/src/ui/map.dart'; diff --git a/maplibre_gl_web/lib/src/ui/control/geolocate_control.dart b/maplibre_gl_web/lib/src/ui/control/geolocate_control.dart index dc645d2a4..e7191e59f 100644 --- a/maplibre_gl_web/lib/src/ui/control/geolocate_control.dart +++ b/maplibre_gl_web/lib/src/ui/control/geolocate_control.dart @@ -1,5 +1,3 @@ -library maplibre.ui.control.geolocate_control; - import 'package:maplibre_gl_web/src/interop/interop.dart'; import 'package:maplibre_gl_web/src/ui/map.dart'; import 'package:maplibre_gl_web/src/util/evented.dart'; diff --git a/maplibre_gl_web/lib/src/ui/control/logo_control.dart b/maplibre_gl_web/lib/src/ui/control/logo_control.dart index b0b404ee0..dec72b870 100644 --- a/maplibre_gl_web/lib/src/ui/control/logo_control.dart +++ b/maplibre_gl_web/lib/src/ui/control/logo_control.dart @@ -1,5 +1,3 @@ -library maplibre.ui.control.logo_control; - import 'package:maplibre_gl_web/src/interop/interop.dart'; import 'package:maplibre_gl_web/src/ui/map.dart'; diff --git a/maplibre_gl_web/lib/src/ui/control/navigation_control.dart b/maplibre_gl_web/lib/src/ui/control/navigation_control.dart index fa9fb957f..b701d8ea6 100644 --- a/maplibre_gl_web/lib/src/ui/control/navigation_control.dart +++ b/maplibre_gl_web/lib/src/ui/control/navigation_control.dart @@ -1,5 +1,3 @@ -library maplibre.ui.control.navigation_control; - import 'package:maplibre_gl_web/src/interop/interop.dart'; import 'package:maplibre_gl_web/src/ui/map.dart'; diff --git a/maplibre_gl_web/lib/src/ui/events.dart b/maplibre_gl_web/lib/src/ui/events.dart index 621d56ef0..2622813c8 100644 --- a/maplibre_gl_web/lib/src/ui/events.dart +++ b/maplibre_gl_web/lib/src/ui/events.dart @@ -1,5 +1,3 @@ -library maplibre.ui.events; - import 'dart:html'; import 'package:maplibre_gl_web/src/geo/lng_lat.dart'; diff --git a/maplibre_gl_web/lib/src/ui/handler/box_zoom.dart b/maplibre_gl_web/lib/src/ui/handler/box_zoom.dart index 8beaec0be..e2112e90f 100644 --- a/maplibre_gl_web/lib/src/ui/handler/box_zoom.dart +++ b/maplibre_gl_web/lib/src/ui/handler/box_zoom.dart @@ -1,5 +1,3 @@ -library maplibre.ui.handler.box_zoom; - import 'dart:html'; import 'package:maplibre_gl_web/src/interop/interop.dart'; diff --git a/maplibre_gl_web/lib/src/ui/handler/dblclick_zoom.dart b/maplibre_gl_web/lib/src/ui/handler/dblclick_zoom.dart index b0e87d239..d8fd65e8f 100644 --- a/maplibre_gl_web/lib/src/ui/handler/dblclick_zoom.dart +++ b/maplibre_gl_web/lib/src/ui/handler/dblclick_zoom.dart @@ -1,5 +1,3 @@ -library maplibre.ui.handler.dbclick_zoom; - import 'package:maplibre_gl_web/src/interop/interop.dart'; import 'package:maplibre_gl_web/src/ui/events.dart'; diff --git a/maplibre_gl_web/lib/src/ui/handler/drag_pan.dart b/maplibre_gl_web/lib/src/ui/handler/drag_pan.dart index a67fdeddf..1366c146d 100644 --- a/maplibre_gl_web/lib/src/ui/handler/drag_pan.dart +++ b/maplibre_gl_web/lib/src/ui/handler/drag_pan.dart @@ -1,5 +1,3 @@ -library maplibre.ui.handler.drag_pan; - import 'dart:html'; import 'package:maplibre_gl_web/src/interop/interop.dart'; diff --git a/maplibre_gl_web/lib/src/ui/handler/drag_rotate.dart b/maplibre_gl_web/lib/src/ui/handler/drag_rotate.dart index c7adac83f..f936bc128 100644 --- a/maplibre_gl_web/lib/src/ui/handler/drag_rotate.dart +++ b/maplibre_gl_web/lib/src/ui/handler/drag_rotate.dart @@ -1,5 +1,3 @@ -library maplibre.ui.handler.drag_rotate; - import 'dart:html'; import 'package:maplibre_gl_web/src/interop/interop.dart'; diff --git a/maplibre_gl_web/lib/src/ui/handler/keyboard.dart b/maplibre_gl_web/lib/src/ui/handler/keyboard.dart index ed4b02eec..2f709a641 100644 --- a/maplibre_gl_web/lib/src/ui/handler/keyboard.dart +++ b/maplibre_gl_web/lib/src/ui/handler/keyboard.dart @@ -1,5 +1,3 @@ -library maplibre.ui.handler.keyboard; - import 'package:maplibre_gl_web/src/interop/interop.dart'; class KeyboardHandler extends JsObjectWrapper { diff --git a/maplibre_gl_web/lib/src/ui/handler/scroll_zoom.dart b/maplibre_gl_web/lib/src/ui/handler/scroll_zoom.dart index 95f2ebb02..53ac7453a 100644 --- a/maplibre_gl_web/lib/src/ui/handler/scroll_zoom.dart +++ b/maplibre_gl_web/lib/src/ui/handler/scroll_zoom.dart @@ -1,5 +1,3 @@ -library maplibre.ui.handler.scroll_zoom; - import 'dart:html'; import 'package:maplibre_gl_web/src/interop/interop.dart'; diff --git a/maplibre_gl_web/lib/src/ui/handler/touch_zoom_rotate.dart b/maplibre_gl_web/lib/src/ui/handler/touch_zoom_rotate.dart index 9ba5a74e1..8380c6cba 100644 --- a/maplibre_gl_web/lib/src/ui/handler/touch_zoom_rotate.dart +++ b/maplibre_gl_web/lib/src/ui/handler/touch_zoom_rotate.dart @@ -1,5 +1,3 @@ -library maplibre.ui.handler.touch_zoom_rotate; - import 'dart:html'; import 'package:maplibre_gl_web/src/interop/interop.dart'; diff --git a/maplibre_gl_web/lib/src/ui/map.dart b/maplibre_gl_web/lib/src/ui/map.dart index f8eba1bae..5e66e7359 100644 --- a/maplibre_gl_web/lib/src/ui/map.dart +++ b/maplibre_gl_web/lib/src/ui/map.dart @@ -1,5 +1,3 @@ -library maplibre.ui.map; - import 'dart:html'; import 'package:js/js_util.dart'; import 'package:maplibre_gl_web/src/geo/geojson.dart'; diff --git a/maplibre_gl_web/lib/src/ui/marker.dart b/maplibre_gl_web/lib/src/ui/marker.dart index 57e1b9c28..8359ea7eb 100644 --- a/maplibre_gl_web/lib/src/ui/marker.dart +++ b/maplibre_gl_web/lib/src/ui/marker.dart @@ -1,5 +1,3 @@ -library maplibre.ui.marker; - import 'dart:html'; import 'package:maplibre_gl_web/src/geo/lng_lat.dart'; import 'package:maplibre_gl_web/src/interop/interop.dart'; diff --git a/maplibre_gl_web/lib/src/ui/popup.dart b/maplibre_gl_web/lib/src/ui/popup.dart index 14f895679..2777ea130 100644 --- a/maplibre_gl_web/lib/src/ui/popup.dart +++ b/maplibre_gl_web/lib/src/ui/popup.dart @@ -1,5 +1,3 @@ -library maplibre.ui.popup; - import 'dart:html'; import 'package:maplibre_gl_web/src/geo/lng_lat.dart'; import 'package:maplibre_gl_web/src/interop/interop.dart'; diff --git a/maplibre_gl_web/lib/src/util/evented.dart b/maplibre_gl_web/lib/src/util/evented.dart index 4c7d4f0f2..395fe7176 100644 --- a/maplibre_gl_web/lib/src/util/evented.dart +++ b/maplibre_gl_web/lib/src/util/evented.dart @@ -1,5 +1,3 @@ -library maplibre.util.evented; - import 'dart:js'; import 'package:maplibre_gl_web/src/geo/geojson.dart'; From 00c1d3eac215adafa529942cd519c11131d9330b Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 01:10:58 +0200 Subject: [PATCH 24/36] prefer_asserts_with_message --- CHANGELOG.md | 2 ++ analysis_options.yaml | 1 - example/lib/annotation_order_maps.dart | 8 ++++---- example/lib/click_annotations.dart | 4 ++-- example/lib/get_map_informations.dart | 2 +- example/lib/layer.dart | 2 +- example/lib/place_batch.dart | 4 ++-- lib/src/maplibre_map.dart | 18 ++++++++++-------- .../lib/src/location.dart | 6 +++++- maplibre_gl_platform_interface/lib/src/ui.dart | 5 ++++- 10 files changed, 31 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 819f15863..0508d2c61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ * Renamed `Maplibre` to `MapLibre` to be in line with maplibre-native (affects for example the classes MaplibreMap and MaplibreMapController). * Remove the parameter `hash` from `MapOptions` because it was not used. +* The parameter type of `annotationOrder` and `annotationConsumeTapEvents` from + `MapLibreMap` has changed to a Set. ### Changes diff --git a/analysis_options.yaml b/analysis_options.yaml index fb482fdd3..589b8f9ac 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -24,7 +24,6 @@ linter: parameter_assignments: false use_setters_to_change_properties: false type_annotate_public_apis: false - prefer_asserts_with_message: false public_member_api_docs: false require_trailing_commas: false avoid_dynamic_calls: false diff --git a/example/lib/annotation_order_maps.dart b/example/lib/annotation_order_maps.dart index 9c00557a4..d604cae40 100644 --- a/example/lib/annotation_order_maps.dart +++ b/example/lib/annotation_order_maps.dart @@ -51,12 +51,12 @@ class _AnnotationOrderBodyState extends State { target: center, zoom: 5.0, ), - annotationOrder: const [ + annotationOrder: const { AnnotationType.line, AnnotationType.symbol, AnnotationType.circle, AnnotationType.fill, - ], + }, ), ), ), @@ -85,12 +85,12 @@ class _AnnotationOrderBodyState extends State { target: center, zoom: 5.0, ), - annotationOrder: const [ + annotationOrder: const { AnnotationType.fill, AnnotationType.line, AnnotationType.symbol, AnnotationType.circle, - ], + }, ), ), ), diff --git a/example/lib/click_annotations.dart b/example/lib/click_annotations.dart index 10f7f7690..1269cfc40 100644 --- a/example/lib/click_annotations.dart +++ b/example/lib/click_annotations.dart @@ -140,12 +140,12 @@ class ClickAnnotationBodyState extends State { @override Widget build(BuildContext context) { return MapLibreMap( - annotationOrder: const [ + annotationOrder: const { AnnotationType.fill, AnnotationType.line, AnnotationType.circle, AnnotationType.symbol, - ], + }, onMapCreated: _onMapCreated, onStyleLoadedCallback: _onStyleLoaded, initialCameraPosition: const CameraPosition( diff --git a/example/lib/get_map_informations.dart b/example/lib/get_map_informations.dart index fcbe67ddc..c9a0fc228 100644 --- a/example/lib/get_map_informations.dart +++ b/example/lib/get_map_informations.dart @@ -67,7 +67,7 @@ class _GetMapInfoBodyState extends State { ), onMapCreated: onMapCreated, compassEnabled: false, - annotationOrder: const [], + annotationOrder: const {}, myLocationEnabled: false, styleString: '''{ "version": 8, diff --git a/example/lib/layer.dart b/example/lib/layer.dart index 50df8ec1d..4de44b67e 100644 --- a/example/lib/layer.dart +++ b/example/lib/layer.dart @@ -54,7 +54,7 @@ class LayerState extends State { target: center, zoom: 11.0, ), - annotationOrder: const [], + annotationOrder: const {}, )), ), TextButton( diff --git a/example/lib/place_batch.dart b/example/lib/place_batch.dart index 9e2fbfd6a..1356c69ee 100644 --- a/example/lib/place_batch.dart +++ b/example/lib/place_batch.dart @@ -156,12 +156,12 @@ class BatchAddBodyState extends State { target: LatLng(-33.8, 151.511), zoom: 8.2, ), - annotationOrder: const [ + annotationOrder: const { AnnotationType.fill, AnnotationType.line, AnnotationType.circle, AnnotationType.symbol, - ], + }, ), ), ), diff --git a/lib/src/maplibre_map.dart b/lib/src/maplibre_map.dart index de6716d5b..ed2b1a320 100644 --- a/lib/src/maplibre_map.dart +++ b/lib/src/maplibre_map.dart @@ -47,25 +47,27 @@ class MapLibreMap extends StatefulWidget { this.onCameraTrackingChanged, this.onCameraIdle, this.onMapIdle, - this.annotationOrder = const [ + this.annotationOrder = const { AnnotationType.line, AnnotationType.symbol, AnnotationType.circle, AnnotationType.fill, - ], - this.annotationConsumeTapEvents = const [ +}, + this.annotationConsumeTapEvents = const { AnnotationType.symbol, AnnotationType.fill, AnnotationType.line, AnnotationType.circle, - ], + }, }) : assert( myLocationRenderMode == MyLocationRenderMode.normal || myLocationEnabled, "$myLocationRenderMode requires [myLocationEnabled] set to true.", ), - assert(annotationOrder.length <= 4), - assert(annotationConsumeTapEvents.length > 0); + assert( + annotationConsumeTapEvents.length > 0, + 'annotationConsumeTapEvents must contain at least 1 annotation type', + ); /// Defines the layer order of annotations displayed on map /// @@ -73,12 +75,12 @@ class MapLibreMap extends StatefulWidget { /// /// Note that setting this to be empty gives a big perfomance boost for /// android. However if you do so annotations will not work. - final List annotationOrder; + final Set annotationOrder; /// Defines the layer order of click annotations /// /// (must contain at least 1 annotation type, 4 items max) - final List annotationConsumeTapEvents; + final Set annotationConsumeTapEvents; /// Please note: you should only add annotations (e.g. symbols or circles) after `onStyleLoadedCallback` has been called. final MapCreatedCallback? onMapCreated; diff --git a/maplibre_gl_platform_interface/lib/src/location.dart b/maplibre_gl_platform_interface/lib/src/location.dart index d8b540aa9..60baa092d 100644 --- a/maplibre_gl_platform_interface/lib/src/location.dart +++ b/maplibre_gl_platform_interface/lib/src/location.dart @@ -72,7 +72,11 @@ class LatLngBounds { /// The latitude of the southwest corner cannot be larger than the /// latitude of the northeast corner. LatLngBounds({required this.southwest, required this.northeast}) - : assert(southwest.latitude <= northeast.latitude); + : assert( + southwest.latitude <= northeast.latitude, + 'The latitude of the southwest corner cannot be larger than the ' + 'latitude of the northeast corner.', + ); /// The southwest corner of the rectangle. final LatLng southwest; diff --git a/maplibre_gl_platform_interface/lib/src/ui.dart b/maplibre_gl_platform_interface/lib/src/ui.dart index abeebfc98..5b7a964dc 100644 --- a/maplibre_gl_platform_interface/lib/src/ui.dart +++ b/maplibre_gl_platform_interface/lib/src/ui.dart @@ -83,7 +83,10 @@ class CameraTargetBounds { @immutable class MinMaxZoomPreference { const MinMaxZoomPreference(this.minZoom, this.maxZoom) - : assert(minZoom == null || maxZoom == null || minZoom <= maxZoom); + : assert( + minZoom == null || maxZoom == null || minZoom <= maxZoom, + 'minZoom cannot be larger than maxZoom.', + ); /// The preferred minimum zoom level or null, if unbounded from below. final double? minZoom; From d0c9dce3a303465b4b9209689ce28208de5a6505 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 01:14:28 +0200 Subject: [PATCH 25/36] avoid_void_async --- analysis_options.yaml | 1 - example/lib/annotation_order_maps.dart | 2 +- example/lib/click_annotations.dart | 2 +- example/lib/get_map_informations.dart | 4 ++-- example/lib/layer.dart | 2 +- example/lib/main.dart | 2 +- example/lib/offline_regions.dart | 6 +++--- example/lib/place_batch.dart | 2 +- example/lib/place_circle.dart | 2 +- example/lib/place_symbol.dart | 4 ++-- example/lib/scrolling_map.dart | 2 +- lib/src/maplibre_map.dart | 4 ++-- maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart | 2 +- 13 files changed, 17 insertions(+), 18 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 589b8f9ac..8b74a980b 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -27,7 +27,6 @@ linter: public_member_api_docs: false require_trailing_commas: false avoid_dynamic_calls: false - avoid_void_async: false always_use_package_imports: false prefer_single_quotes: false always_declare_return_types: false diff --git a/example/lib/annotation_order_maps.dart b/example/lib/annotation_order_maps.dart index d604cae40..577a4072d 100644 --- a/example/lib/annotation_order_maps.dart +++ b/example/lib/annotation_order_maps.dart @@ -110,7 +110,7 @@ class _AnnotationOrderBodyState extends State { controllerTwo = controller; } - void onStyleLoaded(MapLibreMapController controller) async { + Future onStyleLoaded(MapLibreMapController controller) async { await addImageFromAsset( controller, "custom-marker", "assets/symbols/custom-marker.png"); controller.addSymbol( diff --git a/example/lib/click_annotations.dart b/example/lib/click_annotations.dart index 1269cfc40..822f18937 100644 --- a/example/lib/click_annotations.dart +++ b/example/lib/click_annotations.dart @@ -79,7 +79,7 @@ class ClickAnnotationBodyState extends State { _showSnackBar('symbol', symbol.id); } - void _onStyleLoaded() async { + Future _onStyleLoaded() async { await addImageFromAsset( controller!, "custom-marker", "assets/symbols/custom-marker.png"); controller!.addCircle( diff --git a/example/lib/get_map_informations.dart b/example/lib/get_map_informations.dart index c9a0fc228..892ff99ba 100644 --- a/example/lib/get_map_informations.dart +++ b/example/lib/get_map_informations.dart @@ -30,7 +30,7 @@ class _GetMapInfoBodyState extends State { }); } - void displaySources() async { + Future displaySources() async { if (controller == null) { return; } @@ -40,7 +40,7 @@ class _GetMapInfoBodyState extends State { }); } - void displayLayers() async { + Future displayLayers() async { if (controller == null) { return; } diff --git a/example/lib/layer.dart b/example/lib/layer.dart index 4de44b67e..9d39d38fc 100644 --- a/example/lib/layer.dart +++ b/example/lib/layer.dart @@ -157,7 +157,7 @@ class LayerState extends State { ScaffoldMessenger.of(context).showSnackBar(snackBar); } - void _onStyleLoadedCallback() async { + Future _onStyleLoadedCallback() async { await addImageFromAsset( controller, "custom-marker", "assets/symbols/custom-marker.png"); await controller.addGeoJsonSource("points", _points); diff --git a/example/lib/main.dart b/example/lib/main.dart index c54460f31..57d7e598f 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -85,7 +85,7 @@ class _MapsDemoState extends State { } } - void _pushPage(BuildContext context, ExamplePage page) async { + Future _pushPage(BuildContext context, ExamplePage page) async { if (!kIsWeb && page.needsLocationPermission) { final location = Location(); final hasPermissions = await location.hasPermission(); diff --git a/example/lib/offline_regions.dart b/example/lib/offline_regions.dart index d58c6d738..e39054349 100644 --- a/example/lib/offline_regions.dart +++ b/example/lib/offline_regions.dart @@ -181,7 +181,7 @@ class _OfflineRegionsBodyState extends State { ); } - void _updateListOfRegions() async { + Future _updateListOfRegions() async { List offlineRegions = await getListOfRegions(); List regionItems = []; for (var item in allRegions) { @@ -199,7 +199,7 @@ class _OfflineRegionsBodyState extends State { }); } - void _downloadRegion(OfflineRegionListItem item, int index) async { + Future _downloadRegion(OfflineRegionListItem item, int index) async { setState(() { _items.removeAt(index); _items.insert(index, item.copyWith(isDownloading: true)); @@ -235,7 +235,7 @@ class _OfflineRegionsBodyState extends State { } } - void _deleteRegion(OfflineRegionListItem item, int index) async { + Future _deleteRegion(OfflineRegionListItem item, int index) async { setState(() { _items.removeAt(index); _items.insert(index, item.copyWith(isDownloading: true)); diff --git a/example/lib/place_batch.dart b/example/lib/place_batch.dart index 1356c69ee..0e27c96eb 100644 --- a/example/lib/place_batch.dart +++ b/example/lib/place_batch.dart @@ -116,7 +116,7 @@ class BatchAddBodyState extends State { return symbolOptions; } - void _add() async { + Future _add() async { if (_fills.isEmpty) { _fills = await controller.addFills(fillOptions); _lines = await controller diff --git a/example/lib/place_circle.dart b/example/lib/place_circle.dart index 2a7a32625..4de2d73ad 100644 --- a/example/lib/place_circle.dart +++ b/example/lib/place_circle.dart @@ -115,7 +115,7 @@ class PlaceCircleBodyState extends State { ); } - void _getLatLng() async { + Future _getLatLng() async { LatLng latLng = await controller!.getCircleLatLng(_selectedCircle!); if (!mounted) return; diff --git a/example/lib/place_symbol.dart b/example/lib/place_symbol.dart index 530e60a4a..d21b7da6e 100644 --- a/example/lib/place_symbol.dart +++ b/example/lib/place_symbol.dart @@ -85,7 +85,7 @@ class PlaceSymbolBodyState extends State { ); } - void _updateSelectedSymbol(SymbolOptions changes) async { + Future _updateSelectedSymbol(SymbolOptions changes) async { await controller!.updateSymbol(_selectedSymbol!, changes); } @@ -245,7 +245,7 @@ class PlaceSymbolBodyState extends State { ); } - void _getLatLng() async { + Future _getLatLng() async { final latLng = await controller!.getSymbolLatLng(_selectedSymbol!); if (!mounted) return; diff --git a/example/lib/scrolling_map.dart b/example/lib/scrolling_map.dart index d173412e5..d5abf4df7 100644 --- a/example/lib/scrolling_map.dart +++ b/example/lib/scrolling_map.dart @@ -118,7 +118,7 @@ class _ScrollingMapBodyState extends State { controllerTwo = controller; } - void onStyleLoaded(MapLibreMapController controller) async { + Future onStyleLoaded(MapLibreMapController controller) async { await addImageFromAsset( controller, "custom-marker", "assets/symbols/custom-marker.png"); controller.addSymbol(SymbolOptions( diff --git a/lib/src/maplibre_map.dart b/lib/src/maplibre_map.dart index ed2b1a320..03b338adf 100644 --- a/lib/src/maplibre_map.dart +++ b/lib/src/maplibre_map.dart @@ -283,7 +283,7 @@ class _MapLibreMapState extends State { } @override - void dispose() async { + Future dispose() async { super.dispose(); if (_controller.isCompleted) { final controller = await _controller.future; @@ -302,7 +302,7 @@ class _MapLibreMapState extends State { _maplibreMapOptions = newOptions; } - void _updateOptions(Map updates) async { + Future _updateOptions(Map updates) async { if (updates.isEmpty) { return; } diff --git a/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart b/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart index 554e5ba39..f36c838ad 100644 --- a/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart +++ b/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart @@ -104,7 +104,7 @@ class MapLibreMapController extends MapLibrePlatform resizeObserver.observe(html.document.body!); } - void _loadFromAssets(Event event) async { + Future _loadFromAssets(Event event) async { final imagePath = event.id; final ByteData bytes = await rootBundle.load(imagePath); await addImage(imagePath, bytes.buffer.asUint8List()); From 5b3e4a9c74374a726de11bad88774b8074691bb4 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 01:21:34 +0200 Subject: [PATCH 26/36] prefer_final_fields --- analysis_options.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 8b74a980b..108c28004 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -33,7 +33,6 @@ linter: sort_constructors_first: false avoid_relative_lib_imports: false avoid_positional_boolean_parameters: false - prefer_final_fields: false prefer_final_locals: false prefer_final_in_for_each: false implicit_call_tearoffs: false From 21e8ca0cf8ff4b8f9dccb1b98e83081822bc1a96 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 01:26:12 +0200 Subject: [PATCH 27/36] prefer_final_locals --- analysis_options.yaml | 1 - example/lib/custom_marker.dart | 12 +++--- example/lib/get_map_informations.dart | 4 +- example/lib/line.dart | 4 +- example/lib/local_style.dart | 8 ++-- example/lib/map_ui.dart | 20 ++++----- example/lib/offline_regions.dart | 4 +- example/lib/place_circle.dart | 2 +- example/lib/place_fill.dart | 4 +- example/lib/place_symbol.dart | 8 ++-- lib/src/global.dart | 12 +++--- .../lib/src/fill.dart | 4 +- .../lib/src/method_channel_maplibre_gl.dart | 14 +++---- maplibre_gl_web/lib/src/convert.dart | 16 +++---- .../style/layers/circle_layer_interop.dart | 4 +- .../style/layers/line_layer_interop.dart | 6 +-- .../style/layers/symbol_layer_interop.dart | 6 +-- .../lib/src/maplibre_web_gl_platform.dart | 42 +++++++++---------- .../lib/src/style/sources/vector_source.dart | 2 +- maplibre_gl_web/lib/src/ui/map.dart | 2 +- maplibre_gl_web/lib/src/utils.dart | 4 +- scripts/lib/generate.dart | 8 ++-- 22 files changed, 93 insertions(+), 94 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 108c28004..73fa06b04 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -33,7 +33,6 @@ linter: sort_constructors_first: false avoid_relative_lib_imports: false avoid_positional_boolean_parameters: false - prefer_final_locals: false prefer_final_in_for_each: false implicit_call_tearoffs: false comment_references: false diff --git a/example/lib/custom_marker.dart b/example/lib/custom_marker.dart index e202f1711..80363544e 100644 --- a/example/lib/custom_marker.dart +++ b/example/lib/custom_marker.dart @@ -111,7 +111,7 @@ class CustomMarkerState extends State { //_measurePerformance(); // Generate random markers - var param = []; + final param = []; for (var i = 0; i < randomMarkerNum; i++) { final lat = _rnd.nextDouble() * 20 + 30; final lng = _rnd.nextDouble() * 20 + 125; @@ -120,7 +120,7 @@ class CustomMarkerState extends State { _mapController.toScreenLocationBatch(param).then((value) { for (var i = 0; i < randomMarkerNum; i++) { - var point = + final point = Point(value[i].x as double, value[i].y as double); _addMarker(point, param[i]); } @@ -141,7 +141,7 @@ class CustomMarkerState extends State { } _mapController.toScreenLocation(const LatLng(0, 0)); - Stopwatch sw = Stopwatch(); + final Stopwatch sw = Stopwatch(); for (final batch in batches) { // @@ -149,9 +149,9 @@ class CustomMarkerState extends State { // for (var i = 0; i < trial; i++) { sw.start(); - var list = >>[]; + final list = >>[]; for (var j = 0; j < batch; j++) { - var p = _mapController + final p = _mapController .toScreenLocation(LatLng(j.toDouble() % 80, j.toDouble() % 300)); list.add(p); } @@ -166,7 +166,7 @@ class CustomMarkerState extends State { // for (var i = 0; i < trial; i++) { sw.start(); - var param = []; + final param = []; for (var j = 0; j < batch; j++) { param.add(LatLng(j.toDouble() % 80, j.toDouble() % 300)); } diff --git a/example/lib/get_map_informations.dart b/example/lib/get_map_informations.dart index 892ff99ba..7c0267baa 100644 --- a/example/lib/get_map_informations.dart +++ b/example/lib/get_map_informations.dart @@ -34,7 +34,7 @@ class _GetMapInfoBodyState extends State { if (controller == null) { return; } - List sources = await controller!.getSourceIds(); + final List sources = await controller!.getSourceIds(); setState(() { data = 'Sources: ${sources.map((e) => '"$e"').join(', ')}'; }); @@ -44,7 +44,7 @@ class _GetMapInfoBodyState extends State { if (controller == null) { return; } - List layers = (await controller!.getLayerIds()).cast(); + final List layers = (await controller!.getLayerIds()).cast(); setState(() { data = 'Layers: ${layers.map((e) => '"$e"').join(', ')}'; }); diff --git a/example/lib/line.dart b/example/lib/line.dart index b287441b3..24b8aaadb 100644 --- a/example/lib/line.dart +++ b/example/lib/line.dart @@ -109,7 +109,7 @@ class LineBodyState extends State { } Future _changeLinePattern() async { - String? current = + final String? current = _selectedLine!.options.linePattern == null ? "assetImage" : null; await _updateSelectedLine( LineOptions(linePattern: current), @@ -213,7 +213,7 @@ class LineBodyState extends State { onPressed: (_selectedLine == null) ? null : () async { - var latLngs = await controller! + final latLngs = await controller! .getLineLatLngs(_selectedLine!); for (var latLng in latLngs) { debugPrint(latLng.toString()); diff --git a/example/lib/local_style.dart b/example/lib/local_style.dart index 0ad4a84f1..eb12f2761 100644 --- a/example/lib/local_style.dart +++ b/example/lib/local_style.dart @@ -32,14 +32,14 @@ class LocalStyleState extends State { super.initState(); getApplicationDocumentsDirectory().then((dir) async { - String documentDir = dir.path; - String stylesDir = '$documentDir/styles'; - String styleJSON = + final String documentDir = dir.path; + final String stylesDir = '$documentDir/styles'; + const String styleJSON = '{"version":8,"name":"Demo style","center":[50,10],"zoom":4,"sources":{"demotiles":{"type":"vector","url":"https://demotiles.maplibre.org/tiles/tiles.json"}},"sprite":"","glyphs":"https://orangemug.github.io/font-glyphs/glyphs/{fontstack}/{range}.pbf","layers":[{"id":"background","type":"background","paint":{"background-color":"rgba(255, 255, 255, 1)"}},{"id":"countries","type":"line","source":"demotiles","source-layer":"countries","paint":{"line-color":"rgba(0, 0, 0, 1)","line-width":1,"line-opacity":1}}]}'; await Directory(stylesDir).create(recursive: true); - File styleFile = File('$stylesDir/style.json'); + final File styleFile = File('$stylesDir/style.json'); await styleFile.writeAsString(styleJSON); diff --git a/example/lib/map_ui.dart b/example/lib/map_ui.dart index 12b78d79e..ff6883586 100644 --- a/example/lib/map_ui.dart +++ b/example/lib/map_ui.dart @@ -278,7 +278,7 @@ class MapUiBodyState extends State { return TextButton( child: const Text('get currently visible region'), onPressed: () async { - var result = await mapController!.getVisibleRegion(); + final result = await mapController!.getVisibleRegion(); if (!mounted) return; ScaffoldMessenger.of(context).showSnackBar(SnackBar( @@ -293,7 +293,7 @@ class MapUiBodyState extends State { return TextButton( child: const Text('get source features (maplibre)'), onPressed: () async { - var result = await mapController! + final result = await mapController! .querySourceFeatures("maplibre", "centroids", null); debugPrint(result.toString()); }, @@ -320,16 +320,16 @@ class MapUiBodyState extends State { } _drawFill(List features) async { - Map? feature = + final Map? feature = features.firstWhereOrNull((f) => f['geometry']['type'] == 'Polygon'); if (feature != null) { - List> geometry = feature['geometry']['coordinates'] + final List> geometry = feature['geometry']['coordinates'] .map( (ll) => ll.map((l) => LatLng(l[1], l[0])).toList().cast()) .toList() .cast>(); - Fill fill = await mapController!.addFill(FillOptions( + final Fill fill = await mapController!.addFill(FillOptions( geometry: geometry, fillColor: "#FF0000", fillOutlineColor: "#FF0000", @@ -363,7 +363,7 @@ class MapUiBodyState extends State { debugPrint( "Map click: ${point.x},${point.y} ${latLng.latitude}/${latLng.longitude}"); debugPrint("Filter $_featureQueryFilter"); - List features = await mapController! + final List features = await mapController! .queryRenderedFeatures(point, [], _featureQueryFilter); if (!mounted) return; @@ -381,17 +381,17 @@ class MapUiBodyState extends State { onMapLongClick: (point, latLng) async { debugPrint( "Map long press: ${point.x},${point.y} ${latLng.latitude}/${latLng.longitude}"); - Point convertedPoint = await mapController!.toScreenLocation(latLng); - LatLng convertedLatLng = await mapController!.toLatLng(point); + final Point convertedPoint = await mapController!.toScreenLocation(latLng); + final LatLng convertedLatLng = await mapController!.toLatLng(point); debugPrint( "Map long press converted: ${convertedPoint.x},${convertedPoint.y} ${convertedLatLng.latitude}/${convertedLatLng.longitude}"); - double metersPerPixel = + final double metersPerPixel = await mapController!.getMetersPerPixelAtLatitude(latLng.latitude); debugPrint( "Map long press The distance measured in meters at latitude ${latLng.latitude} is $metersPerPixel m"); - List features = + final List features = await mapController!.queryRenderedFeatures(point, [], null); if (features.isNotEmpty) { debugPrint(features[0]); diff --git a/example/lib/offline_regions.dart b/example/lib/offline_regions.dart index e39054349..2c52ade50 100644 --- a/example/lib/offline_regions.dart +++ b/example/lib/offline_regions.dart @@ -182,8 +182,8 @@ class _OfflineRegionsBodyState extends State { } Future _updateListOfRegions() async { - List offlineRegions = await getListOfRegions(); - List regionItems = []; + final List offlineRegions = await getListOfRegions(); + final List regionItems = []; for (var item in allRegions) { final offlineRegion = offlineRegions.firstWhereOrNull( (offlineRegion) => offlineRegion.metadata['name'] == item.name); diff --git a/example/lib/place_circle.dart b/example/lib/place_circle.dart index 4de2d73ad..4dbadd98f 100644 --- a/example/lib/place_circle.dart +++ b/example/lib/place_circle.dart @@ -116,7 +116,7 @@ class PlaceCircleBodyState extends State { } Future _getLatLng() async { - LatLng latLng = await controller!.getCircleLatLng(_selectedCircle!); + final LatLng latLng = await controller!.getCircleLatLng(_selectedCircle!); if (!mounted) return; ScaffoldMessenger.of(context).showSnackBar( diff --git a/example/lib/place_fill.dart b/example/lib/place_fill.dart index cc3e830de..45de41321 100644 --- a/example/lib/place_fill.dart +++ b/example/lib/place_fill.dart @@ -65,7 +65,7 @@ class PlaceFillBodyState extends State { required origin, required point, required eventType}) { - DragEventType type = eventType; + final DragEventType type = eventType; switch (type) { case DragEventType.start: // TODO: Handle this case. @@ -177,7 +177,7 @@ class PlaceFillBodyState extends State { } Future _changeFillPattern() async { - String? current = + final String? current = _selectedFill!.options.fillPattern == null ? "assetImage" : null; _updateSelectedFill( FillOptions(fillPattern: current), diff --git a/example/lib/place_symbol.dart b/example/lib/place_symbol.dart index d21b7da6e..2dae481b4 100644 --- a/example/lib/place_symbol.dart +++ b/example/lib/place_symbol.dart @@ -67,7 +67,7 @@ class PlaceSymbolBodyState extends State { /// Adds a network image to the currently displayed style Future addImageFromUrl(String name, Uri uri) async { - var response = await http.get(uri); + final response = await http.get(uri); return controller!.addImage(name, response.bodyBytes); } @@ -90,7 +90,7 @@ class PlaceSymbolBodyState extends State { } void _add(String iconImage) { - List availableNumbers = Iterable.generate(12).toList(); + final List availableNumbers = Iterable.generate(12).toList(); for (var s in controller!.symbols) { availableNumbers.removeWhere((i) => i == s.data!['count']); } @@ -105,7 +105,7 @@ class PlaceSymbolBodyState extends State { } SymbolOptions _getSymbolOptions(String iconImage, int symbolCount) { - LatLng geometry = LatLng( + final LatLng geometry = LatLng( center.latitude + sin(symbolCount * pi / 6.0) / 20.0, center.longitude + cos(symbolCount * pi / 6.0) / 20.0, ); @@ -133,7 +133,7 @@ class PlaceSymbolBodyState extends State { } Future _addAll(String iconImage) async { - List symbolsToAddNumbers = Iterable.generate(12).toList(); + final List symbolsToAddNumbers = Iterable.generate(12).toList(); for (var s in controller!.symbols) { symbolsToAddNumbers.removeWhere((i) => i == s.data!['count']); } diff --git a/lib/src/global.dart b/lib/src/global.dart index 8c628e1c4..6530455bb 100644 --- a/lib/src/global.dart +++ b/lib/src/global.dart @@ -37,22 +37,22 @@ Future setHttpHeaders(Map headers) { } Future> mergeOfflineRegions(String path) async { - String regionsJson = await _globalChannel.invokeMethod( + final String regionsJson = await _globalChannel.invokeMethod( 'mergeOfflineRegions', { 'path': path, }, ); - Iterable regions = json.decode(regionsJson); + final Iterable regions = json.decode(regionsJson); return regions.map((region) => OfflineRegion.fromMap(region)).toList(); } Future> getListOfRegions() async { - String regionsJson = await _globalChannel.invokeMethod( + final String regionsJson = await _globalChannel.invokeMethod( 'getListOfRegions', {}, ); - Iterable regions = json.decode(regionsJson); + final Iterable regions = json.decode(regionsJson); return regions.map((region) => OfflineRegion.fromMap(region)).toList(); } @@ -90,7 +90,7 @@ Future downloadOfflineRegion(OfflineRegionDefinition definition, Map metadata = const {}, Function(DownloadRegionStatus event)? onEvent, }) async { - String channelName = + final String channelName = 'downloadOfflineRegion_${DateTime .now() .microsecondsSinceEpoch}'; @@ -106,7 +106,7 @@ Future downloadOfflineRegion(OfflineRegionDefinition definition, onEvent(Error(error)); return Error(error); } - var unknownError = Error( + final unknownError = Error( PlatformException( code: 'UnknowException', message: diff --git a/maplibre_gl_platform_interface/lib/src/fill.dart b/maplibre_gl_platform_interface/lib/src/fill.dart index b19f5d2c2..9b93c7c41 100644 --- a/maplibre_gl_platform_interface/lib/src/fill.dart +++ b/maplibre_gl_platform_interface/lib/src/fill.dart @@ -8,9 +8,9 @@ part of '../maplibre_gl_platform_interface.dart'; FillOptions translateFillOptions(FillOptions options, LatLng delta) { if (options.geometry != null) { - List> newGeometry = []; + final List> newGeometry = []; for (var ring in options.geometry!) { - List newRing = []; + final List newRing = []; for (var coords in ring) { newRing.add(coords + delta); } diff --git a/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart b/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart index 593681694..8daf42256 100644 --- a/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart +++ b/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart @@ -406,7 +406,7 @@ class MapLibreMethodChannel extends MapLibrePlatform { @override Future toScreenLocation(LatLng latLng) async { try { - var screenPosMap = + final screenPosMap = await _channel.invokeMethod('map#toScreenLocation', { 'latitude': latLng.latitude, 'longitude': latLng.longitude, @@ -420,14 +420,14 @@ class MapLibreMethodChannel extends MapLibrePlatform { @override Future> toScreenLocationBatch(Iterable latLngs) async { try { - var coordinates = Float64List.fromList(latLngs + final coordinates = Float64List.fromList(latLngs .map((e) => [e.latitude, e.longitude]) .expand((e) => e) .toList()); - Float64List result = await _channel.invokeMethod( + final Float64List result = await _channel.invokeMethod( 'map#toScreenLocationBatch', {"coordinates": coordinates}); - var points = []; + final points = []; for (int i = 0; i < result.length; i += 2) { points.add(Point(result[i], result[i + 1])); } @@ -505,7 +505,7 @@ class MapLibreMethodChannel extends MapLibrePlatform { @override Future getFilter(String layerId) async { try { - Map reply = + final Map reply = await _channel.invokeMethod('style#getFilter', { 'layerId': layerId, }); @@ -519,7 +519,7 @@ class MapLibreMethodChannel extends MapLibrePlatform { @override Future toLatLng(Point screenLocation) async { try { - var latLngMap = + final latLngMap = await _channel.invokeMethod('map#toLatLng', { 'x': screenLocation.x, 'y': screenLocation.y, @@ -533,7 +533,7 @@ class MapLibreMethodChannel extends MapLibrePlatform { @override Future getMetersPerPixelAtLatitude(double latitude) async { try { - var latLngMap = await _channel + final latLngMap = await _channel .invokeMethod('map#getMetersPerPixelAtLatitude', { 'latitude': latitude, }); diff --git a/maplibre_gl_web/lib/src/convert.dart b/maplibre_gl_web/lib/src/convert.dart index 65a62bfa0..082fcec40 100644 --- a/maplibre_gl_web/lib/src/convert.dart +++ b/maplibre_gl_web/lib/src/convert.dart @@ -203,7 +203,7 @@ class Convert { static Feature interpretSymbolOptions( SymbolOptions options, Feature feature) { - var properties = feature.properties; + final properties = feature.properties; var geometry = feature.geometry; if (options.iconSize != null) { properties['iconSize'] = options.iconSize; @@ -299,7 +299,7 @@ class Convert { } static Feature interpretLineOptions(LineOptions options, Feature feature) { - var properties = feature.properties; + final properties = feature.properties; var geometry = feature.geometry; if (options.lineJoin != null) { properties['lineJoin'] = options.lineJoin; @@ -341,7 +341,7 @@ class Convert { static Feature interpretCircleOptions( CircleOptions options, Feature feature) { - var properties = feature.properties; + final properties = feature.properties; var geometry = feature.geometry; if (options.circleRadius != null) { properties['circleRadius'] = options.circleRadius; @@ -378,9 +378,9 @@ class Convert { static List>> fillGeometryToFeatureGeometry( List> geom) { - List>> convertedFill = []; + final List>> convertedFill = []; for (final ring in geom) { - List> convertedRing = []; + final List> convertedRing = []; for (final coords in ring) { convertedRing.add([coords.longitude, coords.latitude]); } @@ -391,9 +391,9 @@ class Convert { static List> featureGeometryToFillGeometry( List>> geom) { - List> convertedFill = []; + final List> convertedFill = []; for (final ring in geom) { - List convertedRing = []; + final List convertedRing = []; for (final coords in ring) { convertedRing.add(LatLng(coords[1], coords[0])); } @@ -403,7 +403,7 @@ class Convert { } static Feature intepretFillOptions(FillOptions options, Feature feature) { - var properties = feature.properties; + final properties = feature.properties; var geometry = feature.geometry; if (options.draggable != null) { properties['draggable'] = options.draggable; diff --git a/maplibre_gl_web/lib/src/interop/style/layers/circle_layer_interop.dart b/maplibre_gl_web/lib/src/interop/style/layers/circle_layer_interop.dart index 0fd3f4dbf..4ea175357 100644 --- a/maplibre_gl_web/lib/src/interop/style/layers/circle_layer_interop.dart +++ b/maplibre_gl_web/lib/src/interop/style/layers/circle_layer_interop.dart @@ -5,7 +5,7 @@ class CircleLayerJsImpl { static toJs(CircleLayer circleLayer) => jsify(toDict(circleLayer)); static toDict(CircleLayer circleLayer) { - Map dict = { + final Map dict = { 'id': circleLayer.id, 'type': 'circle', }; @@ -28,7 +28,7 @@ class CirclePaintJsImpl { static toJs(CirclePaint circlePaint) => jsify(toDict(circlePaint)); static toDict(CirclePaint circlePaint) { - Map dict = {}; + final Map dict = {}; if (circlePaint.circleRadius != null) { dict['circle-radius'] = circlePaint.circleRadius; } diff --git a/maplibre_gl_web/lib/src/interop/style/layers/line_layer_interop.dart b/maplibre_gl_web/lib/src/interop/style/layers/line_layer_interop.dart index 1948a4027..c55a9022f 100644 --- a/maplibre_gl_web/lib/src/interop/style/layers/line_layer_interop.dart +++ b/maplibre_gl_web/lib/src/interop/style/layers/line_layer_interop.dart @@ -5,7 +5,7 @@ class LineLayerJsImpl { static toJs(LineLayer lineLayer) => jsify(toDict(lineLayer)); static toDict(LineLayer lineLayer) { - Map dict = { + final Map dict = { 'id': lineLayer.id, 'type': 'line', }; @@ -33,7 +33,7 @@ class LinePaintJsImpl { static toJs(LinePaint linePaint) => jsify(toDict(linePaint)); static toDict(LinePaint linePaint) { - Map dict = {}; + final Map dict = {}; if (linePaint.lineOpacity != null) { dict['line-opacity'] = linePaint.lineOpacity; } @@ -75,7 +75,7 @@ class LineLayoutJsImpl { static toJs(LineLayout lineLayout) => jsify(toDict(lineLayout)); static toDict(LineLayout lineLayout) { - Map dict = {}; + final Map dict = {}; if (lineLayout.lineCap != null) { dict['line-cap'] = lineLayout.lineCap; } diff --git a/maplibre_gl_web/lib/src/interop/style/layers/symbol_layer_interop.dart b/maplibre_gl_web/lib/src/interop/style/layers/symbol_layer_interop.dart index 400c9b9a7..5b8e9bef8 100644 --- a/maplibre_gl_web/lib/src/interop/style/layers/symbol_layer_interop.dart +++ b/maplibre_gl_web/lib/src/interop/style/layers/symbol_layer_interop.dart @@ -5,7 +5,7 @@ class SymbolLayerJsImpl { static toJs(SymbolLayer symbolLayer) => jsify(toDict(symbolLayer)); static toDict(SymbolLayer symbolLayer) { - Map dict = { + final Map dict = { 'id': symbolLayer.id, 'type': 'symbol', }; @@ -43,7 +43,7 @@ class SymbolPaintJsImpl { static toJs(SymbolPaint symbolPaint) => jsify(toDict(symbolPaint)); static toDict(SymbolPaint symbolPaint) { - Map dict = {}; + final Map dict = {}; if (symbolPaint.iconOpacity != null) { dict['icon-opacity'] = symbolPaint.iconOpacity; } @@ -94,7 +94,7 @@ class SymbolLayoutJsImpl { static toJs(SymbolLayout symbolLayout) => jsify(toDict(symbolLayout)); static toDict(SymbolLayout symbolLayout) { - Map dict = {}; + final Map dict = {}; if (symbolLayout.symbolAvoidEdges != null) { dict['symbol-avoid-edges'] = symbolLayout.symbolAvoidEdges; } diff --git a/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart b/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart index f36c838ad..c2a0ac2bb 100644 --- a/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart +++ b/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart @@ -58,7 +58,7 @@ class MapLibreMapController extends MapLibrePlatform @override Future initPlatform(int id) async { if (_creationParams.containsKey('initialCameraPosition')) { - var camera = _creationParams['initialCameraPosition']; + final camera = _creationParams['initialCameraPosition']; _dragEnabled = _creationParams['dragEnabled'] ?? true; _map = MapLibreMap( @@ -111,13 +111,13 @@ class MapLibreMapController extends MapLibrePlatform } _onMouseDown(Event e) { - var isDraggable = e.features[0].properties['draggable']; + final isDraggable = e.features[0].properties['draggable']; if (isDraggable != null && isDraggable) { // Prevent the default map drag behavior. e.preventDefault(); _draggedFeatureId = e.features[0].id; _map.getCanvas().style.cursor = 'grabbing'; - var coords = e.lngLat; + final coords = e.lngLat; _dragOrigin = LatLng(coords.lat as double, coords.lng as double); if (_draggedFeatureId != null) { @@ -268,7 +268,7 @@ class MapLibreMapController extends MapLibrePlatform @override Future queryRenderedFeatures( Point point, List layerIds, List? filter) async { - Map options = {}; + final Map options = {}; if (layerIds.isNotEmpty) { options['layers'] = layerIds; } @@ -296,7 +296,7 @@ class MapLibreMapController extends MapLibrePlatform @override Future queryRenderedFeaturesInRect( Rect rect, List layerIds, String? filter) async { - Map options = {}; + final Map options = {}; if (layerIds.isNotEmpty) { options['layers'] = layerIds; } @@ -324,7 +324,7 @@ class MapLibreMapController extends MapLibrePlatform @override Future querySourceFeatures( String sourceId, String? sourceLayerId, List? filter) async { - Map parameters = {}; + final Map parameters = {}; if (sourceLayerId != null) { parameters['sourceLayer'] = sourceLayerId; @@ -418,10 +418,10 @@ class MapLibreMapController extends MapLibrePlatform void _onMapResize() { Timer(const Duration(), () { - var container = _map.getContainer(); - var canvas = _map.getCanvas(); - var widthMismatch = canvas.clientWidth != container.clientWidth; - var heightMismatch = canvas.clientHeight != container.clientHeight; + final container = _map.getContainer(); + final canvas = _map.getCanvas(); + final widthMismatch = canvas.clientWidth != container.clientWidth; + final heightMismatch = canvas.clientHeight != container.clientHeight; if (widthMismatch || heightMismatch) { _map.resize(); } @@ -456,7 +456,7 @@ class MapLibreMapController extends MapLibrePlatform void _onCameraMove(_) { final center = _map.getCenter(); - var camera = CameraPosition( + final camera = CameraPosition( bearing: _map.getBearing() as double, target: LatLng(center.lat as double, center.lng as double), tilt: _map.getPitch() as double, @@ -467,7 +467,7 @@ class MapLibreMapController extends MapLibrePlatform void _onCameraIdle(_) { final center = _map.getCenter(); - var camera = CameraPosition( + final camera = CameraPosition( bearing: _map.getBearing() as double, target: LatLng(center.lat as double, center.lng as double), tilt: _map.getPitch() as double, @@ -535,9 +535,9 @@ class MapLibreMapController extends MapLibrePlatform if (_navigationControl != null) { prevShowCompass = _navigationControl!.options.showCompass; } - String? prevPosition = _navigationControlPosition; + final String? prevPosition = _navigationControlPosition; - String? positionString = switch (position) { + final String? positionString = switch (position) { CompassViewPosition.topRight => 'top-right', CompassViewPosition.topLeft => 'top-left', CompassViewPosition.bottomRight => 'bottom-right', @@ -545,8 +545,8 @@ class MapLibreMapController extends MapLibrePlatform _ => null, }; - bool newShowCompass = compassEnabled ?? prevShowCompass ?? false; - String? newPosition = positionString ?? prevPosition; + final bool newShowCompass = compassEnabled ?? prevShowCompass ?? false; + final String? newPosition = positionString ?? prevPosition; _removeNavigationControl(); _navigationControl = NavigationControl(NavigationControlOptions( @@ -710,14 +710,14 @@ class MapLibreMapController extends MapLibrePlatform @override Future toLatLng(Point screenLocation) async { - var lngLat = + final lngLat = _map.unproject(geo_point.Point(screenLocation.x, screenLocation.y)); return LatLng(lngLat.lat as double, lngLat.lng as double); } @override Future toScreenLocation(LatLng latLng) async { - var screenPosition = + final screenPosition = _map.project(LngLat(latLng.longitude, latLng.latitude)); final point = Point(screenPosition.x.round(), screenPosition.y.round()); @@ -728,7 +728,7 @@ class MapLibreMapController extends MapLibrePlatform Future>> toScreenLocationBatch( Iterable latLngs) async { return latLngs.map((latLng) { - var screenPosition = + final screenPosition = _map.project(LngLat(latLng.longitude, latLng.latitude)); return Point(screenPosition.x.round(), screenPosition.y.round()); }).toList(growable: false); @@ -737,8 +737,8 @@ class MapLibreMapController extends MapLibrePlatform @override Future getMetersPerPixelAtLatitude(double latitude) async { //https://wiki.openstreetmap.org/wiki/Zoom_levels - var circumference = 40075017.686; - var zoom = _map.getZoom(); + const circumference = 40075017.686; + final zoom = _map.getZoom(); return circumference * cos(latitude * (pi / 180)) / pow(2, zoom + 9); } diff --git a/maplibre_gl_web/lib/src/style/sources/vector_source.dart b/maplibre_gl_web/lib/src/style/sources/vector_source.dart index 9f2d3d2c7..a554701b2 100644 --- a/maplibre_gl_web/lib/src/style/sources/vector_source.dart +++ b/maplibre_gl_web/lib/src/style/sources/vector_source.dart @@ -30,7 +30,7 @@ class VectorSource extends Source { @override get dict { - Map dict = { + final Map dict = { 'type': 'vector', }; if (url != null) { diff --git a/maplibre_gl_web/lib/src/ui/map.dart b/maplibre_gl_web/lib/src/ui/map.dart index 5e66e7359..8d4123bc1 100644 --- a/maplibre_gl_web/lib/src/ui/map.dart +++ b/maplibre_gl_web/lib/src/ui/map.dart @@ -579,7 +579,7 @@ class MapLibreMap extends Camera { /// @see [Animate a point](https://maplibre.org/maplibre-gl-js/docs/examples/animate-point-along-line/) /// @see [Add live realtime data](https://maplibre.org/maplibre-gl-js/docs/examples/live-geojson/) dynamic getSource(String id) { - var source = jsObject.getSource(id); + final source = jsObject.getSource(id); if (source is GeoJsonSourceJsImpl) { return GeoJsonSource.fromJsObject(source); } diff --git a/maplibre_gl_web/lib/src/utils.dart b/maplibre_gl_web/lib/src/utils.dart index b500b2582..78e44d5fb 100644 --- a/maplibre_gl_web/lib/src/utils.dart +++ b/maplibre_gl_web/lib/src/utils.dart @@ -26,8 +26,8 @@ bool _isBasicType(Object? value) { } Map dartifyMap(Object? jsObject) { - var keys = js.objectKeys(jsObject); - var map = {}; + final keys = js.objectKeys(jsObject); + final map = {}; for (var key in keys) { map[key] = dartify(util.getProperty(jsObject!, key)); } diff --git a/scripts/lib/generate.dart b/scripts/lib/generate.dart index c28602d7b..aff77f779 100644 --- a/scripts/lib/generate.dart +++ b/scripts/lib/generate.dart @@ -7,7 +7,7 @@ import 'package:recase/recase.dart'; import 'conversions.dart'; main() async { - var styleJson = + final styleJson = jsonDecode(await File('scripts/input/style.json').readAsString()); final layerTypes = [ @@ -80,11 +80,11 @@ Future render( final outputPath = pathItems.join("/"); print("Rendering $filename"); - var templateFile = + final templateFile = await File('./scripts/templates/$filename.template').readAsString(); - var template = Template(templateFile); - var outputFile = File('$outputPath/$filename'); + final template = Template(templateFile); + final outputFile = File('$outputPath/$filename'); outputFile.writeAsString(template.renderString(renderContext)); } From d016acd3e7daa1f3df12a6e9e0fdc1ca49fd9674 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 01:27:43 +0200 Subject: [PATCH 28/36] prefer_final_in_for_each --- analysis_options.yaml | 1 - example/lib/line.dart | 2 +- example/lib/offline_regions.dart | 2 +- example/lib/place_symbol.dart | 4 ++-- lib/src/annotation_manager.dart | 4 ++-- lib/src/controller.dart | 2 +- maplibre_gl_platform_interface/lib/src/callbacks.dart | 2 +- maplibre_gl_platform_interface/lib/src/fill.dart | 4 ++-- maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart | 2 +- maplibre_gl_web/lib/src/utils.dart | 2 +- scripts/lib/generate.dart | 10 +++++----- 11 files changed, 17 insertions(+), 18 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 73fa06b04..104496702 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -33,7 +33,6 @@ linter: sort_constructors_first: false avoid_relative_lib_imports: false avoid_positional_boolean_parameters: false - prefer_final_in_for_each: false implicit_call_tearoffs: false comment_references: false cascade_invocations: false diff --git a/example/lib/line.dart b/example/lib/line.dart index 24b8aaadb..acde3a1e7 100644 --- a/example/lib/line.dart +++ b/example/lib/line.dart @@ -215,7 +215,7 @@ class LineBodyState extends State { : () async { final latLngs = await controller! .getLineLatLngs(_selectedLine!); - for (var latLng in latLngs) { + for (final latLng in latLngs) { debugPrint(latLng.toString()); } }, diff --git a/example/lib/offline_regions.dart b/example/lib/offline_regions.dart index 2c52ade50..cdba76f56 100644 --- a/example/lib/offline_regions.dart +++ b/example/lib/offline_regions.dart @@ -184,7 +184,7 @@ class _OfflineRegionsBodyState extends State { Future _updateListOfRegions() async { final List offlineRegions = await getListOfRegions(); final List regionItems = []; - for (var item in allRegions) { + for (final item in allRegions) { final offlineRegion = offlineRegions.firstWhereOrNull( (offlineRegion) => offlineRegion.metadata['name'] == item.name); if (offlineRegion != null) { diff --git a/example/lib/place_symbol.dart b/example/lib/place_symbol.dart index 2dae481b4..681a0c2c2 100644 --- a/example/lib/place_symbol.dart +++ b/example/lib/place_symbol.dart @@ -91,7 +91,7 @@ class PlaceSymbolBodyState extends State { void _add(String iconImage) { final List availableNumbers = Iterable.generate(12).toList(); - for (var s in controller!.symbols) { + for (final s in controller!.symbols) { availableNumbers.removeWhere((i) => i == s.data!['count']); } if (availableNumbers.isNotEmpty) { @@ -134,7 +134,7 @@ class PlaceSymbolBodyState extends State { Future _addAll(String iconImage) async { final List symbolsToAddNumbers = Iterable.generate(12).toList(); - for (var s in controller!.symbols) { + for (final s in controller!.symbols) { symbolsToAddNumbers.removeWhere((i) => i == s.data!['count']); } diff --git a/lib/src/annotation_manager.dart b/lib/src/annotation_manager.dart index 1ba3d4331..4c8ac4d95 100644 --- a/lib/src/annotation_manager.dart +++ b/lib/src/annotation_manager.dart @@ -91,7 +91,7 @@ abstract class AnnotationManager { /// Adds a multiple annotations to the map. This much faster than calling add /// multiple times Future addAll(Iterable annotations) async { - for (var a in annotations) { + for (final a in annotations) { _idToAnnotation[a.id] = a; } await _setAll(); @@ -105,7 +105,7 @@ abstract class AnnotationManager { /// Removes multiple annotations from the map Future removeAll(Iterable annotations) async { - for (var a in annotations) { + for (final a in annotations) { _idToAnnotation.remove(a.id); } await _setAll(); diff --git a/lib/src/controller.dart b/lib/src/controller.dart index 447fed722..92e2d776e 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -131,7 +131,7 @@ class MapLibreMapController extends ChangeNotifier { _maplibrePlatform.onMapStyleLoadedPlatform.add((_) { final interactionEnabled = annotationConsumeTapEvents.toSet(); - for (var type in annotationOrder.toSet()) { + for (final type in annotationOrder.toSet()) { final enableInteraction = interactionEnabled.contains(type); switch (type) { case AnnotationType.fill: diff --git a/maplibre_gl_platform_interface/lib/src/callbacks.dart b/maplibre_gl_platform_interface/lib/src/callbacks.dart index 48ee24b88..33939ce5a 100644 --- a/maplibre_gl_platform_interface/lib/src/callbacks.dart +++ b/maplibre_gl_platform_interface/lib/src/callbacks.dart @@ -27,7 +27,7 @@ class ArgumentCallbacks { if (length == 1) { _callbacks[0].call(argument); } else if (0 < length) { - for (ArgumentCallback callback + for (final ArgumentCallback callback in List>.from(_callbacks)) { callback(argument); } diff --git a/maplibre_gl_platform_interface/lib/src/fill.dart b/maplibre_gl_platform_interface/lib/src/fill.dart index 9b93c7c41..44fa6fa14 100644 --- a/maplibre_gl_platform_interface/lib/src/fill.dart +++ b/maplibre_gl_platform_interface/lib/src/fill.dart @@ -9,9 +9,9 @@ part of '../maplibre_gl_platform_interface.dart'; FillOptions translateFillOptions(FillOptions options, LatLng delta) { if (options.geometry != null) { final List> newGeometry = []; - for (var ring in options.geometry!) { + for (final ring in options.geometry!) { final List newRing = []; - for (var coords in ring) { + for (final coords in ring) { newRing.add(coords + delta); } newGeometry.add(newRing); diff --git a/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart b/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart index c2a0ac2bb..9cb77b0b3 100644 --- a/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart +++ b/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart @@ -688,7 +688,7 @@ class MapLibreMapController extends MapLibrePlatform @override void setStyleString(String? styleString) { //remove old mouseenter callbacks to avoid multicalling - for (var layerId in _interactiveFeatureLayerIds) { + for (final layerId in _interactiveFeatureLayerIds) { _map.off('mouseenter', layerId, _onMouseEnterFeature); _map.off('mousemouve', layerId, _onMouseEnterFeature); _map.off('mouseleave', layerId, _onMouseLeaveFeature); diff --git a/maplibre_gl_web/lib/src/utils.dart b/maplibre_gl_web/lib/src/utils.dart index 78e44d5fb..62a86b277 100644 --- a/maplibre_gl_web/lib/src/utils.dart +++ b/maplibre_gl_web/lib/src/utils.dart @@ -28,7 +28,7 @@ bool _isBasicType(Object? value) { Map dartifyMap(Object? jsObject) { final keys = js.objectKeys(jsObject); final map = {}; - for (var key in keys) { + for (final key in keys) { map[key] = dartify(util.getProperty(jsObject!, key)); } return map; diff --git a/scripts/lib/generate.dart b/scripts/lib/generate.dart index aff77f779..633e696e9 100644 --- a/scripts/lib/generate.dart +++ b/scripts/lib/generate.dart @@ -31,7 +31,7 @@ main() async { final renderContext = { "layerTypes": [ - for (var type in layerTypes) + for (final type in layerTypes) { "type": type, "typePascal": ReCase(type).pascalCase, @@ -41,7 +41,7 @@ main() async { }, ], "sourceTypes": [ - for (var type in sourceTypes) + for (final type in sourceTypes) { "type": type.replaceAll("_", "-"), "typePascal": ReCase(type).pascalCase, @@ -66,7 +66,7 @@ main() async { "maplibre_gl_platform_interface/lib/src/source_properties.dart", ]; - for (var template in templates) { + for (final template in templates) { await render(renderContext, template); } } @@ -168,7 +168,7 @@ List buildDocSplit(Map item) { if (maxValue != null) result.add(" maximum: $maxValue"); if (values != null) { result.add("Options:"); - for (var value in values.entries) { + for (final value in values.entries) { result.add(' "${value.key}"'); result.addAll( splitIntoChunks("${value.value["doc"]}", 70, prefix: " ")); @@ -198,7 +198,7 @@ List splitIntoChunks(String input, int lineLength, final chunks = []; String chunk = ""; - for (var word in words) { + for (final word in words) { final nextChunk = chunk.isEmpty ? prefix + word : "$chunk $word"; if (nextChunk.length > lineLength || chunk.endsWith("\n")) { chunks.add(chunk.replaceAll("\n", "")); From 7873ae8984cfbcebacaaa8dba8d4c2ea85d98792 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 01:29:10 +0200 Subject: [PATCH 29/36] implicit_call_tearoffs --- analysis_options.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 104496702..1abc06865 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -33,7 +33,6 @@ linter: sort_constructors_first: false avoid_relative_lib_imports: false avoid_positional_boolean_parameters: false - implicit_call_tearoffs: false comment_references: false cascade_invocations: false avoid_type_to_string: false From f3808934180e0a523e52ea899a000c1b12c005ea Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 01:30:22 +0200 Subject: [PATCH 30/36] avoid_type_to_string --- analysis_options.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 1abc06865..a36a97670 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -35,6 +35,5 @@ linter: avoid_positional_boolean_parameters: false comment_references: false cascade_invocations: false - avoid_type_to_string: false omit_local_variable_types: false use_named_constants: false From f9f971a9fc4d99881d19968e6451e86ebfd5771f Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 01:36:02 +0200 Subject: [PATCH 31/36] omit_local_variable_types --- analysis_options.yaml | 1 - example/lib/custom_marker.dart | 2 +- example/lib/get_map_informations.dart | 4 +-- example/lib/line.dart | 10 +++--- example/lib/local_style.dart | 8 ++--- example/lib/map_ui.dart | 19 ++++++----- example/lib/offline_regions.dart | 4 +-- example/lib/place_circle.dart | 22 ++++++------- example/lib/place_fill.dart | 16 +++++----- example/lib/place_source.dart | 8 ++--- example/lib/place_symbol.dart | 32 +++++++++---------- example/lib/util.dart | 4 +-- lib/src/controller.dart | 6 ++-- lib/src/global.dart | 2 +- lib/src/layer_properties.dart | 16 +++++----- lib/src/maplibre_map.dart | 14 ++++---- lib/src/offline_region.dart | 2 +- .../lib/src/callbacks.dart | 4 +-- .../lib/src/circle.dart | 2 +- .../lib/src/fill.dart | 6 ++-- .../lib/src/line.dart | 2 +- .../lib/src/method_channel_maplibre_gl.dart | 6 ++-- .../lib/src/source_properties.dart | 12 +++---- .../lib/src/symbol.dart | 2 +- maplibre_gl_web/lib/src/convert.dart | 8 ++--- .../style/layers/circle_layer_interop.dart | 4 +-- .../style/layers/line_layer_interop.dart | 6 ++-- .../style/layers/symbol_layer_interop.dart | 6 ++-- .../lib/src/maplibre_web_gl_platform.dart | 16 +++++----- .../lib/src/style/sources/vector_source.dart | 2 +- scripts/lib/generate.dart | 2 +- 31 files changed, 123 insertions(+), 125 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index a36a97670..ad0175b5f 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -35,5 +35,4 @@ linter: avoid_positional_boolean_parameters: false comment_references: false cascade_invocations: false - omit_local_variable_types: false use_named_constants: false diff --git a/example/lib/custom_marker.dart b/example/lib/custom_marker.dart index 80363544e..32d5d7e9f 100644 --- a/example/lib/custom_marker.dart +++ b/example/lib/custom_marker.dart @@ -141,7 +141,7 @@ class CustomMarkerState extends State { } _mapController.toScreenLocation(const LatLng(0, 0)); - final Stopwatch sw = Stopwatch(); + final sw = Stopwatch(); for (final batch in batches) { // diff --git a/example/lib/get_map_informations.dart b/example/lib/get_map_informations.dart index 7c0267baa..9109f3de3 100644 --- a/example/lib/get_map_informations.dart +++ b/example/lib/get_map_informations.dart @@ -34,7 +34,7 @@ class _GetMapInfoBodyState extends State { if (controller == null) { return; } - final List sources = await controller!.getSourceIds(); + final sources = await controller!.getSourceIds(); setState(() { data = 'Sources: ${sources.map((e) => '"$e"').join(', ')}'; }); @@ -44,7 +44,7 @@ class _GetMapInfoBodyState extends State { if (controller == null) { return; } - final List layers = (await controller!.getLayerIds()).cast(); + final layers = (await controller!.getLayerIds()).cast(); setState(() { data = 'Layers: ${layers.map((e) => '"$e"').join(', ')}'; }); diff --git a/example/lib/line.dart b/example/lib/line.dart index acde3a1e7..1b09f10c8 100644 --- a/example/lib/line.dart +++ b/example/lib/line.dart @@ -49,8 +49,8 @@ class LineBodyState extends State { /// Adds an asset image to the currently displayed style Future addImageFromAsset(String name, String assetName) async { - final ByteData bytes = await rootBundle.load(assetName); - final Uint8List list = bytes.buffer.asUint8List(); + final bytes = await rootBundle.load(assetName); + final list = bytes.buffer.asUint8List(); return controller!.addImage(name, list); } @@ -109,7 +109,7 @@ class LineBodyState extends State { } Future _changeLinePattern() async { - final String? current = + final current = _selectedLine!.options.linePattern == null ? "assetImage" : null; await _updateSelectedLine( LineOptions(linePattern: current), @@ -117,7 +117,7 @@ class LineBodyState extends State { } Future _changeAlpha() async { - double? current = _selectedLine!.options.lineOpacity; + var current = _selectedLine!.options.lineOpacity; current ??= 1.0; await _updateSelectedLine( @@ -126,7 +126,7 @@ class LineBodyState extends State { } Future _toggleVisible() async { - double? current = _selectedLine!.options.lineOpacity; + var current = _selectedLine!.options.lineOpacity; current ??= 1.0; await _updateSelectedLine( LineOptions(lineOpacity: current == 0.0 ? 1.0 : 0.0), diff --git a/example/lib/local_style.dart b/example/lib/local_style.dart index eb12f2761..5a3c35309 100644 --- a/example/lib/local_style.dart +++ b/example/lib/local_style.dart @@ -32,14 +32,14 @@ class LocalStyleState extends State { super.initState(); getApplicationDocumentsDirectory().then((dir) async { - final String documentDir = dir.path; - final String stylesDir = '$documentDir/styles'; - const String styleJSON = + final documentDir = dir.path; + final stylesDir = '$documentDir/styles'; + const styleJSON = '{"version":8,"name":"Demo style","center":[50,10],"zoom":4,"sources":{"demotiles":{"type":"vector","url":"https://demotiles.maplibre.org/tiles/tiles.json"}},"sprite":"","glyphs":"https://orangemug.github.io/font-glyphs/glyphs/{fontstack}/{range}.pbf","layers":[{"id":"background","type":"background","paint":{"background-color":"rgba(255, 255, 255, 1)"}},{"id":"countries","type":"line","source":"demotiles","source-layer":"countries","paint":{"line-color":"rgba(0, 0, 0, 1)","line-width":1,"line-opacity":1}}]}'; await Directory(stylesDir).create(recursive: true); - final File styleFile = File('$stylesDir/style.json'); + final styleFile = File('$stylesDir/style.json'); await styleFile.writeAsString(styleJSON); diff --git a/example/lib/map_ui.dart b/example/lib/map_ui.dart index ff6883586..21a29b5aa 100644 --- a/example/lib/map_ui.dart +++ b/example/lib/map_ui.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:math'; import 'package:flutter/material.dart'; import 'package:collection/collection.dart'; @@ -86,7 +85,7 @@ class MapUiBodyState extends State { } Widget _myLocationTrackingModeCycler() { - final MyLocationTrackingMode nextType = MyLocationTrackingMode.values[ + final nextType = MyLocationTrackingMode.values[ (_myLocationTrackingMode.index + 1) % MyLocationTrackingMode.values.length]; return TextButton( @@ -329,7 +328,7 @@ class MapUiBodyState extends State { (ll) => ll.map((l) => LatLng(l[1], l[0])).toList().cast()) .toList() .cast>(); - final Fill fill = await mapController!.addFill(FillOptions( + final fill = await mapController!.addFill(FillOptions( geometry: geometry, fillColor: "#FF0000", fillOutlineColor: "#FF0000", @@ -343,7 +342,7 @@ class MapUiBodyState extends State { @override Widget build(BuildContext context) { - final MapLibreMap maplibreMap = MapLibreMap( + final maplibreMap = MapLibreMap( onMapCreated: onMapCreated, initialCameraPosition: _kInitialPosition, trackCameraPosition: true, @@ -363,7 +362,7 @@ class MapUiBodyState extends State { debugPrint( "Map click: ${point.x},${point.y} ${latLng.latitude}/${latLng.longitude}"); debugPrint("Filter $_featureQueryFilter"); - final List features = await mapController! + final features = await mapController! .queryRenderedFeatures(point, [], _featureQueryFilter); if (!mounted) return; @@ -381,17 +380,17 @@ class MapUiBodyState extends State { onMapLongClick: (point, latLng) async { debugPrint( "Map long press: ${point.x},${point.y} ${latLng.latitude}/${latLng.longitude}"); - final Point convertedPoint = await mapController!.toScreenLocation(latLng); - final LatLng convertedLatLng = await mapController!.toLatLng(point); + final convertedPoint = await mapController!.toScreenLocation(latLng); + final convertedLatLng = await mapController!.toLatLng(point); debugPrint( "Map long press converted: ${convertedPoint.x},${convertedPoint.y} ${convertedLatLng.latitude}/${convertedLatLng.longitude}"); - final double metersPerPixel = + final metersPerPixel = await mapController!.getMetersPerPixelAtLatitude(latLng.latitude); debugPrint( "Map long press The distance measured in meters at latitude ${latLng.latitude} is $metersPerPixel m"); - final List features = + final features = await mapController!.queryRenderedFeatures(point, [], null); if (features.isNotEmpty) { debugPrint(features[0]); @@ -408,7 +407,7 @@ class MapUiBodyState extends State { }, ); - final List listViewChildren = []; + final listViewChildren = []; if (mapController != null) { listViewChildren.addAll( diff --git a/example/lib/offline_regions.dart b/example/lib/offline_regions.dart index cdba76f56..7d387c19c 100644 --- a/example/lib/offline_regions.dart +++ b/example/lib/offline_regions.dart @@ -182,8 +182,8 @@ class _OfflineRegionsBodyState extends State { } Future _updateListOfRegions() async { - final List offlineRegions = await getListOfRegions(); - final List regionItems = []; + final offlineRegions = await getListOfRegions(); + final regionItems = []; for (final item in allRegions) { final offlineRegion = offlineRegions.firstWhereOrNull( (offlineRegion) => offlineRegion.metadata['name'] == item.name); diff --git a/example/lib/place_circle.dart b/example/lib/place_circle.dart index 4dbadd98f..918d93401 100644 --- a/example/lib/place_circle.dart +++ b/example/lib/place_circle.dart @@ -90,8 +90,8 @@ class PlaceCircleBodyState extends State { } void _changePosition() { - final LatLng current = _selectedCircle!.options.geometry!; - final Offset offset = Offset( + final current = _selectedCircle!.options.geometry!; + final offset = Offset( center.latitude - current.latitude, center.longitude - current.longitude, ); @@ -106,7 +106,7 @@ class PlaceCircleBodyState extends State { } void _changeDraggable() { - bool? draggable = _selectedCircle!.options.draggable; + var draggable = _selectedCircle!.options.draggable; draggable ??= false; _updateSelectedCircle( CircleOptions( @@ -116,7 +116,7 @@ class PlaceCircleBodyState extends State { } Future _getLatLng() async { - final LatLng latLng = await controller!.getCircleLatLng(_selectedCircle!); + final latLng = await controller!.getCircleLatLng(_selectedCircle!); if (!mounted) return; ScaffoldMessenger.of(context).showSnackBar( @@ -127,7 +127,7 @@ class PlaceCircleBodyState extends State { } void _changeCircleStrokeOpacity() { - double? current = _selectedCircle!.options.circleStrokeOpacity; + var current = _selectedCircle!.options.circleStrokeOpacity; current ??= 1.0; _updateSelectedCircle( @@ -136,14 +136,14 @@ class PlaceCircleBodyState extends State { } void _changeCircleStrokeWidth() { - double? current = _selectedCircle!.options.circleStrokeWidth; + var current = _selectedCircle!.options.circleStrokeWidth; current ??= 0; _updateSelectedCircle( CircleOptions(circleStrokeWidth: current == 0 ? 5.0 : 0)); } Future _changeCircleStrokeColor() async { - String? current = _selectedCircle!.options.circleStrokeColor; + var current = _selectedCircle!.options.circleStrokeColor; current ??= "#FFFFFF"; _updateSelectedCircle( @@ -153,7 +153,7 @@ class PlaceCircleBodyState extends State { } Future _changeCircleOpacity() async { - double? current = _selectedCircle!.options.circleOpacity; + var current = _selectedCircle!.options.circleOpacity; current ??= 1.0; _updateSelectedCircle( @@ -162,7 +162,7 @@ class PlaceCircleBodyState extends State { } Future _changeCircleRadius() async { - double? current = _selectedCircle!.options.circleRadius; + var current = _selectedCircle!.options.circleRadius; current ??= 0; _updateSelectedCircle( CircleOptions(circleRadius: current == 120.0 ? 30.0 : current + 30.0), @@ -170,7 +170,7 @@ class PlaceCircleBodyState extends State { } Future _changeCircleColor() async { - String? current = _selectedCircle!.options.circleColor; + var current = _selectedCircle!.options.circleColor; current ??= "#FF0000"; _updateSelectedCircle( @@ -179,7 +179,7 @@ class PlaceCircleBodyState extends State { } Future _changeCircleBlur() async { - double? current = _selectedCircle!.options.circleBlur; + var current = _selectedCircle!.options.circleBlur; current ??= 0; _updateSelectedCircle( CircleOptions(circleBlur: current == 0.75 ? 0 : 0.75), diff --git a/example/lib/place_fill.dart b/example/lib/place_fill.dart index 45de41321..b0bc014be 100644 --- a/example/lib/place_fill.dart +++ b/example/lib/place_fill.dart @@ -85,8 +85,8 @@ class PlaceFillBodyState extends State { /// Adds an asset image to the currently displayed style Future addImageFromAsset(String name, String assetName) async { - final ByteData bytes = await rootBundle.load(assetName); - final Uint8List list = bytes.buffer.asUint8List(); + final bytes = await rootBundle.load(assetName); + final list = bytes.buffer.asUint8List(); return controller!.addImage(name, list); } @@ -127,7 +127,7 @@ class PlaceFillBodyState extends State { } void _changePosition() { - List>? geometry = _selectedFill!.options.geometry; + var geometry = _selectedFill!.options.geometry; geometry ??= _defaultGeometry; @@ -142,7 +142,7 @@ class PlaceFillBodyState extends State { } void _changeDraggable() { - bool? draggable = _selectedFill!.options.draggable; + var draggable = _selectedFill!.options.draggable; draggable ??= false; _updateSelectedFill( FillOptions(draggable: !draggable), @@ -150,7 +150,7 @@ class PlaceFillBodyState extends State { } Future _changeFillOpacity() async { - double? current = _selectedFill!.options.fillOpacity; + var current = _selectedFill!.options.fillOpacity; current ??= 1.0; _updateSelectedFill( @@ -159,7 +159,7 @@ class PlaceFillBodyState extends State { } Future _changeFillColor() async { - String? current = _selectedFill!.options.fillColor; + var current = _selectedFill!.options.fillColor; current ??= "#FF0000"; _updateSelectedFill( @@ -168,7 +168,7 @@ class PlaceFillBodyState extends State { } Future _changeFillOutlineColor() async { - String? current = _selectedFill!.options.fillOutlineColor; + var current = _selectedFill!.options.fillOutlineColor; current ??= "#FF0000"; _updateSelectedFill( @@ -177,7 +177,7 @@ class PlaceFillBodyState extends State { } Future _changeFillPattern() async { - final String? current = + final current = _selectedFill!.options.fillPattern == null ? "assetImage" : null; _updateSelectedFill( FillOptions(fillPattern: current), diff --git a/example/lib/place_source.dart b/example/lib/place_source.dart index f59f8abd8..1d92326aa 100644 --- a/example/lib/place_source.dart +++ b/example/lib/place_source.dart @@ -50,8 +50,8 @@ class PlaceSymbolBodyState extends State { /// Adds an asset image as a source to the currently displayed style Future addImageSourceFromAsset( String imageSourceId, String assetName) async { - final ByteData bytes = await rootBundle.load(assetName); - final Uint8List list = bytes.buffer.asUint8List(); + final bytes = await rootBundle.load(assetName); + final list = bytes.buffer.asUint8List(); return controller.addImageSource( imageSourceId, list, @@ -93,8 +93,8 @@ class PlaceSymbolBodyState extends State { Future updateImageSourceFromAsset( String imageSourceId, String assetName) async { - final ByteData bytes = await rootBundle.load(assetName); - final Uint8List list = bytes.buffer.asUint8List(); + final bytes = await rootBundle.load(assetName); + final list = bytes.buffer.asUint8List(); return controller.updateImageSource(imageSourceId, list, null); } diff --git a/example/lib/place_symbol.dart b/example/lib/place_symbol.dart index 681a0c2c2..13bb52bd2 100644 --- a/example/lib/place_symbol.dart +++ b/example/lib/place_symbol.dart @@ -60,8 +60,8 @@ class PlaceSymbolBodyState extends State { /// Adds an asset image to the currently displayed style Future addImageFromAsset(String name, String assetName) async { - final ByteData bytes = await rootBundle.load(assetName); - final Uint8List list = bytes.buffer.asUint8List(); + final bytes = await rootBundle.load(assetName); + final list = bytes.buffer.asUint8List(); return controller!.addImage(name, list); } @@ -90,7 +90,7 @@ class PlaceSymbolBodyState extends State { } void _add(String iconImage) { - final List availableNumbers = Iterable.generate(12).toList(); + final availableNumbers = Iterable.generate(12).toList(); for (final s in controller!.symbols) { availableNumbers.removeWhere((i) => i == s.data!['count']); } @@ -105,7 +105,7 @@ class PlaceSymbolBodyState extends State { } SymbolOptions _getSymbolOptions(String iconImage, int symbolCount) { - final LatLng geometry = LatLng( + final geometry = LatLng( center.latitude + sin(symbolCount * pi / 6.0) / 20.0, center.longitude + cos(symbolCount * pi / 6.0) / 20.0, ); @@ -133,13 +133,13 @@ class PlaceSymbolBodyState extends State { } Future _addAll(String iconImage) async { - final List symbolsToAddNumbers = Iterable.generate(12).toList(); + final symbolsToAddNumbers = Iterable.generate(12).toList(); for (final s in controller!.symbols) { symbolsToAddNumbers.removeWhere((i) => i == s.data!['count']); } if (symbolsToAddNumbers.isNotEmpty) { - final List symbolOptionsList = symbolsToAddNumbers + final symbolOptionsList = symbolsToAddNumbers .map((i) => _getSymbolOptions(iconImage, i)) .toList(); controller!.addSymbols(symbolOptionsList, @@ -168,8 +168,8 @@ class PlaceSymbolBodyState extends State { } void _changePosition() { - final LatLng current = _selectedSymbol!.options.geometry!; - final Offset offset = Offset( + final current = _selectedSymbol!.options.geometry!; + final offset = Offset( center.latitude - current.latitude, center.longitude - current.longitude, ); @@ -184,14 +184,14 @@ class PlaceSymbolBodyState extends State { } void _changeIconOffset() { - Offset? currentAnchor = _selectedSymbol!.options.iconOffset; + var currentAnchor = _selectedSymbol!.options.iconOffset; currentAnchor ??= const Offset(0.0, 0.0); - final Offset newAnchor = Offset(1.0 - currentAnchor.dy, currentAnchor.dx); + final newAnchor = Offset(1.0 - currentAnchor.dy, currentAnchor.dx); _updateSelectedSymbol(SymbolOptions(iconOffset: newAnchor)); } Future _changeIconAnchor() async { - String? current = _selectedSymbol!.options.iconAnchor; + var current = _selectedSymbol!.options.iconAnchor; if (current == null || current == 'center') { current = 'bottom'; } else { @@ -203,7 +203,7 @@ class PlaceSymbolBodyState extends State { } Future _toggleDraggable() async { - bool? draggable = _selectedSymbol!.options.draggable; + var draggable = _selectedSymbol!.options.draggable; draggable ??= false; _updateSelectedSymbol( @@ -212,7 +212,7 @@ class PlaceSymbolBodyState extends State { } Future _changeAlpha() async { - double? current = _selectedSymbol!.options.iconOpacity; + var current = _selectedSymbol!.options.iconOpacity; current ??= 1.0; _updateSelectedSymbol( @@ -221,7 +221,7 @@ class PlaceSymbolBodyState extends State { } Future _changeRotation() async { - double? current = _selectedSymbol!.options.iconRotate; + var current = _selectedSymbol!.options.iconRotate; current ??= 0; _updateSelectedSymbol( SymbolOptions(iconRotate: current == 330.0 ? 0.0 : current + 30.0), @@ -229,7 +229,7 @@ class PlaceSymbolBodyState extends State { } Future _toggleVisible() async { - double? current = _selectedSymbol!.options.iconOpacity; + var current = _selectedSymbol!.options.iconOpacity; current ??= 1.0; _updateSelectedSymbol( @@ -238,7 +238,7 @@ class PlaceSymbolBodyState extends State { } Future _changeZIndex() async { - int? current = _selectedSymbol!.options.zIndex; + var current = _selectedSymbol!.options.zIndex; current ??= 0; _updateSelectedSymbol( SymbolOptions(zIndex: current == 12 ? 0 : current + 1), diff --git a/example/lib/util.dart b/example/lib/util.dart index fa5ae9ed6..035c5c050 100644 --- a/example/lib/util.dart +++ b/example/lib/util.dart @@ -4,7 +4,7 @@ import 'package:maplibre_gl/maplibre_gl.dart'; /// Adds an asset image to the currently displayed style Future addImageFromAsset( MapLibreMapController controller, String name, String assetName) async { - final ByteData bytes = await rootBundle.load(assetName); - final Uint8List list = bytes.buffer.asUint8List(); + final bytes = await rootBundle.load(assetName); + final list = bytes.buffer.asUint8List(); return controller.addImage(name, list); } diff --git a/lib/src/controller.dart b/lib/src/controller.dart index 92e2d776e..1974e8d2a 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -99,7 +99,7 @@ class MapLibreMapController extends ChangeNotifier { _maplibrePlatform.onFeatureDraggedPlatform.add((payload) { for (final fun in List.from(onFeatureDrag)) { - final DragEventType enmDragEventType = DragEventType.values + final enmDragEventType = DragEventType.values .firstWhere((element) => element.name == payload["eventType"]); fun(payload["id"], point: payload["point"], @@ -910,7 +910,7 @@ class MapLibreMapController extends ChangeNotifier { /// The returned [Future] completes with the added circle once listeners have /// been notified. Future addCircle(CircleOptions options, [Map? data]) async { - final CircleOptions effectiveOptions = + final effectiveOptions = CircleOptions.defaultOptions.copyWith(options); final circle = Circle(getRandomString(), effectiveOptions, data); await circleManager!.add(circle); @@ -1005,7 +1005,7 @@ class MapLibreMapController extends ChangeNotifier { /// The returned [Future] completes with the added fill once listeners have /// been notified. Future addFill(FillOptions options, [Map? data]) async { - final FillOptions effectiveOptions = + final effectiveOptions = FillOptions.defaultOptions.copyWith(options); final fill = Fill(getRandomString(), effectiveOptions, data); await fillManager!.add(fill); diff --git a/lib/src/global.dart b/lib/src/global.dart index 6530455bb..71c70226e 100644 --- a/lib/src/global.dart +++ b/lib/src/global.dart @@ -90,7 +90,7 @@ Future downloadOfflineRegion(OfflineRegionDefinition definition, Map metadata = const {}, Function(DownloadRegionStatus event)? onEvent, }) async { - final String channelName = + final channelName = 'downloadOfflineRegion_${DateTime .now() .microsecondsSinceEpoch}'; diff --git a/lib/src/layer_properties.dart b/lib/src/layer_properties.dart index 389fcd463..f4e5735aa 100644 --- a/lib/src/layer_properties.dart +++ b/lib/src/layer_properties.dart @@ -904,7 +904,7 @@ class SymbolLayerProperties implements LayerProperties { @override Map toJson() { - final Map json = {}; + final json = {}; void addIfPresent(String fieldName, dynamic value) { if (value != null) { @@ -1229,7 +1229,7 @@ class CircleLayerProperties implements LayerProperties { @override Map toJson() { - final Map json = {}; + final json = {}; void addIfPresent(String fieldName, dynamic value) { if (value != null) { @@ -1533,7 +1533,7 @@ class LineLayerProperties implements LayerProperties { @override Map toJson() { - final Map json = {}; + final json = {}; void addIfPresent(String fieldName, dynamic value) { if (value != null) { @@ -1720,7 +1720,7 @@ class FillLayerProperties implements LayerProperties { @override Map toJson() { - final Map json = {}; + final json = {}; void addIfPresent(String fieldName, dynamic value) { if (value != null) { @@ -1901,7 +1901,7 @@ class FillExtrusionLayerProperties implements LayerProperties { @override Map toJson() { - final Map json = {}; + final json = {}; void addIfPresent(String fieldName, dynamic value) { if (value != null) { @@ -2078,7 +2078,7 @@ class RasterLayerProperties implements LayerProperties { @override Map toJson() { - final Map json = {}; + final json = {}; void addIfPresent(String fieldName, dynamic value) { if (value != null) { @@ -2228,7 +2228,7 @@ class HillshadeLayerProperties implements LayerProperties { @override Map toJson() { - final Map json = {}; + final json = {}; void addIfPresent(String fieldName, dynamic value) { if (value != null) { @@ -2358,7 +2358,7 @@ class HeatmapLayerProperties implements LayerProperties { @override Map toJson() { - final Map json = {}; + final json = {}; void addIfPresent(String fieldName, dynamic value) { if (value != null) { diff --git a/lib/src/maplibre_map.dart b/lib/src/maplibre_map.dart index 03b338adf..daf9e8d20 100644 --- a/lib/src/maplibre_map.dart +++ b/lib/src/maplibre_map.dart @@ -263,7 +263,7 @@ class _MapLibreMapState extends State { assert( widget.annotationOrder.toSet().length == widget.annotationOrder.length, "annotationOrder must not have duplicate types"); - final Map creationParams = { + final creationParams = { 'initialCameraPosition': widget.initialCameraPosition.toMap(), 'styleString': widget.styleString, 'options': _MapLibreMapOptions.fromWidget(widget).toMap(), @@ -294,9 +294,9 @@ class _MapLibreMapState extends State { @override void didUpdateWidget(MapLibreMap oldWidget) { super.didUpdateWidget(oldWidget); - final _MapLibreMapOptions newOptions = + final newOptions = _MapLibreMapOptions.fromWidget(widget); - final Map updates = + final updates = _maplibreMapOptions.updatesMap(newOptions); _updateOptions(updates); _maplibreMapOptions = newOptions; @@ -306,12 +306,12 @@ class _MapLibreMapState extends State { if (updates.isEmpty) { return; } - final MapLibreMapController controller = await _controller.future; + final controller = await _controller.future; controller._updateMapOptions(updates); } Future onPlatformViewCreated(int id) async { - final MapLibreMapController controller = MapLibreMapController( + final controller = MapLibreMapController( maplibrePlatform: _maplibrePlatform, initialCameraPosition: widget.initialCameraPosition, onStyleLoadedCallback: () { @@ -431,7 +431,7 @@ class _MapLibreMapOptions { }; Map toMap() { - final Map optionsMap = {}; + final optionsMap = {}; void addIfNonNull(String fieldName, dynamic value) { if (value != null) { @@ -472,7 +472,7 @@ class _MapLibreMapOptions { } Map updatesMap(_MapLibreMapOptions newOptions) { - final Map prevOptionsMap = toMap(); + final prevOptionsMap = toMap(); final newOptionsMap = newOptions.toMap(); // if any gesture is updated also all other gestures have to the saved to diff --git a/lib/src/offline_region.dart b/lib/src/offline_region.dart index 04badd120..e5e70cc76 100644 --- a/lib/src/offline_region.dart +++ b/lib/src/offline_region.dart @@ -22,7 +22,7 @@ class OfflineRegionDefinition { "OfflineRegionDefinition, bounds = $bounds, mapStyleUrl = $mapStyleUrl, minZoom = $minZoom, maxZoom = $maxZoom"; Map toMap() { - final Map data = {}; + final data = {}; data['bounds'] = bounds.toList(); data['mapStyleUrl'] = mapStyleUrl; data['minZoom'] = minZoom; diff --git a/maplibre_gl_platform_interface/lib/src/callbacks.dart b/maplibre_gl_platform_interface/lib/src/callbacks.dart index 33939ce5a..e7a177b8c 100644 --- a/maplibre_gl_platform_interface/lib/src/callbacks.dart +++ b/maplibre_gl_platform_interface/lib/src/callbacks.dart @@ -23,11 +23,11 @@ class ArgumentCallbacks { /// method and is unaffected by any changes subsequently made to this /// collection. void call(T argument) { - final int length = _callbacks.length; + final length = _callbacks.length; if (length == 1) { _callbacks[0].call(argument); } else if (0 < length) { - for (final ArgumentCallback callback + for (final callback in List>.from(_callbacks)) { callback(argument); } diff --git a/maplibre_gl_platform_interface/lib/src/circle.dart b/maplibre_gl_platform_interface/lib/src/circle.dart index 9c80815b9..bee69ee55 100644 --- a/maplibre_gl_platform_interface/lib/src/circle.dart +++ b/maplibre_gl_platform_interface/lib/src/circle.dart @@ -92,7 +92,7 @@ class CircleOptions { } dynamic toJson([bool addGeometry = true]) { - final Map json = {}; + final json = {}; void addIfPresent(String fieldName, dynamic value) { if (value != null) { diff --git a/maplibre_gl_platform_interface/lib/src/fill.dart b/maplibre_gl_platform_interface/lib/src/fill.dart index 44fa6fa14..c2913e589 100644 --- a/maplibre_gl_platform_interface/lib/src/fill.dart +++ b/maplibre_gl_platform_interface/lib/src/fill.dart @@ -8,9 +8,9 @@ part of '../maplibre_gl_platform_interface.dart'; FillOptions translateFillOptions(FillOptions options, LatLng delta) { if (options.geometry != null) { - final List> newGeometry = []; + final newGeometry = >[]; for (final ring in options.geometry!) { - final List newRing = []; + final newRing = []; for (final coords in ring) { newRing.add(coords + delta); } @@ -94,7 +94,7 @@ class FillOptions { } dynamic toJson([bool addGeometry = true]) { - final Map json = {}; + final json = {}; void addIfPresent(String fieldName, dynamic value) { if (value != null) { diff --git a/maplibre_gl_platform_interface/lib/src/line.dart b/maplibre_gl_platform_interface/lib/src/line.dart index 2d2f30e37..98599572c 100644 --- a/maplibre_gl_platform_interface/lib/src/line.dart +++ b/maplibre_gl_platform_interface/lib/src/line.dart @@ -95,7 +95,7 @@ class LineOptions { } dynamic toJson([bool addGeometry = true]) { - final Map json = {}; + final json = {}; void addIfPresent(String fieldName, dynamic value) { if (value != null) { diff --git a/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart b/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart index 8daf42256..aa480ef04 100644 --- a/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart +++ b/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart @@ -326,8 +326,8 @@ class MapLibreMethodChannel extends MapLibrePlatform { try { final Map reply = await _channel.invokeMethod( 'locationComponent#getLastLocation'); - double latitude = 0.0; - double longitude = 0.0; + var latitude = 0.0; + var longitude = 0.0; if (reply.containsKey('latitude') && reply['latitude'] != null) { latitude = double.parse(reply['latitude'].toString()); } @@ -428,7 +428,7 @@ class MapLibreMethodChannel extends MapLibrePlatform { 'map#toScreenLocationBatch', {"coordinates": coordinates}); final points = []; - for (int i = 0; i < result.length; i += 2) { + for (var i = 0; i < result.length; i += 2) { points.add(Point(result[i], result[i + 1])); } diff --git a/maplibre_gl_platform_interface/lib/src/source_properties.dart b/maplibre_gl_platform_interface/lib/src/source_properties.dart index 79e58f6ad..d0da46ce6 100644 --- a/maplibre_gl_platform_interface/lib/src/source_properties.dart +++ b/maplibre_gl_platform_interface/lib/src/source_properties.dart @@ -105,7 +105,7 @@ class VectorSourceProperties implements SourceProperties { @override Map toJson() { - final Map json = {}; + final json = {}; void addIfPresent(String fieldName, dynamic value) { if (value != null) { @@ -236,7 +236,7 @@ class RasterSourceProperties implements SourceProperties { @override Map toJson() { - final Map json = {}; + final json = {}; void addIfPresent(String fieldName, dynamic value) { if (value != null) { @@ -370,7 +370,7 @@ class RasterDemSourceProperties implements SourceProperties { @override Map toJson() { - final Map json = {}; + final json = {}; void addIfPresent(String fieldName, dynamic value) { if (value != null) { @@ -554,7 +554,7 @@ class GeojsonSourceProperties implements SourceProperties { @override Map toJson() { - final Map json = {}; + final json = {}; void addIfPresent(String fieldName, dynamic value) { if (value != null) { @@ -624,7 +624,7 @@ class VideoSourceProperties implements SourceProperties { @override Map toJson() { - final Map json = {}; + final json = {}; void addIfPresent(String fieldName, dynamic value) { if (value != null) { @@ -674,7 +674,7 @@ class ImageSourceProperties implements SourceProperties { @override Map toJson() { - final Map json = {}; + final json = {}; void addIfPresent(String fieldName, dynamic value) { if (value != null) { diff --git a/maplibre_gl_platform_interface/lib/src/symbol.dart b/maplibre_gl_platform_interface/lib/src/symbol.dart index e54558855..978bb4a28 100644 --- a/maplibre_gl_platform_interface/lib/src/symbol.dart +++ b/maplibre_gl_platform_interface/lib/src/symbol.dart @@ -157,7 +157,7 @@ class SymbolOptions { } dynamic toJson([bool addGeometry = true]) { - final Map json = {}; + final json = {}; void addIfPresent(String fieldName, dynamic value) { if (value != null) { diff --git a/maplibre_gl_web/lib/src/convert.dart b/maplibre_gl_web/lib/src/convert.dart index 082fcec40..1f8e2245c 100644 --- a/maplibre_gl_web/lib/src/convert.dart +++ b/maplibre_gl_web/lib/src/convert.dart @@ -378,9 +378,9 @@ class Convert { static List>> fillGeometryToFeatureGeometry( List> geom) { - final List>> convertedFill = []; + final convertedFill = >>[]; for (final ring in geom) { - final List> convertedRing = []; + final convertedRing = >[]; for (final coords in ring) { convertedRing.add([coords.longitude, coords.latitude]); } @@ -391,9 +391,9 @@ class Convert { static List> featureGeometryToFillGeometry( List>> geom) { - final List> convertedFill = []; + final convertedFill = >[]; for (final ring in geom) { - final List convertedRing = []; + final convertedRing = []; for (final coords in ring) { convertedRing.add(LatLng(coords[1], coords[0])); } diff --git a/maplibre_gl_web/lib/src/interop/style/layers/circle_layer_interop.dart b/maplibre_gl_web/lib/src/interop/style/layers/circle_layer_interop.dart index 4ea175357..e1c8cc9b9 100644 --- a/maplibre_gl_web/lib/src/interop/style/layers/circle_layer_interop.dart +++ b/maplibre_gl_web/lib/src/interop/style/layers/circle_layer_interop.dart @@ -5,7 +5,7 @@ class CircleLayerJsImpl { static toJs(CircleLayer circleLayer) => jsify(toDict(circleLayer)); static toDict(CircleLayer circleLayer) { - final Map dict = { + final dict = { 'id': circleLayer.id, 'type': 'circle', }; @@ -28,7 +28,7 @@ class CirclePaintJsImpl { static toJs(CirclePaint circlePaint) => jsify(toDict(circlePaint)); static toDict(CirclePaint circlePaint) { - final Map dict = {}; + final dict = {}; if (circlePaint.circleRadius != null) { dict['circle-radius'] = circlePaint.circleRadius; } diff --git a/maplibre_gl_web/lib/src/interop/style/layers/line_layer_interop.dart b/maplibre_gl_web/lib/src/interop/style/layers/line_layer_interop.dart index c55a9022f..f843af268 100644 --- a/maplibre_gl_web/lib/src/interop/style/layers/line_layer_interop.dart +++ b/maplibre_gl_web/lib/src/interop/style/layers/line_layer_interop.dart @@ -5,7 +5,7 @@ class LineLayerJsImpl { static toJs(LineLayer lineLayer) => jsify(toDict(lineLayer)); static toDict(LineLayer lineLayer) { - final Map dict = { + final dict = { 'id': lineLayer.id, 'type': 'line', }; @@ -33,7 +33,7 @@ class LinePaintJsImpl { static toJs(LinePaint linePaint) => jsify(toDict(linePaint)); static toDict(LinePaint linePaint) { - final Map dict = {}; + final dict = {}; if (linePaint.lineOpacity != null) { dict['line-opacity'] = linePaint.lineOpacity; } @@ -75,7 +75,7 @@ class LineLayoutJsImpl { static toJs(LineLayout lineLayout) => jsify(toDict(lineLayout)); static toDict(LineLayout lineLayout) { - final Map dict = {}; + final dict = {}; if (lineLayout.lineCap != null) { dict['line-cap'] = lineLayout.lineCap; } diff --git a/maplibre_gl_web/lib/src/interop/style/layers/symbol_layer_interop.dart b/maplibre_gl_web/lib/src/interop/style/layers/symbol_layer_interop.dart index 5b8e9bef8..fea76de17 100644 --- a/maplibre_gl_web/lib/src/interop/style/layers/symbol_layer_interop.dart +++ b/maplibre_gl_web/lib/src/interop/style/layers/symbol_layer_interop.dart @@ -5,7 +5,7 @@ class SymbolLayerJsImpl { static toJs(SymbolLayer symbolLayer) => jsify(toDict(symbolLayer)); static toDict(SymbolLayer symbolLayer) { - final Map dict = { + final dict = { 'id': symbolLayer.id, 'type': 'symbol', }; @@ -43,7 +43,7 @@ class SymbolPaintJsImpl { static toJs(SymbolPaint symbolPaint) => jsify(toDict(symbolPaint)); static toDict(SymbolPaint symbolPaint) { - final Map dict = {}; + final dict = {}; if (symbolPaint.iconOpacity != null) { dict['icon-opacity'] = symbolPaint.iconOpacity; } @@ -94,7 +94,7 @@ class SymbolLayoutJsImpl { static toJs(SymbolLayout symbolLayout) => jsify(toDict(symbolLayout)); static toDict(SymbolLayout symbolLayout) { - final Map dict = {}; + final dict = {}; if (symbolLayout.symbolAvoidEdges != null) { dict['symbol-avoid-edges'] = symbolLayout.symbolAvoidEdges; } diff --git a/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart b/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart index 9cb77b0b3..2d977fb45 100644 --- a/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart +++ b/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart @@ -106,7 +106,7 @@ class MapLibreMapController extends MapLibrePlatform Future _loadFromAssets(Event event) async { final imagePath = event.id; - final ByteData bytes = await rootBundle.load(imagePath); + final bytes = await rootBundle.load(imagePath); await addImage(imagePath, bytes.buffer.asUint8List()); } @@ -268,7 +268,7 @@ class MapLibreMapController extends MapLibrePlatform @override Future queryRenderedFeatures( Point point, List layerIds, List? filter) async { - final Map options = {}; + final options = {}; if (layerIds.isNotEmpty) { options['layers'] = layerIds; } @@ -296,7 +296,7 @@ class MapLibreMapController extends MapLibrePlatform @override Future queryRenderedFeaturesInRect( Rect rect, List layerIds, String? filter) async { - final Map options = {}; + final options = {}; if (layerIds.isNotEmpty) { options['layers'] = layerIds; } @@ -324,7 +324,7 @@ class MapLibreMapController extends MapLibrePlatform @override Future querySourceFeatures( String sourceId, String? sourceLayerId, List? filter) async { - final Map parameters = {}; + final parameters = {}; if (sourceLayerId != null) { parameters['sourceLayer'] = sourceLayerId; @@ -535,9 +535,9 @@ class MapLibreMapController extends MapLibrePlatform if (_navigationControl != null) { prevShowCompass = _navigationControl!.options.showCompass; } - final String? prevPosition = _navigationControlPosition; + final prevPosition = _navigationControlPosition; - final String? positionString = switch (position) { + final positionString = switch (position) { CompassViewPosition.topRight => 'top-right', CompassViewPosition.topLeft => 'top-left', CompassViewPosition.bottomRight => 'bottom-right', @@ -545,8 +545,8 @@ class MapLibreMapController extends MapLibrePlatform _ => null, }; - final bool newShowCompass = compassEnabled ?? prevShowCompass ?? false; - final String? newPosition = positionString ?? prevPosition; + final newShowCompass = compassEnabled ?? prevShowCompass ?? false; + final newPosition = positionString ?? prevPosition; _removeNavigationControl(); _navigationControl = NavigationControl(NavigationControlOptions( diff --git a/maplibre_gl_web/lib/src/style/sources/vector_source.dart b/maplibre_gl_web/lib/src/style/sources/vector_source.dart index a554701b2..34af784bf 100644 --- a/maplibre_gl_web/lib/src/style/sources/vector_source.dart +++ b/maplibre_gl_web/lib/src/style/sources/vector_source.dart @@ -30,7 +30,7 @@ class VectorSource extends Source { @override get dict { - final Map dict = { + final dict = { 'type': 'vector', }; if (url != null) { diff --git a/scripts/lib/generate.dart b/scripts/lib/generate.dart index 633e696e9..ec4e8f877 100644 --- a/scripts/lib/generate.dart +++ b/scripts/lib/generate.dart @@ -197,7 +197,7 @@ List splitIntoChunks(String input, int lineLength, final words = input.split(" "); final chunks = []; - String chunk = ""; + var chunk = ""; for (final word in words) { final nextChunk = chunk.isEmpty ? prefix + word : "$chunk $word"; if (nextChunk.length > lineLength || chunk.endsWith("\n")) { From cd3b9904c093b71fb8208244ec137f0995e0fc6f Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 01:37:49 +0200 Subject: [PATCH 32/36] use_named_constants --- analysis_options.yaml | 1 - example/lib/annotation_order_maps.dart | 106 +++++++++--------- example/lib/place_symbol.dart | 2 +- .../lib/src/maplibre_web_gl_platform.dart | 2 +- 4 files changed, 52 insertions(+), 59 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index ad0175b5f..5d5c02b3c 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -35,4 +35,3 @@ linter: avoid_positional_boolean_parameters: false comment_references: false cascade_invocations: false - use_named_constants: false diff --git a/example/lib/annotation_order_maps.dart b/example/lib/annotation_order_maps.dart index 577a4072d..08c9c4635 100644 --- a/example/lib/annotation_order_maps.dart +++ b/example/lib/annotation_order_maps.dart @@ -31,71 +31,65 @@ class _AnnotationOrderBodyState extends State { return Column( children: [ Card( - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 0.0), - child: Column( - children: [ - const Padding( - padding: EdgeInsets.only(bottom: 5.0), - child: Text( - 'This map has polygones (fill) above all other anotations (default behavior)'), - ), - Center( - child: SizedBox( - width: 250.0, - height: 250.0, - child: MapLibreMap( - onMapCreated: onMapCreatedOne, - onStyleLoadedCallback: () => onStyleLoaded(controllerOne), - initialCameraPosition: CameraPosition( - target: center, - zoom: 5.0, - ), - annotationOrder: const { - AnnotationType.line, - AnnotationType.symbol, - AnnotationType.circle, - AnnotationType.fill, - }, + child: Column( + children: [ + const Padding( + padding: EdgeInsets.only(bottom: 5.0), + child: Text( + 'This map has polygones (fill) above all other anotations (default behavior)'), + ), + Center( + child: SizedBox( + width: 250.0, + height: 250.0, + child: MapLibreMap( + onMapCreated: onMapCreatedOne, + onStyleLoadedCallback: () => onStyleLoaded(controllerOne), + initialCameraPosition: CameraPosition( + target: center, + zoom: 5.0, ), + annotationOrder: const { + AnnotationType.line, + AnnotationType.symbol, + AnnotationType.circle, + AnnotationType.fill, + }, ), ), - ], - ), + ), + ], ), ), Card( - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 0.0), - child: Column( - children: [ - const Padding( - padding: EdgeInsets.only(bottom: 5.0, top: 5.0), - child: Text( - 'This map has polygones (fill) under all other anotations'), - ), - Center( - child: SizedBox( - width: 250.0, - height: 250.0, - child: MapLibreMap( - onMapCreated: onMapCreatedTwo, - onStyleLoadedCallback: () => onStyleLoaded(controllerTwo), - initialCameraPosition: CameraPosition( - target: center, - zoom: 5.0, - ), - annotationOrder: const { - AnnotationType.fill, - AnnotationType.line, - AnnotationType.symbol, - AnnotationType.circle, - }, + child: Column( + children: [ + const Padding( + padding: EdgeInsets.only(bottom: 5.0, top: 5.0), + child: Text( + 'This map has polygones (fill) under all other anotations'), + ), + Center( + child: SizedBox( + width: 250.0, + height: 250.0, + child: MapLibreMap( + onMapCreated: onMapCreatedTwo, + onStyleLoadedCallback: () => onStyleLoaded(controllerTwo), + initialCameraPosition: CameraPosition( + target: center, + zoom: 5.0, ), + annotationOrder: const { + AnnotationType.fill, + AnnotationType.line, + AnnotationType.symbol, + AnnotationType.circle, + }, ), ), - ], - ), + ), + ], ), ), ], diff --git a/example/lib/place_symbol.dart b/example/lib/place_symbol.dart index 13bb52bd2..da020cfc7 100644 --- a/example/lib/place_symbol.dart +++ b/example/lib/place_symbol.dart @@ -185,7 +185,7 @@ class PlaceSymbolBodyState extends State { void _changeIconOffset() { var currentAnchor = _selectedSymbol!.options.iconOffset; - currentAnchor ??= const Offset(0.0, 0.0); + currentAnchor ??= Offset.zero; final newAnchor = Offset(1.0 - currentAnchor.dy, currentAnchor.dx); _updateSelectedSymbol(SymbolOptions(iconOffset: newAnchor)); } diff --git a/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart b/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart index 2d977fb45..426f89f57 100644 --- a/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart +++ b/maplibre_gl_web/lib/src/maplibre_web_gl_platform.dart @@ -417,7 +417,7 @@ class MapLibreMapController extends MapLibrePlatform } void _onMapResize() { - Timer(const Duration(), () { + Timer(Duration.zero, () { final container = _map.getContainer(); final canvas = _map.getCanvas(); final widthMismatch = canvas.clientWidth != container.clientWidth; From a39ade9e9563252af5041bdf88f2afd7b18e296f Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Fri, 7 Jun 2024 01:38:12 +0200 Subject: [PATCH 33/36] dart format . --- example/lib/map_ui.dart | 4 +-- lib/src/controller.dart | 6 ++-- lib/src/global.dart | 28 ++++++++----------- lib/src/maplibre_map.dart | 8 ++---- .../lib/src/callbacks.dart | 3 +- .../lib/src/method_channel_maplibre_gl.dart | 4 +-- 6 files changed, 21 insertions(+), 32 deletions(-) diff --git a/example/lib/map_ui.dart b/example/lib/map_ui.dart index 21a29b5aa..8321fd501 100644 --- a/example/lib/map_ui.dart +++ b/example/lib/map_ui.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - import 'package:flutter/material.dart'; import 'package:collection/collection.dart'; import 'package:maplibre_gl/maplibre_gl.dart'; @@ -281,8 +280,7 @@ class MapUiBodyState extends State { if (!mounted) return; ScaffoldMessenger.of(context).showSnackBar(SnackBar( - content: Text( - "SW: ${result.southwest} NE: ${result.northeast}"), + content: Text("SW: ${result.southwest} NE: ${result.northeast}"), )); }, ); diff --git a/lib/src/controller.dart b/lib/src/controller.dart index 1974e8d2a..71a5e827f 100644 --- a/lib/src/controller.dart +++ b/lib/src/controller.dart @@ -910,8 +910,7 @@ class MapLibreMapController extends ChangeNotifier { /// The returned [Future] completes with the added circle once listeners have /// been notified. Future addCircle(CircleOptions options, [Map? data]) async { - final effectiveOptions = - CircleOptions.defaultOptions.copyWith(options); + final effectiveOptions = CircleOptions.defaultOptions.copyWith(options); final circle = Circle(getRandomString(), effectiveOptions, data); await circleManager!.add(circle); notifyListeners(); @@ -1005,8 +1004,7 @@ class MapLibreMapController extends ChangeNotifier { /// The returned [Future] completes with the added fill once listeners have /// been notified. Future addFill(FillOptions options, [Map? data]) async { - final effectiveOptions = - FillOptions.defaultOptions.copyWith(options); + final effectiveOptions = FillOptions.defaultOptions.copyWith(options); final fill = Fill(getRandomString(), effectiveOptions, data); await fillManager!.add(fill); notifyListeners(); diff --git a/lib/src/global.dart b/lib/src/global.dart index 71c70226e..ab10ba6f9 100644 --- a/lib/src/global.dart +++ b/lib/src/global.dart @@ -19,8 +19,7 @@ Future installOfflineMapTiles(String tilesDb) async { enum DragEventType { start, drag, end } -Future setOffline(bool offline) => - _globalChannel.invokeMethod( +Future setOffline(bool offline) => _globalChannel.invokeMethod( 'setOffline', { 'offline': offline, @@ -56,8 +55,8 @@ Future> getListOfRegions() async { return regions.map((region) => OfflineRegion.fromMap(region)).toList(); } -Future updateOfflineRegionMetadata(int id, - Map metadata) async { +Future updateOfflineRegionMetadata( + int id, Map metadata) async { final regionJson = await _globalChannel.invokeMethod( 'updateOfflineRegionMetadata', { @@ -77,23 +76,20 @@ Future setOfflineTileCountLimit(int limit) => }, ); -Future deleteOfflineRegion(int id) => - _globalChannel.invokeMethod( +Future deleteOfflineRegion(int id) => _globalChannel.invokeMethod( 'deleteOfflineRegion', { 'id': id, }, ); -Future downloadOfflineRegion(OfflineRegionDefinition definition, - { - Map metadata = const {}, - Function(DownloadRegionStatus event)? onEvent, - }) async { +Future downloadOfflineRegion( + OfflineRegionDefinition definition, { + Map metadata = const {}, + Function(DownloadRegionStatus event)? onEvent, +}) async { final channelName = - 'downloadOfflineRegion_${DateTime - .now() - .microsecondsSinceEpoch}'; + 'downloadOfflineRegion_${DateTime.now().microsecondsSinceEpoch}'; await _globalChannel .invokeMethod('downloadOfflineRegion#setup', { @@ -110,7 +106,7 @@ Future downloadOfflineRegion(OfflineRegionDefinition definition, PlatformException( code: 'UnknowException', message: - 'This error is unhandled by plugin. Please contact us if needed.', + 'This error is unhandled by plugin. Please contact us if needed.', details: error, ), ); @@ -122,7 +118,7 @@ Future downloadOfflineRegion(OfflineRegionDefinition definition, 'start' => InProgress(0.0), 'progress' => InProgress((jsonData['progress']! as num).toDouble()), 'success' => Success(), - _ => throw Exception('Invalid event status ${jsonData['status']}'), + _ => throw Exception('Invalid event status ${jsonData['status']}'), }; onEvent(status); }); diff --git a/lib/src/maplibre_map.dart b/lib/src/maplibre_map.dart index daf9e8d20..f3dd0fa54 100644 --- a/lib/src/maplibre_map.dart +++ b/lib/src/maplibre_map.dart @@ -52,7 +52,7 @@ class MapLibreMap extends StatefulWidget { AnnotationType.symbol, AnnotationType.circle, AnnotationType.fill, -}, + }, this.annotationConsumeTapEvents = const { AnnotationType.symbol, AnnotationType.fill, @@ -294,10 +294,8 @@ class _MapLibreMapState extends State { @override void didUpdateWidget(MapLibreMap oldWidget) { super.didUpdateWidget(oldWidget); - final newOptions = - _MapLibreMapOptions.fromWidget(widget); - final updates = - _maplibreMapOptions.updatesMap(newOptions); + final newOptions = _MapLibreMapOptions.fromWidget(widget); + final updates = _maplibreMapOptions.updatesMap(newOptions); _updateOptions(updates); _maplibreMapOptions = newOptions; } diff --git a/maplibre_gl_platform_interface/lib/src/callbacks.dart b/maplibre_gl_platform_interface/lib/src/callbacks.dart index e7a177b8c..fe3bd9cdd 100644 --- a/maplibre_gl_platform_interface/lib/src/callbacks.dart +++ b/maplibre_gl_platform_interface/lib/src/callbacks.dart @@ -27,8 +27,7 @@ class ArgumentCallbacks { if (length == 1) { _callbacks[0].call(argument); } else if (0 < length) { - for (final callback - in List>.from(_callbacks)) { + for (final callback in List>.from(_callbacks)) { callback(argument); } } diff --git a/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart b/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart index aa480ef04..d2b4ccccd 100644 --- a/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart +++ b/maplibre_gl_platform_interface/lib/src/method_channel_maplibre_gl.dart @@ -324,8 +324,8 @@ class MapLibreMethodChannel extends MapLibrePlatform { @override Future requestMyLocationLatLng() async { try { - final Map reply = await _channel.invokeMethod( - 'locationComponent#getLastLocation'); + final Map reply = + await _channel.invokeMethod('locationComponent#getLastLocation'); var latitude = 0.0; var longitude = 0.0; if (reply.containsKey('latitude') && reply['latitude'] != null) { From e76778d58fb4dbe5d5ea5cae37b38839c93ab8e6 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Mon, 24 Jun 2024 11:06:31 +0200 Subject: [PATCH 34/36] revert 00c1d3eac215adafa529942cd519c11131d9330b: prefer_asserts_with_message --- analysis_options.yaml | 1 + example/lib/annotation_order_maps.dart | 8 ++++---- example/lib/click_annotations.dart | 4 ++-- example/lib/get_map_informations.dart | 2 +- example/lib/layer.dart | 2 +- example/lib/place_batch.dart | 4 ++-- maplibre_gl/lib/src/maplibre_map.dart | 16 +++++++--------- .../lib/src/location.dart | 6 +----- maplibre_gl_platform_interface/lib/src/ui.dart | 5 +---- 9 files changed, 20 insertions(+), 28 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 5d5c02b3c..90048b4bb 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -24,6 +24,7 @@ linter: parameter_assignments: false use_setters_to_change_properties: false type_annotate_public_apis: false + prefer_asserts_with_message: false public_member_api_docs: false require_trailing_commas: false avoid_dynamic_calls: false diff --git a/example/lib/annotation_order_maps.dart b/example/lib/annotation_order_maps.dart index 08c9c4635..a077757d3 100644 --- a/example/lib/annotation_order_maps.dart +++ b/example/lib/annotation_order_maps.dart @@ -49,12 +49,12 @@ class _AnnotationOrderBodyState extends State { target: center, zoom: 5.0, ), - annotationOrder: const { + annotationOrder: const [ AnnotationType.line, AnnotationType.symbol, AnnotationType.circle, AnnotationType.fill, - }, + ], ), ), ), @@ -80,12 +80,12 @@ class _AnnotationOrderBodyState extends State { target: center, zoom: 5.0, ), - annotationOrder: const { + annotationOrder: const [ AnnotationType.fill, AnnotationType.line, AnnotationType.symbol, AnnotationType.circle, - }, + ], ), ), ), diff --git a/example/lib/click_annotations.dart b/example/lib/click_annotations.dart index 822f18937..93a5a41b0 100644 --- a/example/lib/click_annotations.dart +++ b/example/lib/click_annotations.dart @@ -140,12 +140,12 @@ class ClickAnnotationBodyState extends State { @override Widget build(BuildContext context) { return MapLibreMap( - annotationOrder: const { + annotationOrder: const [ AnnotationType.fill, AnnotationType.line, AnnotationType.circle, AnnotationType.symbol, - }, + ], onMapCreated: _onMapCreated, onStyleLoadedCallback: _onStyleLoaded, initialCameraPosition: const CameraPosition( diff --git a/example/lib/get_map_informations.dart b/example/lib/get_map_informations.dart index 9109f3de3..5819f741d 100644 --- a/example/lib/get_map_informations.dart +++ b/example/lib/get_map_informations.dart @@ -67,7 +67,7 @@ class _GetMapInfoBodyState extends State { ), onMapCreated: onMapCreated, compassEnabled: false, - annotationOrder: const {}, + annotationOrder: const [], myLocationEnabled: false, styleString: '''{ "version": 8, diff --git a/example/lib/layer.dart b/example/lib/layer.dart index 9d39d38fc..7a03fb471 100644 --- a/example/lib/layer.dart +++ b/example/lib/layer.dart @@ -54,7 +54,7 @@ class LayerState extends State { target: center, zoom: 11.0, ), - annotationOrder: const {}, + annotationOrder: const [], )), ), TextButton( diff --git a/example/lib/place_batch.dart b/example/lib/place_batch.dart index 0e27c96eb..6fac0535c 100644 --- a/example/lib/place_batch.dart +++ b/example/lib/place_batch.dart @@ -156,12 +156,12 @@ class BatchAddBodyState extends State { target: LatLng(-33.8, 151.511), zoom: 8.2, ), - annotationOrder: const { + annotationOrder: const [ AnnotationType.fill, AnnotationType.line, AnnotationType.circle, AnnotationType.symbol, - }, + ], ), ), ), diff --git a/maplibre_gl/lib/src/maplibre_map.dart b/maplibre_gl/lib/src/maplibre_map.dart index f3dd0fa54..62c14a614 100644 --- a/maplibre_gl/lib/src/maplibre_map.dart +++ b/maplibre_gl/lib/src/maplibre_map.dart @@ -47,27 +47,25 @@ class MapLibreMap extends StatefulWidget { this.onCameraTrackingChanged, this.onCameraIdle, this.onMapIdle, - this.annotationOrder = const { + this.annotationOrder = const [ AnnotationType.line, AnnotationType.symbol, AnnotationType.circle, AnnotationType.fill, }, - this.annotationConsumeTapEvents = const { + this.annotationConsumeTapEvents = const [ AnnotationType.symbol, AnnotationType.fill, AnnotationType.line, AnnotationType.circle, - }, + ], }) : assert( myLocationRenderMode == MyLocationRenderMode.normal || myLocationEnabled, "$myLocationRenderMode requires [myLocationEnabled] set to true.", ), - assert( - annotationConsumeTapEvents.length > 0, - 'annotationConsumeTapEvents must contain at least 1 annotation type', - ); + assert(annotationOrder.length <= 4), + assert(annotationConsumeTapEvents.length > 0); /// Defines the layer order of annotations displayed on map /// @@ -75,12 +73,12 @@ class MapLibreMap extends StatefulWidget { /// /// Note that setting this to be empty gives a big perfomance boost for /// android. However if you do so annotations will not work. - final Set annotationOrder; + final List annotationOrder; /// Defines the layer order of click annotations /// /// (must contain at least 1 annotation type, 4 items max) - final Set annotationConsumeTapEvents; + final List annotationConsumeTapEvents; /// Please note: you should only add annotations (e.g. symbols or circles) after `onStyleLoadedCallback` has been called. final MapCreatedCallback? onMapCreated; diff --git a/maplibre_gl_platform_interface/lib/src/location.dart b/maplibre_gl_platform_interface/lib/src/location.dart index 60baa092d..d8b540aa9 100644 --- a/maplibre_gl_platform_interface/lib/src/location.dart +++ b/maplibre_gl_platform_interface/lib/src/location.dart @@ -72,11 +72,7 @@ class LatLngBounds { /// The latitude of the southwest corner cannot be larger than the /// latitude of the northeast corner. LatLngBounds({required this.southwest, required this.northeast}) - : assert( - southwest.latitude <= northeast.latitude, - 'The latitude of the southwest corner cannot be larger than the ' - 'latitude of the northeast corner.', - ); + : assert(southwest.latitude <= northeast.latitude); /// The southwest corner of the rectangle. final LatLng southwest; diff --git a/maplibre_gl_platform_interface/lib/src/ui.dart b/maplibre_gl_platform_interface/lib/src/ui.dart index 5b7a964dc..abeebfc98 100644 --- a/maplibre_gl_platform_interface/lib/src/ui.dart +++ b/maplibre_gl_platform_interface/lib/src/ui.dart @@ -83,10 +83,7 @@ class CameraTargetBounds { @immutable class MinMaxZoomPreference { const MinMaxZoomPreference(this.minZoom, this.maxZoom) - : assert( - minZoom == null || maxZoom == null || minZoom <= maxZoom, - 'minZoom cannot be larger than maxZoom.', - ); + : assert(minZoom == null || maxZoom == null || minZoom <= maxZoom); /// The preferred minimum zoom level or null, if unbounded from below. final double? minZoom; From 6ef2eef7f415b54e5e1cf5d7a781f9b7c493652a Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Mon, 24 Jun 2024 11:09:11 +0200 Subject: [PATCH 35/36] revert 27eaca2447cbd704cf1110e6816b9ea8d472060e: avoid_unused_constructor_parameters --- analysis_options.yaml | 1 + maplibre_gl_web/lib/src/ui/map.dart | 1 + 2 files changed, 2 insertions(+) diff --git a/analysis_options.yaml b/analysis_options.yaml index 90048b4bb..db6a211fe 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -16,6 +16,7 @@ linter: prefer_int_literals: false unnecessary_lambdas: false avoid_print: false + avoid_unused_constructor_parameters: false unawaited_futures: false overridden_fields: false always_put_required_named_parameters_first: false diff --git a/maplibre_gl_web/lib/src/ui/map.dart b/maplibre_gl_web/lib/src/ui/map.dart index 8d4123bc1..27f29395c 100644 --- a/maplibre_gl_web/lib/src/ui/map.dart +++ b/maplibre_gl_web/lib/src/ui/map.dart @@ -1205,6 +1205,7 @@ class MapOptions extends JsObjectWrapper { dynamic get locale => jsObject.locale; factory MapOptions({ + dynamic hash, bool? interactive, dynamic container, num? bearingSnap, From 7d0509af1aea8118ae619063617e81bd5e215b10 Mon Sep 17 00:00:00 2001 From: Joscha <34318751+josxha@users.noreply.github.com> Date: Mon, 24 Jun 2024 11:15:06 +0200 Subject: [PATCH 36/36] fix bad revert --- maplibre_gl/lib/src/maplibre_map.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maplibre_gl/lib/src/maplibre_map.dart b/maplibre_gl/lib/src/maplibre_map.dart index 62c14a614..15a9aebf1 100644 --- a/maplibre_gl/lib/src/maplibre_map.dart +++ b/maplibre_gl/lib/src/maplibre_map.dart @@ -52,7 +52,7 @@ class MapLibreMap extends StatefulWidget { AnnotationType.symbol, AnnotationType.circle, AnnotationType.fill, - }, + ], this.annotationConsumeTapEvents = const [ AnnotationType.symbol, AnnotationType.fill,