From 07cdf37ca3e380fefb2cf5aff75055981115511b Mon Sep 17 00:00:00 2001 From: Ian Hickson Date: Wed, 19 Jul 2023 15:47:43 -0700 Subject: [PATCH] Add implementation advice to debugTypicalAncestorWidgetClass (#130530) Fixes https://github.com/flutter/flutter/issues/56500 --- packages/flutter/lib/src/rendering/paragraph.dart | 2 +- packages/flutter/lib/src/widgets/framework.dart | 15 ++++++++++++++- packages/flutter/lib/src/widgets/widget_span.dart | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/packages/flutter/lib/src/rendering/paragraph.dart b/packages/flutter/lib/src/rendering/paragraph.dart index 4fd946a88d..d53720c869 100644 --- a/packages/flutter/lib/src/rendering/paragraph.dart +++ b/packages/flutter/lib/src/rendering/paragraph.dart @@ -71,7 +71,7 @@ class TextParentData extends ParentData with ContainerParentDataMixin } @override - String toString() =>'widget: $span, ${offset == null ? "not laid out" : "offset: $offset"}'; + String toString() => 'widget: $span, ${offset == null ? "not laid out" : "offset: $offset"}'; } /// A mixin that provides useful default behaviors for text [RenderBox]es diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart index da4132c16a..8628b57ba4 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -1514,7 +1514,20 @@ abstract class ParentDataWidget extends ProxyWidget { /// that [applyParentData] will write to. /// /// This is only used in error messages to tell users what widget typically - /// wraps this ParentDataWidget. + /// wraps this [ParentDataWidget]. + /// + /// ## Implementations + /// + /// The returned type should be a subclass of `RenderObjectWidget`. + /// + /// ```dart + /// @override + /// Type get debugTypicalAncestorWidgetClass => FrogJar; + /// ``` + /// + /// If the "typical" parent is generic (`Foo`), consider specifying either + /// a typical type argument (e.g. `Foo` if `int` is typically how the + /// type is specialized), or specifying the upper bound (e.g. `Foo`). Type get debugTypicalAncestorWidgetClass; Iterable _debugDescribeIncorrectParentDataType({ diff --git a/packages/flutter/lib/src/widgets/widget_span.dart b/packages/flutter/lib/src/widgets/widget_span.dart index 34afb66f3a..65427e7ed2 100644 --- a/packages/flutter/lib/src/widgets/widget_span.dart +++ b/packages/flutter/lib/src/widgets/widget_span.dart @@ -290,7 +290,7 @@ class _WidgetSpanParentData extends ParentDataWidget { } @override - Type get debugTypicalAncestorWidgetClass => RenderInlineChildrenContainerDefaults; + Type get debugTypicalAncestorWidgetClass => RichText; } // A RenderObjectWidget that automatically applies text scaling on inline