Skip to content

Commit 07cdf37

Browse files
authored
Add implementation advice to debugTypicalAncestorWidgetClass (#130530)
Fixes flutter/flutter#56500
1 parent 6cabe73 commit 07cdf37

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

packages/flutter/lib/src/rendering/paragraph.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class TextParentData extends ParentData with ContainerParentDataMixin<RenderBox>
7171
}
7272

7373
@override
74-
String toString() =>'widget: $span, ${offset == null ? "not laid out" : "offset: $offset"}';
74+
String toString() => 'widget: $span, ${offset == null ? "not laid out" : "offset: $offset"}';
7575
}
7676

7777
/// A mixin that provides useful default behaviors for text [RenderBox]es

packages/flutter/lib/src/widgets/framework.dart

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1514,7 +1514,20 @@ abstract class ParentDataWidget<T extends ParentData> extends ProxyWidget {
15141514
/// that [applyParentData] will write to.
15151515
///
15161516
/// This is only used in error messages to tell users what widget typically
1517-
/// wraps this ParentDataWidget.
1517+
/// wraps this [ParentDataWidget].
1518+
///
1519+
/// ## Implementations
1520+
///
1521+
/// The returned type should be a subclass of `RenderObjectWidget`.
1522+
///
1523+
/// ```dart
1524+
/// @override
1525+
/// Type get debugTypicalAncestorWidgetClass => FrogJar;
1526+
/// ```
1527+
///
1528+
/// If the "typical" parent is generic (`Foo<T>`), consider specifying either
1529+
/// a typical type argument (e.g. `Foo<int>` if `int` is typically how the
1530+
/// type is specialized), or specifying the upper bound (e.g. `Foo<Object?>`).
15181531
Type get debugTypicalAncestorWidgetClass;
15191532

15201533
Iterable<DiagnosticsNode> _debugDescribeIncorrectParentDataType({

packages/flutter/lib/src/widgets/widget_span.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ class _WidgetSpanParentData extends ParentDataWidget<TextParentData> {
290290
}
291291

292292
@override
293-
Type get debugTypicalAncestorWidgetClass => RenderInlineChildrenContainerDefaults;
293+
Type get debugTypicalAncestorWidgetClass => RichText;
294294
}
295295

296296
// A RenderObjectWidget that automatically applies text scaling on inline

0 commit comments

Comments
 (0)