Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: LateInitializationError when specifying initialCameraFit #1691

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions lib/src/gestures/flutter_map_interactive_viewer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion lib/src/map/options/options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion lib/src/map/widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ class _FlutterMapStateContainer extends State<FlutterMap>
return LayoutBuilder(
builder: (context, constraints) {
_updateAndEmitSizeIfConstraintsChanged(constraints);
_applyInitialCameraFit(constraints);

return FlutterMapInteractiveViewer(
controller: _flutterMapInternalController,
Expand Down Expand Up @@ -235,6 +234,8 @@ class _FlutterMapStateContainer extends State<FlutterMap>
oldCamera,
newMapCamera,
);

_applyInitialCameraFit(constraints);
}
});
}
Expand Down
Loading