Repository navigation
fix: allow using MapController before the map has been laid out - #2294
Open
codeOfJannik wants to merge 2 commits into
Open
codeOfJannik wants to merge 2 commits into
codeOfJannik wants to merge 2 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2293
MapControllerImpl._interactiveViewerStateislateand only assigned once the map'sMapInteractiveVieweris created, which happens during layout.onMapReadyfires after the first frame regardless, so aFlutterMapthat is built but not laid out (e.g. on a route covered by another route from the first frame) throwsLateInitializationErroron any controller move (_emitMapEvent) and on anyinteractionOptionschange (options=). See the issue for the details and a minimal app.Changes
_interactiveViewerStateis now nullable.options=skipsupdateGestureswhile there is no viewer. The viewer builds its gestures from the controller's current options indidChangeDependencies, so it starts out with the latest options._emitMapEventskipsinterruptAnimatedMovementwhile there is no viewer. There is no viewer-driven gesture animation to interrupt.Behaviour for maps that have been laid out is unchanged.
Tests
New
test/map/unlaid_out_map_test.dart, with the map on a route that an opaque route covers from the first frame:onMapReadydoes not throw, and the move is kept once the map is shown;Both tests fail on
masterwithLateInitializationError: Field '_interactiveViewerState@…' has not been initialized.and pass with this change. The full suite passes (142 tests) anddart analyzeis clean.