Skip to content
Boring Doc
BreakingHigh impactOfficial migration guidesince 1.17.0landed 1.16.3

Generic type of ParentDataWidget changed to ParentData

Framework · Official source

The generic type of `ParentDataWidget` has changed from `RenderObjectWidget` to `ParentData`.

Original behavior

Prior to this change, a `ParentDataWidget` was bound to a specific `RenderObjectWidget` type as ancestor. For example, a `Positioned` widget could only be used within a `Stack` widget. With this change, a `ParentDataWidget` can be used with any `RenderObjectWidget` type as ancestor as long as the `RenderObject` of said `RenderObjectWidget` sets up the correct `ParentData` type. In this new world, the `Positioned` widget can be reused with a hypothetical new `SuperStack` widget.

New behavior

The generic type argument of `ParentDataWidget` has changed from `RenderObjectWidget` to `ParentData`, and a new debug property, `debugTypicalAncestorWidgetClass`, is added to `ParentDataWidget`. The latter is used for error messages to give users a better idea of the context a given `ParentDataWidget` is supposed to be used in.

Who is affected
Applications and packages relying on the previous behaviour or signature. Code that uses ParentDataWidget, RenderObjectWidget, ParentData and related APIs.
Practical impact
Behaviour or API differences that can break builds or change runtime behaviour.
What action should I take?
Follow the official migration guide below, update affected call sites, run `dart fix --apply` where a fix is available, then run your tests.

Before and after (from the official guide)

dart+3−8
Before
1−class FrogSize extends ParentDataWidget<FrogJar> {
2 FrogSize({
3 Key key,
4 required this.size,
5 required Widget child,
6 }) : assert(child != null),
7 assert(size != null),
8 super(key: key, child: child);
9  
10 final Size size;
11  
12 @override
13 void applyParentData(RenderObject renderObject) {
14 final FrogJarParentData parentData = renderObject.parentData;
15 if (parentData.size != size) {
16 parentData.size = size;
17 final RenderFrogJar targetParent = renderObject.parent;
18 targetParent.markNeedsLayout();
19 }
20 }
21−}
22  
23−class FrogJarParentData extends ParentData {
24− Size size;
25 }
26− 
27−class FrogJar extends RenderObjectWidget {
28− // ...
29−}
After
1+class FrogSize extends ParentDataWidget<FrogJarParentData> { // FrogJar changed to FrogJarParentData
2 FrogSize({
3 Key key,
4 required this.size,
5 required Widget child,
6 }) : assert(child != null),
7 assert(size != null),
8 super(key: key, child: child);
9  
10 final Size size;
11  
12 @override
13 void applyParentData(RenderObject renderObject) {
14 final FrogJarParentData parentData = renderObject.parentData;
15 if (parentData.size != size) {
16 parentData.size = size;
17 final RenderFrogJar targetParent = renderObject.parent;
18 targetParent.markNeedsLayout();
19 }
20 }
 
21  
22+ @override
23+ Type get debugTypicalAncestorWidgetClass => FrogJar; // Newly added
24 }
 
 
 
 
Raw before / after
class FrogSize extends ParentDataWidget<FrogJar> {
  FrogSize({
    Key key,
    required this.size,
    required Widget child,
  }) : assert(child != null),
        assert(size != null),
        super(key: key, child: child);

  final Size size;

  @override
  void applyParentData(RenderObject renderObject) {
    final FrogJarParentData parentData = renderObject.parentData;
    if (parentData.size != size) {
      parentData.size = size;
      final RenderFrogJar targetParent = renderObject.parent;
      targetParent.markNeedsLayout();
    }
  }
}

class FrogJarParentData extends ParentData {
  Size size;
}

class FrogJar extends RenderObjectWidget {
  // ...
}
class FrogSize extends ParentDataWidget<FrogJarParentData> { // FrogJar changed to FrogJarParentData
  FrogSize({
    Key key,
    required this.size,
    required Widget child,
  }) : assert(child != null),
        assert(size != null),
        super(key: key, child: child);

  final Size size;

  @override
  void applyParentData(RenderObject renderObject) {
    final FrogJarParentData parentData = renderObject.parentData;
    if (parentData.size != size) {
      parentData.size = size;
      final RenderFrogJar targetParent = renderObject.parent;
      targetParent.markNeedsLayout();
    }
  }

  @override
  Type get debugTypicalAncestorWidgetClass => FrogJar; // Newly added
}
Official migration guide (excerpt, © The Flutter Authors, CC BY 3.0)

You must migrate your code as described in this section if you're subclassing or implementing ParentDataWidget. If you do, the analyzer shows the following warnings when you upgrade to the Flutter version that includes this change:

  error • Missing concrete implementation of 'getter ParentDataWidget.debugTypicalAncestorWidgetClass' • lib/main.dart:114:7 • non_abstract_class_inherits_abstract_member
  error • 'FrogJar' doesn't extend 'ParentData' • lib/main.dart:114:41 • type_argument_not_matching_bounds

Code before migration:

class FrogSize extends ParentDataWidget&#x3C;FrogJar> {
  FrogSize({
    Key key,
    required this.size,
    required Widget child,
  }) : assert(child != null),
        assert(size != null),
        super(key: key, child: child);

  final Size size;

  @override
  void applyParentData(RenderObject renderObject) {
    final FrogJarParentData parentData = renderObject.parentData;
    if (parentData.size != size) {
      parentData.size = size;
      final RenderFrogJar targetParent = renderObject.parent;
      targetParent.markNeedsLayout();
    }
  }
}

class FrogJarParentData extends ParentData {
  Size size;
}

class FrogJar extends RenderObjectWidget {
  // ...
}

Code after migration:

class FrogSize extends ParentDataWidget&#x3C;FrogJarParentData> { // FrogJar changed to FrogJarParentData
  FrogSize({
    Key key,
    required this.size,
    required Widget child,
  }) : assert(child != null),
        assert(size != null),
        super(key: key, child: child);

  final Size size;

  @override
  void applyParentData(RenderObject renderObject) {
    final FrogJarParentData parentData = renderObject.parentData;
    if (parentData.size != size) {
      parentData.size = size;
      final RenderFrogJar targetParent = renderObject.parent;
      targetParent.markNeedsLayout();
    }
  }

  @override
  Type get debugTypicalAncestorWidgetClass => FrogJar; // Newly added
}

The generic type of the ParentDataWidget superclass changes from FrogJar (a RenderObjectWidget) to FrogJarParentData (the ParentData type that FrogSize.applyParentData wants to operate on). Additionally, the new debugTypicalAncestorWidgetClass is implemented for this ParentDataWidget subclass. It returns the type of a typical ancestor RenderObjectWidget for this ParentDataWidget. Most of the time, you just want to return the old generic type here (FrogJar in this example).

Migration assistantAI-generated · grounded in cited sources
AI explanations are not configured
Set AI_PROVIDER (for example to openai-compatible with a local Ollama or LM Studio endpoint) to enable grounded explanations. Everything else on this page works without an AI provider.
Official migration guide·Verified classification (95%)

Listed in the official breaking-changes index (docs.flutter.dev/release/breaking-changes).

An official announcement or migration guide documents an intended behaviour or API change. A verified source change (git diff) shows code changed but does not by itself prove a public API is breaking. AI interpretations are labelled and never used to classify a change.

Source commit
b3045439b7c0
Source last updated
Oct 21, 2026
Last synchronized
Oct 21, 2026
Publication status
published
Publication history
  • Oct 21, 2026, 8:31 PM: new → published (ingestion) — Backed by an official breaking-change/migration guide.
AI explanationAI-generated · grounded in cited sources
AI explanations are not configured
Set AI_PROVIDER (for example to openai-compatible with a local Ollama or LM Studio endpoint) to enable grounded explanations. Everything else on this page works without an AI provider.
Was this useful?
Generic type of ParentDataWidget changed to ParentData · Boring Doc