diff --git a/lib/src/gestures/flutter_map_interactive_viewer.dart b/lib/src/gestures/flutter_map_interactive_viewer.dart index 46a634a25..8fac4ec3c 100644 --- a/lib/src/gestures/flutter_map_interactive_viewer.dart +++ b/lib/src/gestures/flutter_map_interactive_viewer.dart @@ -17,14 +17,16 @@ import 'package:flutter_map/src/map/options/options.dart'; import 'package:flutter_map/src/misc/point_extensions.dart'; import 'package:latlong2/latlong.dart'; +typedef InteractiveViewerBuilder = Widget Function( + BuildContext context, + MapOptions options, + MapCamera camera, +); + /// Applies interactions (gestures/scroll/taps etc) to the current [MapCamera] /// via the internal [controller]. class FlutterMapInteractiveViewer extends StatefulWidget { - final Widget Function( - BuildContext context, - MapOptions options, - MapCamera camera, - ) builder; + final InteractiveViewerBuilder builder; final FlutterMapInternalController controller; const FlutterMapInteractiveViewer({ diff --git a/lib/src/map/options/options.dart b/lib/src/map/options/options.dart index 91928537b..535101ee2 100644 --- a/lib/src/map/options/options.dart +++ b/lib/src/map/options/options.dart @@ -99,7 +99,7 @@ class MapOptions { /// and you need to access the controller as soon as the map is built. /// Otherwise you can use WidgetsBinding.instance.addPostFrameCallback /// In initState to controll the map before the next frame. - final void Function()? onMapReady; + final VoidCallback? onMapReady; final LatLngBounds? maxBounds; diff --git a/lib/src/map/widget.dart b/lib/src/map/widget.dart index 28183400a..5f7dd9042 100644 --- a/lib/src/map/widget.dart +++ b/lib/src/map/widget.dart @@ -142,7 +142,6 @@ class _FlutterMapStateContainer extends State return LayoutBuilder( builder: (context, constraints) { _updateAndEmitSizeIfConstraintsChanged(constraints); - _applyInitialCameraFit(constraints); return FlutterMapInteractiveViewer( controller: _flutterMapInternalController, @@ -235,6 +234,8 @@ class _FlutterMapStateContainer extends State oldCamera, newMapCamera, ); + + _applyInitialCameraFit(constraints); } }); }