Skip to content

Commit 52c7fa3

Browse files
authored
Moved backgroundColor property from TileLayer to MapOptions (with deprecations) (#1578)
1 parent f1cd70b commit 52c7fa3

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

lib/src/layer/tile_layer/tile_layer.dart

+8-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import 'dart:math' as math;
33

44
import 'package:collection/collection.dart' show MapEquality;
55
import 'package:flutter/material.dart';
6-
import 'package:flutter/widgets.dart';
76
import 'package:flutter_map/plugin_api.dart';
87
import 'package:flutter_map/src/layer/tile_layer/tile.dart';
98
import 'package:flutter_map/src/layer/tile_layer/tile_bounds/tile_bounds.dart';
@@ -104,6 +103,11 @@ class TileLayer extends StatefulWidget {
104103
final TileDisplay tileDisplay;
105104

106105
/// Color shown behind the tiles
106+
@Deprecated(
107+
'Prefer `MapOptions.backgroundColor`. '
108+
'This property has been removed simplify interaction when using multiple `TileLayer`s. '
109+
'This property is deprecated since v6.',
110+
)
107111
final Color backgroundColor;
108112

109113
/// Provider with which to load map tiles
@@ -231,7 +235,7 @@ class TileLayer extends StatefulWidget {
231235
this.subdomains = const <String>[],
232236
this.keepBuffer = 2,
233237
this.panBuffer = 0,
234-
this.backgroundColor = const Color(0xFFE0E0E0),
238+
this.backgroundColor = Colors.transparent,
235239
this.errorImage,
236240
TileProvider? tileProvider,
237241
this.tms = false,
@@ -474,7 +478,8 @@ class _TileLayerState extends State<TileLayer> with TickerProviderStateMixin {
474478

475479
_tileScaleCalculator.clearCacheUnlessZoomMatches(map.zoom);
476480

477-
return Container(
481+
return ColoredBox(
482+
// ignore: deprecated_member_use_from_same_package
478483
color: widget.backgroundColor,
479484
child: Stack(
480485
children: [

lib/src/map/options.dart

+3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ class MapOptions {
7070
final double? minZoom;
7171
final double? maxZoom;
7272

73+
final Color backgroundColor;
74+
7375
/// see [InteractiveFlag] for custom settings
7476
final int? _interactiveFlags;
7577

@@ -212,6 +214,7 @@ class MapOptions {
212214
double? scrollWheelVelocity,
213215
this.minZoom,
214216
this.maxZoom,
217+
this.backgroundColor = const Color(0xFFE0E0E0),
215218
this.onTap,
216219
this.onSecondaryTap,
217220
this.onLongPress,

lib/src/map/widget.dart

+3
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ class FlutterMapStateContainer extends State<FlutterMap> {
101101
child: ClipRect(
102102
child: Stack(
103103
children: [
104+
Positioned.fill(
105+
child: ColoredBox(color: options.backgroundColor),
106+
),
104107
OverflowBox(
105108
minWidth: camera.size.x,
106109
maxWidth: camera.size.x,

0 commit comments

Comments
 (0)