diff --git a/example/android/build.gradle b/example/android/build.gradle index b5ae9fa3f..7a18e6b5c 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,5 +1,5 @@ buildscript { - ext.kotlin_version = '1.6.20' + ext.kotlin_version = '1.8.21' repositories { google() jcenter() diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index 595fb867a..02e5f5817 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip diff --git a/example/lib/pages/marker_anchor.dart b/example/lib/pages/marker_anchor.dart index e47c7010b..efda278d1 100644 --- a/example/lib/pages/marker_anchor.dart +++ b/example/lib/pages/marker_anchor.dart @@ -15,7 +15,7 @@ class MarkerAnchorPage extends StatefulWidget { } class MarkerAnchorPageState extends State { - late AnchorPos anchorPos; + late AnchorPos anchorPos; @override void initState() { diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 7f3e0afc5..6e60dbfb8 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -4,7 +4,7 @@ publish_to: "none" version: 5.0.0 environment: - sdk: ">=2.18.0 <4.0.0" + sdk: ">=3.0.0 <4.0.0" flutter: ">=3.10.0" dependencies: diff --git a/lib/src/core/point.dart b/lib/src/core/point.dart index d389da9d1..c66b436be 100644 --- a/lib/src/core/point.dart +++ b/lib/src/core/point.dart @@ -80,9 +80,4 @@ class CustomPoint extends math.Point { @override String toString() => 'CustomPoint ($x, $y)'; - - /// Create new [CustomPoint] with [x] and [y] multiplied by [n] - CustomPoint multiplyBy(num n) { - return this * n; - } } diff --git a/lib/src/geo/crs/crs.dart b/lib/src/geo/crs/crs.dart index ec5d7bcd2..4aec56c30 100644 --- a/lib/src/geo/crs/crs.dart +++ b/lib/src/geo/crs/crs.dart @@ -5,7 +5,6 @@ import 'package:flutter_map/src/core/point.dart'; import 'package:latlong2/latlong.dart'; import 'package:meta/meta.dart'; import 'package:proj4dart/proj4dart.dart' as proj4; -import 'package:tuple/tuple.dart'; /// An abstract representation of a /// [Coordinate Reference System](https://bit.ly/3iVKpja). @@ -68,9 +67,9 @@ abstract class Crs { bool get infinite; - Tuple2? get wrapLng; + (double, double)? get wrapLng; - Tuple2? get wrapLat; + (double, double)? get wrapLat; } // Custom CRS for non geographical maps @@ -93,10 +92,10 @@ class CrsSimple extends Crs { bool get infinite => false; @override - Tuple2? get wrapLat => null; + (double, double)? get wrapLat => null; @override - Tuple2? get wrapLng => null; + (double, double)? get wrapLng => null; } abstract class Earth extends Crs { @@ -104,10 +103,10 @@ abstract class Earth extends Crs { bool get infinite => false; @override - final Tuple2 wrapLng = const Tuple2(-180, 180); + final (double, double) wrapLng = const (-180, 180); @override - final Tuple2? wrapLat = null; + final (double, double)? wrapLat = null; const Earth() : super(); } @@ -132,7 +131,7 @@ class Epsg3857 extends Earth { // Epsg3857 seems to have latitude limits. https://epsg.io/3857 //@override -//Tuple2 get wrapLat => const Tuple2(-85.06, 85.06); +//(double, double) get wrapLat => const (-85.06, 85.06); } /// A common CRS among GIS enthusiasts. Uses simple Equirectangular projection. @@ -167,10 +166,10 @@ class Proj4Crs extends Crs { final bool infinite; @override - final Tuple2? wrapLat = null; + final (double, double)? wrapLat = null; @override - final Tuple2? wrapLng = null; + final (double, double)? wrapLng = null; final List? _transformations; diff --git a/lib/src/gestures/map_events.dart b/lib/src/gestures/map_events.dart index 2b701c3e2..6683a33ba 100644 --- a/lib/src/gestures/map_events.dart +++ b/lib/src/gestures/map_events.dart @@ -72,48 +72,44 @@ abstract class MapEventWithMove extends MapEvent { required bool hasGesture, required MapEventSource source, String? id, - }) { - switch (source) { - case MapEventSource.flingAnimationController: - return MapEventFlingAnimation( - center: oldCenter, - zoom: oldZoom, - targetCenter: targetCenter, - targetZoom: targetZoom, - source: source, - ); - case MapEventSource.doubleTapZoomAnimationController: - return MapEventDoubleTapZoom( - center: oldCenter, - zoom: oldZoom, - targetCenter: targetCenter, - targetZoom: targetZoom, - source: source, - ); - case MapEventSource.scrollWheel: - return MapEventScrollWheelZoom( - center: oldCenter, - zoom: oldZoom, - targetCenter: targetCenter, - targetZoom: targetZoom, - source: source, - ); - case MapEventSource.onDrag: - case MapEventSource.onMultiFinger: - case MapEventSource.mapController: - case MapEventSource.custom: - return MapEventMove( - id: id, - center: oldCenter, - zoom: oldZoom, - targetCenter: targetCenter, - targetZoom: targetZoom, - source: source, - ); - default: - return null; - } - } + }) => + switch (source) { + MapEventSource.flingAnimationController => MapEventFlingAnimation( + center: oldCenter, + zoom: oldZoom, + targetCenter: targetCenter, + targetZoom: targetZoom, + source: source, + ), + MapEventSource.doubleTapZoomAnimationController => + MapEventDoubleTapZoom( + center: oldCenter, + zoom: oldZoom, + targetCenter: targetCenter, + targetZoom: targetZoom, + source: source, + ), + MapEventSource.scrollWheel => MapEventScrollWheelZoom( + center: oldCenter, + zoom: oldZoom, + targetCenter: targetCenter, + targetZoom: targetZoom, + source: source, + ), + MapEventSource.onDrag || + MapEventSource.onMultiFinger || + MapEventSource.mapController || + MapEventSource.custom => + MapEventMove( + id: id, + center: oldCenter, + zoom: oldZoom, + targetCenter: targetCenter, + targetZoom: targetZoom, + source: source, + ), + _ => null, + }; } /// Event which is fired when map is tapped diff --git a/lib/src/layer/attribution_layer/animation.dart b/lib/src/layer/attribution_layer/animation.dart index 0c5a973c5..cf45b4b35 100644 --- a/lib/src/layer/attribution_layer/animation.dart +++ b/lib/src/layer/attribution_layer/animation.dart @@ -11,7 +11,7 @@ import 'package:flutter_map/src/layer/attribution_layer/rich.dart'; /// [AnimatedSwitcher], but its curve and duration can still be customized /// through [buttonDuration] and [buttonCurve]. /// -/// Can be extensivley customized by implementing a custom +/// Can be extensively customized by implementing a custom /// [RichAttributionWidgetAnimation], or the prebuilt [FadeRAWA] and /// [ScaleRAWA] animations can be used with limited customization. abstract class RichAttributionWidgetAnimation { diff --git a/lib/src/layer/label.dart b/lib/src/layer/label.dart index 31d951c05..16387e7c5 100644 --- a/lib/src/layer/label.dart +++ b/lib/src/layer/label.dart @@ -15,15 +15,10 @@ class Label { bool rotate = false, PolygonLabelPlacement labelPlacement = PolygonLabelPlacement.polylabel, }) { - late Offset placementPoint; - switch (labelPlacement) { - case PolygonLabelPlacement.centroid: - placementPoint = _computeCentroid(points); - break; - case PolygonLabelPlacement.polylabel: - placementPoint = _computePolylabel(points); - break; - } + final placementPoint = switch (labelPlacement) { + PolygonLabelPlacement.centroid => _computeCentroid(points), + PolygonLabelPlacement.polylabel => _computePolylabel(points), + }; var dx = placementPoint.dx; var dy = placementPoint.dy; diff --git a/lib/src/layer/marker_layer.dart b/lib/src/layer/marker_layer.dart index 265b0268f..af09e4a32 100644 --- a/lib/src/layer/marker_layer.dart +++ b/lib/src/layer/marker_layer.dart @@ -14,51 +14,34 @@ class Anchor { : left = _leftOffset(width, alignOpt), top = _topOffset(height, alignOpt); - static double _leftOffset(double width, AnchorAlign alignOpt) { - switch (alignOpt) { - case AnchorAlign.left: - return 0; - case AnchorAlign.right: - return width; - case AnchorAlign.top: - case AnchorAlign.bottom: - case AnchorAlign.center: - default: - return width / 2; - } - } - - static double _topOffset(double height, AnchorAlign alignOpt) { - switch (alignOpt) { - case AnchorAlign.top: - return 0; - case AnchorAlign.bottom: - return height; - case AnchorAlign.left: - case AnchorAlign.right: - case AnchorAlign.center: - default: - return height / 2; - } - } - - factory Anchor.forPos(AnchorPos? pos, double width, double height) { + static double _leftOffset(double width, AnchorAlign alignOpt) => + switch (alignOpt) { + AnchorAlign.left => 0, + AnchorAlign.right => width, + _ => width / 2, + }; + + static double _topOffset(double height, AnchorAlign alignOpt) => + switch (alignOpt) { + AnchorAlign.top => 0, + AnchorAlign.bottom => height, + _ => height / 2, + }; + + factory Anchor.forPos(AnchorPos? pos, double width, double height) { if (pos == null) return Anchor._(width, height, AnchorAlign.none); - if (pos.value is AnchorAlign) { - return Anchor._(width, height, pos.value as AnchorAlign); - } - if (pos.value is Anchor) return pos.value as Anchor; - throw Exception('Unsupported AnchorPos value type: ${pos.runtimeType}.'); + if (pos.alignment case final align?) return Anchor._(width, height, align); + if (pos.anchor case final anchor?) return anchor; + throw Exception(); } } -class AnchorPos { - AnchorPos._(this.value); - T value; - static AnchorPos exactly(Anchor anchor) => - AnchorPos._(anchor); - static AnchorPos align(AnchorAlign alignOpt) => - AnchorPos._(alignOpt); +class AnchorPos { + final Anchor? anchor; + final AnchorAlign? alignment; + + AnchorPos.exactly(this.anchor) : alignment = null; + AnchorPos.align(this.alignment) : anchor = null; } enum AnchorAlign { @@ -119,7 +102,7 @@ class Marker { this.rotate, this.rotateOrigin, this.rotateAlignment, - AnchorPos? anchorPos, + AnchorPos? anchorPos, }) : anchor = Anchor.forPos(anchorPos, width, height); } diff --git a/lib/src/layer/tile_layer/tile_bounds/tile_bounds.dart b/lib/src/layer/tile_layer/tile_bounds/tile_bounds.dart index f7c93412a..1799e52ac 100644 --- a/lib/src/layer/tile_layer/tile_bounds/tile_bounds.dart +++ b/lib/src/layer/tile_layer/tile_bounds/tile_bounds.dart @@ -4,7 +4,6 @@ import 'package:flutter_map/src/geo/latlng_bounds.dart'; import 'package:flutter_map/src/layer/tile_layer/tile_bounds/tile_bounds_at_zoom.dart'; import 'package:flutter_map/src/layer/tile_layer/tile_range.dart'; import 'package:latlong2/latlong.dart'; -import 'package:tuple/tuple.dart'; abstract class TileBounds { final Crs crs; @@ -124,30 +123,26 @@ class WrappedTileBounds extends TileBounds { final tzDouble = zoom.toDouble(); - Tuple2? wrapX; - if (crs.wrapLng != null) { + (int, int)? wrapX; + if (crs.wrapLng case final wrapLng?) { final wrapXMin = - (crs.latLngToPoint(LatLng(0, crs.wrapLng!.item1), tzDouble).x / - _tileSize) + (crs.latLngToPoint(LatLng(0, wrapLng.$1), tzDouble).x / _tileSize) .floor(); final wrapXMax = - (crs.latLngToPoint(LatLng(0, crs.wrapLng!.item2), tzDouble).x / - _tileSize) + (crs.latLngToPoint(LatLng(0, wrapLng.$2), tzDouble).x / _tileSize) .ceil(); - wrapX = Tuple2(wrapXMin, wrapXMax - 1); + wrapX = (wrapXMin, wrapXMax - 1); } - Tuple2? wrapY; - if (crs.wrapLat != null) { + (int, int)? wrapY; + if (crs.wrapLat case final wrapLat?) { final wrapYMin = - (crs.latLngToPoint(LatLng(crs.wrapLat!.item1, 0), tzDouble).y / - _tileSize) + (crs.latLngToPoint(LatLng(wrapLat.$1, 0), tzDouble).y / _tileSize) .floor(); final wrapYMax = - (crs.latLngToPoint(LatLng(crs.wrapLat!.item2, 0), tzDouble).y / - _tileSize) + (crs.latLngToPoint(LatLng(wrapLat.$2, 0), tzDouble).y / _tileSize) .ceil(); - wrapY = Tuple2(wrapYMin, wrapYMax - 1); + wrapY = (wrapYMin, wrapYMax - 1); } return WrappedTileBoundsAtZoom( diff --git a/lib/src/layer/tile_layer/tile_bounds/tile_bounds_at_zoom.dart b/lib/src/layer/tile_layer/tile_bounds/tile_bounds_at_zoom.dart index 4920a1f10..e8b70aceb 100644 --- a/lib/src/layer/tile_layer/tile_bounds/tile_bounds_at_zoom.dart +++ b/lib/src/layer/tile_layer/tile_bounds/tile_bounds_at_zoom.dart @@ -1,7 +1,6 @@ import 'package:flutter_map/src/core/point.dart'; import 'package:flutter_map/src/layer/tile_layer/tile_coordinates.dart'; import 'package:flutter_map/src/layer/tile_layer/tile_range.dart'; -import 'package:tuple/tuple.dart'; abstract class TileBoundsAtZoom { const TileBoundsAtZoom(); @@ -46,8 +45,8 @@ class DiscreteTileBoundsAtZoom extends TileBoundsAtZoom { class WrappedTileBoundsAtZoom extends TileBoundsAtZoom { final DiscreteTileRange tileRange; final bool wrappedAxisIsAlwaysInBounds; - final Tuple2? wrapX; - final Tuple2? wrapY; + final (int, int)? wrapX; + final (int, int)? wrapY; const WrappedTileBoundsAtZoom({ required this.tileRange, @@ -120,9 +119,9 @@ class WrappedTileBoundsAtZoom extends TileBoundsAtZoom { } /// Wrap [x] to be within [range] inclusive. - int _wrapInt(int x, Tuple2 range) { - final d = range.item2 + 1 - range.item1; - return ((x - range.item1) % d + d) % d + range.item1; + int _wrapInt(int x, (int, int) range) { + final d = range.$2 + 1 - range.$1; + return ((x - range.$1) % d + d) % d + range.$1; } @override diff --git a/lib/src/layer/tile_layer/tile_coordinates.dart b/lib/src/layer/tile_layer/tile_coordinates.dart index 0d019b570..61929b6f4 100644 --- a/lib/src/layer/tile_layer/tile_coordinates.dart +++ b/lib/src/layer/tile_layer/tile_coordinates.dart @@ -5,7 +5,7 @@ import 'package:flutter_map/flutter_map.dart'; class TileCoordinates extends CustomPoint { final int z; - const TileCoordinates(int x, int y, this.z) : super(x, y); + const TileCoordinates(super.x, super.y, this.z); String get key => '$x:$y:$z'; diff --git a/lib/src/layer/tile_layer/tile_display.dart b/lib/src/layer/tile_layer/tile_display.dart index ca96c4aa6..b203cb91b 100644 --- a/lib/src/layer/tile_layer/tile_display.dart +++ b/lib/src/layer/tile_layer/tile_display.dart @@ -1,6 +1,6 @@ import 'package:flutter_map/src/layer/tile_layer/tile_layer.dart'; -abstract class TileDisplay { +sealed class TileDisplay { const TileDisplay(); // Instantly display tiles once they are loaded without a fade animation. @@ -42,17 +42,16 @@ abstract class TileDisplay { double reloadStartOpacity, }) = FadeInTileDisplay._; - T? map({ + /// Output a value of type [T] dependent on [this] and its type + T? when({ T? Function(InstantaneousTileDisplay instantaneous)? instantaneous, T? Function(FadeInTileDisplay fadeIn)? fadeIn, }) { - switch (runtimeType) { - case InstantaneousTileDisplay: - return instantaneous?.call(this as InstantaneousTileDisplay); - case FadeInTileDisplay: - return fadeIn?.call(this as FadeInTileDisplay); - } - return null; + final display = this; + return switch (display) { + InstantaneousTileDisplay() => instantaneous?.call(display), + FadeInTileDisplay() => fadeIn?.call(display), + }; } } diff --git a/lib/src/layer/tile_layer/tile_image.dart b/lib/src/layer/tile_layer/tile_image.dart index 00e242c11..a75fdf68d 100644 --- a/lib/src/layer/tile_layer/tile_image.dart +++ b/lib/src/layer/tile_layer/tile_image.dart @@ -71,7 +71,7 @@ class TileImage extends ChangeNotifier { required TileDisplay tileDisplay, required this.errorImage, }) : _display = tileDisplay, - _animationController = tileDisplay.map( + _animationController = tileDisplay.when( instantaneous: (_) => null, fadeIn: (fadeIn) => AnimationController( vsync: vsync, @@ -79,7 +79,7 @@ class TileImage extends ChangeNotifier { ), ); - double get opacity => _display.map( + double get opacity => _display.when( instantaneous: (instantaneous) => _active ? instantaneous.opacity : 0.0, fadeIn: (fadeIn) => _animationController!.value, )!; @@ -100,9 +100,9 @@ class TileImage extends ChangeNotifier { _display = newTileDisplay; // Handle disabling/enabling of animation controller if necessary - oldTileDisplay.map( + oldTileDisplay.when( instantaneous: (instantaneous) { - newTileDisplay.map( + newTileDisplay.when( fadeIn: (fadeIn) { // Became animated. _animationController = AnimationController( @@ -114,7 +114,7 @@ class TileImage extends ChangeNotifier { ); }, fadeIn: (fadeIn) { - newTileDisplay.map(instantaneous: (instantaneous) { + newTileDisplay.when(instantaneous: (instantaneous) { // No longer animated. _animationController!.dispose(); _animationController = null; @@ -175,7 +175,7 @@ class TileImage extends ChangeNotifier { final previouslyLoaded = loadFinishedAt != null; loadFinishedAt = DateTime.now(); - _display.map( + _display.when( instantaneous: (_) { _active = true; if (!_disposed) notifyListeners(); diff --git a/lib/src/layer/tile_layer/tile_layer.dart b/lib/src/layer/tile_layer/tile_layer.dart index 4ba49fde0..21833042e 100644 --- a/lib/src/layer/tile_layer/tile_layer.dart +++ b/lib/src/layer/tile_layer/tile_layer.dart @@ -258,7 +258,7 @@ class TileLayer extends StatefulWidget { TileUpdateTransformer? tileUpdateTransformer, String userAgentPackageName = 'unknown', }) : assert( - tileDisplay.map( + tileDisplay.when( instantaneous: (_) => true, fadeIn: (fadeIn) => fadeIn.duration > Duration.zero)!, ), @@ -638,7 +638,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { return; } - widget.tileDisplay.map(instantaneous: (_) { + widget.tileDisplay.when(instantaneous: (_) { _tileImageManager.prune(widget.evictErrorTileStrategy); }, fadeIn: (fadeIn) { // Wait a bit more than tileFadeInDuration to trigger a pruning so that diff --git a/lib/src/layer/tile_layer/tile_update_transformer.dart b/lib/src/layer/tile_layer/tile_update_transformer.dart index 953c94148..57d7ac8a2 100644 --- a/lib/src/layer/tile_layer/tile_update_transformer.dart +++ b/lib/src/layer/tile_layer/tile_update_transformer.dart @@ -2,31 +2,57 @@ import 'dart:async'; import 'package:flutter_map/src/core/util.dart'; import 'package:flutter_map/src/gestures/map_events.dart'; +import 'package:flutter_map/src/layer/tile_layer/tile_layer.dart'; import 'package:flutter_map/src/layer/tile_layer/tile_update_event.dart'; +/// Defines which [TileUpdateEvent]s should cause which [TileUpdateEvent]s and +/// when +/// +/// [TileUpdateTransformers] defines a default set of transformers. +/// +/// If needed, build your own using [StreamTransformer.fromHandlers], adding +/// [TileUpdateEvent]s to the exposed [EventSink] if the event should cause an +/// update. typedef TileUpdateTransformer = StreamTransformer; -class TileUpdateTransformers { - const TileUpdateTransformers._(); - - /// Avoid loading/updating tiles when a tap occurs on the assumption that it - /// should not cause new tiles to be loaded. +/// Set of default [TileUpdateTransformer]s +abstract class TileUpdateTransformers { + /// Always load/update/prune tiles on events, except where the event is one of: + /// - [MapEventTap] + /// - [MapEventSecondaryTap] + /// - [MapEventLongPress] + /// + /// It is assumed (/guaranteed) that these events should not cause the map to + /// move, and therefore, tile changes are not required. + /// + /// Default transformer for [TileLayer]. static final ignoreTapEvents = TileUpdateTransformer.fromHandlers(handleData: (event, sink) { if (!_triggeredByTap(event)) sink.add(event); }); - /// Always load and update tiles for every map event. + /// This feature is deprecated since v5. + /// + /// Prefer `ignoreTapEvents` instead. This transformer produces theoretically + /// unnecessary tile updates which can harm performance. If you notice a + /// difference in behaviour, please open a bug report on GitHub. + @Deprecated( + 'Prefer `ignoreTapEvents` instead. ' + 'This transformer produces theoretically unnecessary tile updates which can harm performance. ' + 'If you notice a difference in behaviour, please open a bug report on GitHub. ' + 'This feature is deprecated since v5.', + ) static final alwaysLoadAndPrune = TileUpdateTransformer.fromHandlers(handleData: (event, sink) { sink.add(event); }); - /// Throttle updates such that maximum one per [duration] is emitted. + /// Throttle loading/updating/pruning tiles such that it only occurs once per + /// [duration] static TileUpdateTransformer throttle( Duration duration, { - /// If true tap events will be filtered out. + /// Whether to filter tap events as [ignoreTapEvents] does bool ignoreTapEvents = true, }) => throttleStreamTransformerWithTrailingCall( diff --git a/pubspec.yaml b/pubspec.yaml index 2d9250cc4..be6850bf0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -7,7 +7,7 @@ issue_tracker: https://github.com/fleaflet/flutter_map/issues documentation: https://docs.fleaflet.dev environment: - sdk: ">=2.18.0 <4.0.0" + sdk: ">=3.0.0 <4.0.0" flutter: ">=3.10.0" dependencies: @@ -20,7 +20,6 @@ dependencies: meta: ^1.8.0 polylabel: ^1.0.1 proj4dart: ^2.1.0 - tuple: ^2.0.0 vector_math: ^2.1.2 dev_dependencies: diff --git a/test/layer/tile_layer/tile_bounds/crs_fakes.dart b/test/layer/tile_layer/tile_bounds/crs_fakes.dart index 7d2c5c6d7..ee39c034f 100644 --- a/test/layer/tile_layer/tile_bounds/crs_fakes.dart +++ b/test/layer/tile_layer/tile_bounds/crs_fakes.dart @@ -1,7 +1,6 @@ import 'package:flutter_map/src/core/point.dart'; import 'package:flutter_map/src/geo/crs/crs.dart'; import 'package:latlong2/latlong.dart'; -import 'package:tuple/tuple.dart'; class FakeInfiniteCrs extends Crs { @override @@ -17,10 +16,10 @@ class FakeInfiniteCrs extends Crs { Transformation get transformation => throw UnimplementedError(); @override - Tuple2? get wrapLat => null; + (double, double)? get wrapLat => null; @override - Tuple2? get wrapLng => null; + (double, double)? get wrapLng => null; /// Any projection just to get non-zero coordiantes. @override diff --git a/test/layer/tile_layer/tile_bounds/tile_bounds_at_zoom_test.dart b/test/layer/tile_layer/tile_bounds/tile_bounds_at_zoom_test.dart index c425dfa05..a7e1bb8ab 100644 --- a/test/layer/tile_layer/tile_bounds/tile_bounds_at_zoom_test.dart +++ b/test/layer/tile_layer/tile_bounds/tile_bounds_at_zoom_test.dart @@ -4,7 +4,6 @@ import 'package:flutter_map/src/layer/tile_layer/tile_bounds/tile_bounds_at_zoom import 'package:flutter_map/src/layer/tile_layer/tile_coordinates.dart'; import 'package:flutter_map/src/layer/tile_layer/tile_range.dart'; import 'package:test/test.dart'; -import 'package:tuple/tuple.dart'; void main() { group('TileBoundsAtZoom', () { @@ -67,7 +66,7 @@ void main() { final tileBoundsAtZoom = WrappedTileBoundsAtZoom( tileRange: tileRange, wrappedAxisIsAlwaysInBounds: false, - wrapX: const Tuple2(0, 12), + wrapX: const (0, 12), wrapY: null, ); @@ -120,7 +119,7 @@ void main() { final tileBoundsAtZoom = WrappedTileBoundsAtZoom( tileRange: tileRange, wrappedAxisIsAlwaysInBounds: true, - wrapX: const Tuple2(0, 12), + wrapX: const (0, 12), wrapY: null, ); diff --git a/test/layer/tile_layer/tile_bounds/tile_bounds_test.dart b/test/layer/tile_layer/tile_bounds/tile_bounds_test.dart index 60e8efa49..7ae33bae8 100644 --- a/test/layer/tile_layer/tile_bounds/tile_bounds_test.dart +++ b/test/layer/tile_layer/tile_bounds/tile_bounds_test.dart @@ -4,7 +4,6 @@ import 'package:flutter_map/src/layer/tile_layer/tile_bounds/tile_bounds_at_zoom import 'package:flutter_map/src/layer/tile_layer/tile_range.dart'; import 'package:latlong2/latlong.dart'; import 'package:test/test.dart'; -import 'package:tuple/tuple.dart'; import 'crs_fakes.dart'; @@ -80,8 +79,8 @@ void main() { ) .having((e) => e.wrappedAxisIsAlwaysInBounds, 'wrappedAxisIsAlwaysInBounds', isTrue) - .having((e) => e.wrapX, 'wrapX', const Tuple2(0, 31)) - .having((e) => e.wrapY, 'wrapY', isNull), + .having((e) => e.wrapX, 'wrapX', const (0, 31)).having( + (e) => e.wrapY, 'wrapY', isNull), ); }); @@ -109,8 +108,8 @@ void main() { ) .having((e) => e.wrappedAxisIsAlwaysInBounds, 'wrappedAxisIsAlwaysInBounds', isFalse) - .having((e) => e.wrapX, 'wrapX', const Tuple2(0, 31)) - .having((e) => e.wrapY, 'wrapY', isNull), + .having((e) => e.wrapX, 'wrapX', const (0, 31)).having( + (e) => e.wrapY, 'wrapY', isNull), ); }); @@ -164,13 +163,13 @@ void main() { // Inferred from (ranges are inclusive starting at 0): // https://wiki.openstreetmap.org/wiki/Zoom_levels final expectedTileRanges = { - 0: const Tuple4(0, 0, 0, 0), - 1: const Tuple4(0, 0, 1, 1), - 2: const Tuple4(0, 0, 3, 3), - 3: const Tuple4(0, 0, 7, 7), - 4: const Tuple4(0, 0, 15, 15), - 5: const Tuple4(0, 0, 31, 31), - 6: const Tuple4(0, 0, 63, 63), + 0: const (0, 0, 0, 0), + 1: const (0, 0, 1, 1), + 2: const (0, 0, 3, 3), + 3: const (0, 0, 7, 7), + 4: const (0, 0, 15, 15), + 5: const (0, 0, 31, 31), + 6: const (0, 0, 63, 63), }; final tileBounds = TileBounds( @@ -188,7 +187,7 @@ void main() { final lastCoord = coords.last; expect( - Tuple4(firstCoord.x, firstCoord.y, lastCoord.x, lastCoord.y), + (firstCoord.x, firstCoord.y, lastCoord.x, lastCoord.y), entry.value, ); } @@ -198,13 +197,13 @@ void main() { // Inferred from (ranges are inclusive starting at 0): // https://wiki.openstreetmap.org/wiki/Zoom_levels final expectedTileRanges = { - 0: const Tuple2(0, 0), - 1: const Tuple2(0, 1), - 2: const Tuple2(0, 3), - 3: const Tuple2(0, 7), - 4: const Tuple2(0, 15), - 5: const Tuple2(0, 31), - 6: const Tuple2(0, 63), + 0: const (0, 0), + 1: const (0, 1), + 2: const (0, 3), + 3: const (0, 7), + 4: const (0, 15), + 5: const (0, 31), + 6: const (0, 63), }; final tileBounds = TileBounds(