mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Fixes https://github.com/flutter/flutter/issues/154060 The error message doesn't make sense to me since one can call `setState` during the idle phase, and I'm not sure what this is guarding against without the right error message. In the case of #154060 the layout builder was never laid out: ``` ââchild 1: _RenderLayoutBuilder#7c319 NEEDS-LAYOUT NEEDS-PAINT â creator: LayoutBuilder â _BodyBuilder â MediaQuery â â LayoutId-[<_ScaffoldSlot.body>] â CustomMultiChildLayout â â _ActionsScope â Actions â AnimatedBuilder â DefaultTextStyle â â AnimatedDefaultTextStyle â _InkFeatures-[GlobalKey#1f6eb ink â renderer] â NotificationListener<LayoutChangedNotification> â ⯠â parentData: offset=Offset(0.0, 0.0); id=_ScaffoldSlot.body â constraints: MISSING â size: MISSING ``` So https://github.com/flutter/flutter/pull/154681 doesn't really fix #154060 since the layout callback cannot be run without a set of valid constraints. Before the `BuildScope` change all `_inDirtyList` flags were unset after the `BuildOwner` finishes rebuilding the widget tree, so `LayoutBuilder._inDirtyLst` is always set to false after a frame even for layout builders that were never laid out. With the `BuildScope` change, `LayoutBuilder` has its own `BuildScope` which is only flushed after LayoutBuilder gets its constraints.