You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow multiple ParentDataWidgets to write to ParentData (flutter#133581)
Fixesflutter#133089
This allows more than one ParentDataWidget to write to the ParentData of a child render object. Previously only one was allowed. There are some rules though:
1. Only one of a given type of `ParentDataWidget` can write to the `ParentData` of a given child.
a. For example, 2 `Positioned` widgets wrapping a child of a `Stack` would not be allowed, as only one of type `Positioned` can contribute data.
2. The type of `ParentData` **must** be compatible with all of the `ParentDataWidget`s that want to contribute data.
a. For example, `TwoDimensionalViewportParentData` mixes in the `KeepAliveParentDataMixin`. So the `ParentData` of a given child would be compatible with the `KeepAlive` `ParentDataWidget`, as well as another `ParentDataWidget` that writes `TwoDimensionalViewportParentData` (or a subclass of `TwoDimensionalViewportParentData` - This was the motivation for this change, where a `ParentDataWidget` is being used in `TableView` with the parent data type being a subclass of `TwoDimensionalViewportParentData`.)
// We explicitly throw here (even though we immediately redirect the
6308
6312
// exception elsewhere) so that debuggers will notice it when they
6309
6313
// have "break on exception" enabled.
6310
6314
throwFlutterError.fromParts(<DiagnosticsNode>[
6311
6315
ErrorSummary('Incorrect use of ParentDataWidget.'),
6312
-
ErrorDescription('The following ParentDataWidgets are providing parent data to the same RenderObject:'),
6313
-
for (finalParentDataElement<ParentData> ancestor in badAncestors)
6314
-
ErrorDescription('- ${ancestor.widget} (typically placed directly inside a ${(ancestor.widgetasParentDataWidget<ParentData>).debugTypicalAncestorWidgetDescription} widget)'),
6315
-
ErrorDescription('However, a RenderObject can only receive parent data from at most one ParentDataWidget.'),
6316
-
ErrorHint('Usually, this indicates that at least one of the offending ParentDataWidgets listed above is not placed directly inside a compatible ancestor widget.'),
6317
-
ErrorDescription('The ownership chain for the RenderObject that received the parent data was:\n ${debugGetCreatorChain(10)}'),
6316
+
ErrorDescription(
6317
+
'Competing ParentDataWidgets are providing parent data to the '
6318
+
'same RenderObject:'
6319
+
),
6320
+
for (finalParentDataElement<ParentData> ancestor in result.where((ParentDataElement<ParentData> ancestor) {
0 commit comments