From 6a48594b1ae44b6468b1f83a1de704ce626c9852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Andersson?= Date: Wed, 2 Jun 2021 09:06:49 +0200 Subject: [PATCH 1/4] fix: remove deprecated properties Removes deprecated properties, updates documentation and changed bounds getCenter to a getter. --- CHANGELOG.md | 7 ++++++- example/lib/pages/custom_crs/custom_crs.dart | 1 - example/lib/pages/network_tile_provider.dart | 2 +- lib/flutter_map.dart | 19 +++---------------- lib/src/core/bounds.dart | 3 +-- lib/src/layer/tile_layer.dart | 2 +- lib/src/map/map.dart | 4 ---- 7 files changed, 12 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4746ab90c..09acf58e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,15 @@ This version has support for sound null safety. For this purpose, some inactive - Sound null safety migration (#851, #870) - requires flutter version 2.0.0 or higher - latlong is replaced with latlong2 + - ready-flag on map has been removed - Remove the package flutter_image and add http instead (#894) - http has to be version 0.13.2 or higher for this package (#894) +- Removed deprecated properties + - debug property has been removed + - interactive has been replaced by interactiveFlags +- Bounds getCenter has been replaced by center getter -Thanks to escamoteur, ThexXTURBOXx, Sata51, tazik561, kengu, passsy, Ahmed-gubara, johnpryan and josxha for this release! +Thanks to escamoteur, ThexXTURBOXx, Sata51, tazik561, kengu, passsy, Ahmed-gubara, johnpryan, josxha and andreandersson for this release! ## [0.12.0] - 3/16/2021 TileLayerOptions now takes some additional options, templateFunction, diff --git a/example/lib/pages/custom_crs/custom_crs.dart b/example/lib/pages/custom_crs/custom_crs.dart index 0cc0e8682..bdb7a7536 100644 --- a/example/lib/pages/custom_crs/custom_crs.dart +++ b/example/lib/pages/custom_crs/custom_crs.dart @@ -37,7 +37,6 @@ class _CustomCrsPageState extends State { // EPSG:3413 is a user-defined projection from a valid Proj4 definition string // From: http://epsg.io/3413, proj definition: http://epsg.io/3413.proj4 // Find Projection by name or define it if not exists - // TODO the warning here will go away as soon as proj4 is migrated to null safety epsg3413 = proj4.Projection.get('EPSG:3413') ?? proj4.Projection.add('EPSG:3413', '+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs'); diff --git a/example/lib/pages/network_tile_provider.dart b/example/lib/pages/network_tile_provider.dart index e9eba1ffc..d5c6d6216 100644 --- a/example/lib/pages/network_tile_provider.dart +++ b/example/lib/pages/network_tile_provider.dart @@ -56,7 +56,7 @@ class NetworkTileProviderPage extends StatelessWidget { padding: EdgeInsets.only(top: 8.0, bottom: 8.0), child: Wrap(children: [ Text('This is a map that is using NetworkTileProvider.'), - Text('Turn on flight mode to see that images are cached.'), + Text('Turn on flight mode to see that images are not cached.'), ]), ), Flexible( diff --git a/lib/flutter_map.dart b/lib/flutter_map.dart index 6db99f69e..7fade1536 100644 --- a/lib/flutter_map.dart +++ b/lib/flutter_map.dart @@ -122,8 +122,6 @@ abstract class MapController { /// through the [options] parameter. void fitBounds(LatLngBounds bounds, {FitBoundsOptions? options}); - bool get ready; - Future get onReady; LatLng get center; @@ -221,10 +219,6 @@ class MapOptions { final double? minZoom; final double? maxZoom; - @deprecated - final bool debug; // TODO no usage outside of constructor. Marked for removal? - @Deprecated('use interactiveFlags instead') - final bool? interactive; /// see [InteractiveFlag] for custom settings final int interactiveFlags; @@ -268,12 +262,7 @@ class MapOptions { MultiFingerGesture.pinchZoom | MultiFingerGesture.pinchMove, this.minZoom, this.maxZoom, - @Deprecated('') this.debug = false, - @Deprecated('Use interactiveFlags instead') this.interactive, - // TODO: Change when [interactive] is removed. - // Change this to [this.interactiveFlags = InteractiveFlag.all] and remove - // [interactiveFlags] from initializer list - int? interactiveFlags, + this.interactiveFlags = InteractiveFlag.all, this.allowPanning = true, this.onTap, this.onLongPress, @@ -286,9 +275,7 @@ class MapOptions { this.controller, this.swPanBoundary, this.nePanBoundary, - }) : interactiveFlags = interactiveFlags ?? - (interactive == false ? InteractiveFlag.none : InteractiveFlag.all), - center = center ?? LatLng(50.5, 30.51), + }) : center = center ?? LatLng(50.5, 30.51), assert(rotationThreshold >= 0.0), assert(pinchZoomThreshold >= 0.0), assert(pinchMoveThreshold >= 0.0) { @@ -365,7 +352,7 @@ class MapOptions { double _calculateScreenHeightInDegrees() => screenSize!.height * 170.102258 / pow(2, _getControllerZoom() + 8); - double _getControllerZoom() => controller!.ready ? controller!.zoom : zoom; + double _getControllerZoom() => controller!.zoom; } class FitBoundsOptions { diff --git a/lib/src/core/bounds.dart b/lib/src/core/bounds.dart index fbb204b17..2397f7404 100644 --- a/lib/src/core/bounds.dart +++ b/lib/src/core/bounds.dart @@ -32,8 +32,7 @@ class Bounds { } /// This [Bounds] central point. - CustomPoint getCenter() { - //TODO should this be a getter? + CustomPoint get center { return CustomPoint( (min.x + max.x) / 2, (min.y + max.y) / 2, diff --git a/lib/src/layer/tile_layer.dart b/lib/src/layer/tile_layer.dart index 34f6061eb..efefaf2af 100644 --- a/lib/src/layer/tile_layer.dart +++ b/lib/src/layer/tile_layer.dart @@ -925,7 +925,7 @@ class _TileLayerState extends State with TickerProviderStateMixin { var pixelBounds = _getTiledPixelBounds(center); var tileRange = _pxBoundsToTileRange(pixelBounds); - var tileCenter = tileRange.getCenter(); + var tileCenter = tileRange.center; final queue = >[]; var margin = options.keepBuffer; var noPruneRange = Bounds( diff --git a/lib/src/map/map.dart b/lib/src/map/map.dart index 408f4eee4..3706f365e 100644 --- a/lib/src/map/map.dart +++ b/lib/src/map/map.dart @@ -51,10 +51,6 @@ class MapControllerImpl implements MapController { _state.fitBounds(bounds, options!); } - @override - // TODO Remove getter since ready is always true (breaking change, was '=> _state != null' when state is never null) - bool get ready => true; - @override LatLng get center => _state.center; From c5ca005b7ecbc2ae2d8a08ff19c3ee371ba28dd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Andersson?= Date: Wed, 2 Jun 2021 09:31:34 +0200 Subject: [PATCH 2/4] fix: simplify center getter --- lib/src/core/bounds.dart | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/src/core/bounds.dart b/lib/src/core/bounds.dart index 2397f7404..3aa96eb5d 100644 --- a/lib/src/core/bounds.dart +++ b/lib/src/core/bounds.dart @@ -32,12 +32,10 @@ class Bounds { } /// This [Bounds] central point. - CustomPoint get center { - return CustomPoint( - (min.x + max.x) / 2, - (min.y + max.y) / 2, - ); - } + CustomPoint get center => CustomPoint( + (min.x + max.x) / 2, + (min.y + max.y) / 2, + ); /// Bottom-Left corner's point. CustomPoint get bottomLeft => CustomPoint(min.x, max.y); From 6dec63f36a4c226ac4a77dd067a9856bcb08e782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Andersson?= Date: Wed, 2 Jun 2021 09:47:19 +0200 Subject: [PATCH 3/4] docs: improve documentation for NetworkTileProvider --- example/lib/pages/network_tile_provider.dart | 4 ++-- lib/src/layer/tile_layer.dart | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/example/lib/pages/network_tile_provider.dart b/example/lib/pages/network_tile_provider.dart index d5c6d6216..3d9ebccec 100644 --- a/example/lib/pages/network_tile_provider.dart +++ b/example/lib/pages/network_tile_provider.dart @@ -55,8 +55,8 @@ class NetworkTileProviderPage extends StatelessWidget { Padding( padding: EdgeInsets.only(top: 8.0, bottom: 8.0), child: Wrap(children: [ - Text('This is a map that is using NetworkTileProvider.'), - Text('Turn on flight mode to see that images are not cached.'), + Text('This Provider does not provide caching.'), + Text('For further options about that, check flutter_map\'s README on GitHub.'), ]), ), Flexible( diff --git a/lib/src/layer/tile_layer.dart b/lib/src/layer/tile_layer.dart index efefaf2af..a570cd160 100644 --- a/lib/src/layer/tile_layer.dart +++ b/lib/src/layer/tile_layer.dart @@ -111,9 +111,7 @@ class TileLayerOptions extends LayerOptions { final double opacity; /// Provider to load the tiles. The default is CachedNetworkTileProvider, - /// which loads tile images from network and caches them offline. - /// - /// If you don't want to cache the tiles, use NetworkTileProvider instead. + /// which loads tile images from network. /// /// In order to use images from the asset folder set this option to /// AssetTileProvider() Note that it requires the urlTemplate to target From dfdd2b99cbf9a32a938e2ea53a7d9e0a8d32a487 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Andersson?= Date: Fri, 4 Jun 2021 14:11:33 +0200 Subject: [PATCH 4/4] docs: update documentation for tileProvider --- lib/src/layer/tile_layer.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/src/layer/tile_layer.dart b/lib/src/layer/tile_layer.dart index a570cd160..f7330e6ef 100644 --- a/lib/src/layer/tile_layer.dart +++ b/lib/src/layer/tile_layer.dart @@ -110,8 +110,10 @@ class TileLayerOptions extends LayerOptions { /// Opacity of the rendered tile final double opacity; - /// Provider to load the tiles. The default is CachedNetworkTileProvider, - /// which loads tile images from network. + /// Provider to load the tiles. The default is `NonCachingNetworkTileProvider()` which + /// doesn't cache tiles and won't retry the HTTP request. Use `NetworkTileProvider()` for + /// a provider which will retry requests. For the best caching implementations, see the + /// flutter_map readme. /// /// In order to use images from the asset folder set this option to /// AssetTileProvider() Note that it requires the urlTemplate to target