Repository navigation
fix(crop-rotate-editor): ignore setState after dispose and color undo/redo with appBarColor - #873
Merged
Merged
Conversation
…/redo with appBarColor The resize-end handler of the crop editor schedules a post-frame callback that runs even when the editor was disposed in the same frame. It then called setState, which added to the already closed rebuildController and threw "Bad state: Cannot add new events after calling close" (#858). The setState overrides of the blur, crop, filter, paint, text and tune editors now return early when the state is no longer mounted, as the main editor already did. The crop editor's post-frame callbacks also bail out before touching its disposed animation controllers. The undo and redo icons of the crop and tune app bars were hardcoded to white, so they vanished on a light appBarBackground while the done button followed appBarColor. They now use appBarColor like the paint editor (#856). The default appBarColor is white, so the default look is unchanged.
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.
Description
Two crop-rotate editor bugs, fixed in one PR.
#858:
Bad state: Cannot add new events after calling closeScreenResizeDetector.onResizeEndfires from a 50 ms debounce, and the crop editor responds by scheduling a post-frame callback that calls_updateAllStates()→setState(). If the editor is removed in the frame where that debounce fires,dispose()has already closedrebuildControllerby the time the callback runs, andrebuildController.add(null)throws. The UI isn't affected, but apps that forwardFlutterError.onErrorto Crashlytics/Sentry report it as a crash.setStateoverrides of the blur, crop, filter, paint, text and tune editors now return early when the state isn't mounted. The main editor already did this.initStateand the one inonResizeEnd) also return early when the state isn't mounted, so they no longer callcalcFitToScreen()/_setCropRectBounding()on disposed animation controllers.#856: undo/redo ignore
appBarColorThe undo and redo icons in
CropEditorAppbarandTuneEditorAppbarwere hardcoded toColors.white/Colors.white.withAlpha(80). The done button followsappBarColor, so with a lightappBarBackgroundundo and redo disappeared. They now usestyle.appBarColor(with alpha 80 when disabled), asPaintEditorAppbaralready does.kImageEditorAppBarColoris white, so the default look is unchanged. The frosted-glass example designs hardcode white on purpose and are unchanged.Related Issue: Closes #858, closes #856
Type of Change
Tests
StateError.setStateafter dispose returns normally.appBarColor.stableand pass with the fix.flutter test(674 tests),flutter analyzeanddart formatpass.