added tests, removed API (#69620)
diff --git a/packages/flutter/lib/fix_data.yaml b/packages/flutter/lib/fix_data.yaml
index 52d64a4..b676546 100644
--- a/packages/flutter/lib/fix_data.yaml
+++ b/packages/flutter/lib/fix_data.yaml
@@ -11,6 +11,149 @@
version: 1
transforms:
+ # Change made in https://github.com/flutter/flutter/pull/44189.
+ - title: 'Rename to dependOnInheritedElement'
+ date: 2019-11-22
+ element:
+ uris: [ 'material.dart', 'cupertino.dart', 'widgets.dart' ]
+ inClass: 'BuildContext'
+ method: 'inheritFromElement'
+ changes:
+ - kind: 'rename'
+ newName: 'dependOnInheritedElement'
+
+ # Change made in https://github.com/flutter/flutter/pull/44189.
+ - title: 'Migrate to dependOnInheritedWidgetOfExactType'
+ date: 2019-11-22
+ element:
+ uris: [ 'material.dart', 'cupertino.dart', 'widgets.dart' ]
+ inClass: 'BuildContext'
+ method: 'inheritFromWidgetOfExactType'
+ changes:
+ - kind: 'rename'
+ newName: 'dependOnInheritedWidgetOfExactType'
+ - kind: 'removeParameter'
+ index: 0
+ - kind: 'addTypeParameter'
+ index: 0
+ name: 'T'
+ argumentValue:
+ expression: '{% type %}'
+ variables:
+ type:
+ kind: fragment
+ value: 'arguments[0]'
+
+ # Change made in https://github.com/flutter/flutter/pull/44189.
+ - title: 'Migrate to getElementForInheritedWidgetOfExactType'
+ date: 2019-11-22
+ element:
+ uris: [ 'material.dart', 'cupertino.dart', 'widgets.dart' ]
+ inClass: 'BuildContext'
+ method: 'ancestorInheritedElementForWidgetOfExactType'
+ changes:
+ - kind: 'rename'
+ newName: 'getElementForInheritedWidgetOfExactType'
+ - kind: 'removeParameter'
+ index: 0
+ - kind: 'addTypeParameter'
+ index: 0
+ name: 'T'
+ argumentValue:
+ expression: '{% type %}'
+ variables:
+ type:
+ kind: fragment
+ value: 'arguments[0]'
+
+ # Change made in https://github.com/flutter/flutter/pull/44189.
+ - title: 'Migrate to findAncestorWidgetOfExactType'
+ date: 2019-11-22
+ element:
+ uris: [ 'material.dart', 'cupertino.dart', 'widgets.dart' ]
+ inClass: 'BuildContext'
+ method: 'ancestorWidgetOfExactType'
+ changes:
+ - kind: 'rename'
+ newName: 'findAncestorWidgetOfExactType'
+ - kind: 'removeParameter'
+ index: 0
+ - kind: 'addTypeParameter'
+ index: 0
+ name: 'T'
+ argumentValue:
+ expression: '{% type %}'
+ variables:
+ type:
+ kind: fragment
+ value: 'arguments[0]'
+
+ # Change made in https://github.com/flutter/flutter/pull/44189.
+ - title: 'Migrate to findAncestorStateOfType'
+ date: 2019-11-22
+ element:
+ uris: [ 'material.dart', 'cupertino.dart', 'widgets.dart' ]
+ inClass: 'BuildContext'
+ method: 'ancestorStateOfType'
+ changes:
+ - kind: 'rename'
+ newName: 'findAncestorStateOfType'
+ - kind: 'removeParameter'
+ index: 0
+ - kind: 'addTypeParameter'
+ index: 0
+ name: 'T'
+ argumentValue:
+ expression: '{% type %}'
+ variables:
+ type:
+ kind: fragment
+ value: 'arguments[0].typeArguments[0]'
+
+ # Change made in https://github.com/flutter/flutter/pull/44189.
+ - title: 'Migrate to rootAncestorStateOfType'
+ date: 2019-11-22
+ element:
+ uris: [ 'material.dart', 'cupertino.dart', 'widgets.dart' ]
+ inClass: 'BuildContext'
+ method: 'rootAncestorStateOfType'
+ changes:
+ - kind: 'rename'
+ newName: 'findRootAncestorStateOfType'
+ - kind: 'removeParameter'
+ index: 0
+ - kind: 'addTypeParameter'
+ index: 0
+ name: 'T'
+ argumentValue:
+ expression: '{% type %}'
+ variables:
+ type:
+ kind: fragment
+ value: 'arguments[0].typeArguments[0]'
+
+ # Change made in https://github.com/flutter/flutter/pull/44189.
+ - title: 'Migrate to ancestorRenderObjectOfType'
+ date: 2019-11-22
+ element:
+ uris: [ 'material.dart', 'cupertino.dart', 'widgets.dart' ]
+ inClass: 'BuildContext'
+ method: 'ancestorRenderObjectOfType'
+ changes:
+ - kind: 'rename'
+ newName: 'findAncestorRenderObjectOfType'
+ - kind: 'removeParameter'
+ index: 0
+ - kind: 'addTypeParameter'
+ index: 0
+ name: 'T'
+ argumentValue:
+ expression: '{% type %}'
+ variables:
+ type:
+ kind: fragment
+ value: 'arguments[0].typeArguments[0]'
+
# Changes made in https://github.com/flutter/flutter/pull/45941
- title: 'Rename to deferFirstFrame'
date: 2020-12-23
diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart
index 71b3bc7..91764b3 100644
--- a/packages/flutter/lib/src/widgets/framework.dart
+++ b/packages/flutter/lib/src/widgets/framework.dart
@@ -2236,17 +2236,6 @@
/// Registers this build context with [ancestor] such that when
/// [ancestor]'s widget changes this build context is rebuilt.
///
- /// This method is deprecated. Please use [dependOnInheritedElement] instead.
- // TODO(a14n): Remove this when it goes to stable, https://github.com/flutter/flutter/pull/44189
- @Deprecated(
- 'Use dependOnInheritedElement instead. '
- 'This feature was deprecated after v1.12.1.'
- )
- InheritedWidget inheritFromElement(InheritedElement ancestor, { Object aspect });
-
- /// Registers this build context with [ancestor] such that when
- /// [ancestor]'s widget changes this build context is rebuilt.
- ///
/// Returns `ancestor.widget`.
///
/// This method is rarely called directly. Most applications should use
@@ -2257,20 +2246,6 @@
/// be called apply to this method as well.
InheritedWidget dependOnInheritedElement(InheritedElement ancestor, { Object aspect });
- /// Obtains the nearest widget of the given type, which must be the type of a
- /// concrete [InheritedWidget] subclass, and registers this build context with
- /// that widget such that when that widget changes (or a new widget of that
- /// type is introduced, or the widget goes away), this build context is
- /// rebuilt so that it can obtain new values from that widget.
- ///
- /// This method is deprecated. Please use [dependOnInheritedWidgetOfExactType] instead.
- // TODO(a14n): Remove this when it goes to stable, https://github.com/flutter/flutter/pull/44189
- @Deprecated(
- 'Use dependOnInheritedWidgetOfExactType instead. '
- 'This feature was deprecated after v1.12.1.'
- )
- InheritedWidget? inheritFromWidgetOfExactType(Type targetType, { Object? aspect });
-
/// Obtains the nearest widget of the given type `T`, which must be the type of a
/// concrete [InheritedWidget] subclass, and registers this build context with
/// that widget such that when that widget changes (or a new widget of that
@@ -2312,17 +2287,6 @@
/// widget this context depends on.
T? dependOnInheritedWidgetOfExactType<T extends InheritedWidget>({ Object? aspect });
- /// Obtains the element corresponding to the nearest widget of the given type,
- /// which must be the type of a concrete [InheritedWidget] subclass.
- ///
- /// This method is deprecated. Please use [getElementForInheritedWidgetOfExactType] instead.
- // TODO(a14n): Remove this when it goes to stable, https://github.com/flutter/flutter/pull/44189
- @Deprecated(
- 'Use getElementForInheritedWidgetOfExactType instead. '
- 'This feature was deprecated after v1.12.1.'
- )
- InheritedElement? ancestorInheritedElementForWidgetOfExactType(Type targetType);
-
/// Obtains the element corresponding to the nearest widget of the given type `T`,
/// which must be the type of a concrete [InheritedWidget] subclass.
///
@@ -2341,17 +2305,6 @@
/// the widget is removed from the tree.
InheritedElement? getElementForInheritedWidgetOfExactType<T extends InheritedWidget>();
- /// Returns the nearest ancestor widget of the given type, which must be the
- /// type of a concrete [Widget] subclass.
- ///
- /// This method is deprecated. Please use [findAncestorWidgetOfExactType] instead.
- // TODO(a14n): Remove this when it goes to stable, https://github.com/flutter/flutter/pull/44189
- @Deprecated(
- 'Use findAncestorWidgetOfExactType instead. '
- 'This feature was deprecated after v1.12.1.'
- )
- Widget? ancestorWidgetOfExactType(Type targetType);
-
/// Returns the nearest ancestor widget of the given type `T`, which must be the
/// type of a concrete [Widget] subclass.
///
@@ -2379,17 +2332,6 @@
T? findAncestorWidgetOfExactType<T extends Widget>();
/// Returns the [State] object of the nearest ancestor [StatefulWidget] widget
- /// that matches the given [TypeMatcher].
- ///
- /// This method is deprecated. Please use [findAncestorStateOfType] instead.
- // TODO(a14n): Remove this when it goes to stable, https://github.com/flutter/flutter/pull/44189
- @Deprecated(
- 'Use findAncestorStateOfType instead. '
- 'This feature was deprecated after v1.12.1.'
- )
- State? ancestorStateOfType(TypeMatcher matcher);
-
- /// Returns the [State] object of the nearest ancestor [StatefulWidget] widget
/// that is an instance of the given type `T`.
///
/// This should not be used from build methods, because the build context will
@@ -2423,17 +2365,6 @@
T? findAncestorStateOfType<T extends State>();
/// Returns the [State] object of the furthest ancestor [StatefulWidget] widget
- /// that matches the given [TypeMatcher].
- ///
- /// This method is deprecated. Please use [findRootAncestorStateOfType] instead.
- // TODO(a14n): Remove this when it goes to stable, https://github.com/flutter/flutter/pull/44189
- @Deprecated(
- 'Use findRootAncestorStateOfType instead. '
- 'This feature was deprecated after v1.12.1.'
- )
- State? rootAncestorStateOfType(TypeMatcher matcher);
-
- /// Returns the [State] object of the furthest ancestor [StatefulWidget] widget
/// that is an instance of the given type `T`.
///
/// Functions the same way as [findAncestorStateOfType] but keeps visiting subsequent
@@ -2445,17 +2376,6 @@
T? findRootAncestorStateOfType<T extends State>();
/// Returns the [RenderObject] object of the nearest ancestor [RenderObjectWidget] widget
- /// that matches the given [TypeMatcher].
- ///
- /// This method is deprecated. Please use [findAncestorRenderObjectOfType] instead.
- // TODO(a14n): Remove this when it goes to stable, https://github.com/flutter/flutter/pull/44189
- @Deprecated(
- 'Use findAncestorRenderObjectOfType instead. '
- 'This feature was deprecated after v1.12.1.'
- )
- RenderObject? ancestorRenderObjectOfType(TypeMatcher matcher);
-
- /// Returns the [RenderObject] object of the nearest ancestor [RenderObjectWidget] widget
/// that is an instance of the given type `T`.
///
/// This should not be used from build methods, because the build context will
@@ -3959,12 +3879,15 @@
return true;
}
+ /// Registers this build context with [ancestor] such that when
+ /// [ancestor]'s widget changes this build context is rebuilt.
+ ///
+ /// This method is deprecated. Please use [dependOnInheritedElement] instead.
// TODO(a14n): Remove this when it goes to stable, https://github.com/flutter/flutter/pull/44189
@Deprecated(
'Use dependOnInheritedElement instead. '
'This feature was deprecated after v1.12.1.'
)
- @override
InheritedWidget inheritFromElement(InheritedElement ancestor, { Object? aspect }) {
return dependOnInheritedElement(ancestor, aspect: aspect);
}
@@ -3978,12 +3901,18 @@
return ancestor.widget;
}
+ /// Obtains the nearest widget of the given type, which must be the type of a
+ /// concrete [InheritedWidget] subclass, and registers this build context with
+ /// that widget such that when that widget changes (or a new widget of that
+ /// type is introduced, or the widget goes away), this build context is
+ /// rebuilt so that it can obtain new values from that widget.
+ ///
+ /// This method is deprecated. Please use [dependOnInheritedWidgetOfExactType] instead.
// TODO(a14n): Remove this when it goes to stable, https://github.com/flutter/flutter/pull/44189
@Deprecated(
'Use dependOnInheritedWidgetOfExactType instead. '
'This feature was deprecated after v1.12.1.'
)
- @override
InheritedWidget? inheritFromWidgetOfExactType(Type targetType, { Object? aspect }) {
assert(_debugCheckStateIsActiveForAncestorLookup());
final InheritedElement? ancestor = _inheritedWidgets == null ? null : _inheritedWidgets![targetType];
@@ -4007,12 +3936,15 @@
return null;
}
+ /// Obtains the element corresponding to the nearest widget of the given type,
+ /// which must be the type of a concrete [InheritedWidget] subclass.
+ ///
+ /// This method is deprecated. Please use [getElementForInheritedWidgetOfExactType] instead.
// TODO(a14n): Remove this when it goes to stable, https://github.com/flutter/flutter/pull/44189
@Deprecated(
'Use getElementForInheritedWidgetOfExactType instead. '
'This feature was deprecated after v1.12.1.'
)
- @override
InheritedElement? ancestorInheritedElementForWidgetOfExactType(Type targetType) {
assert(_debugCheckStateIsActiveForAncestorLookup());
final InheritedElement? ancestor = _inheritedWidgets == null ? null : _inheritedWidgets![targetType];
@@ -4031,12 +3963,15 @@
_inheritedWidgets = _parent?._inheritedWidgets;
}
+ /// Returns the nearest ancestor widget of the given type, which must be the
+ /// type of a concrete [Widget] subclass.
+ ///
+ /// This method is deprecated. Please use [findAncestorWidgetOfExactType] instead.
// TODO(a14n): Remove this when it goes to stable, https://github.com/flutter/flutter/pull/44189
@Deprecated(
'Use findAncestorWidgetOfExactType instead. '
'This feature was deprecated after v1.12.1.'
)
- @override
Widget? ancestorWidgetOfExactType(Type targetType) {
assert(_debugCheckStateIsActiveForAncestorLookup());
Element? ancestor = _parent;
@@ -4054,12 +3989,15 @@
return ancestor?.widget as T?;
}
+ /// Returns the [State] object of the nearest ancestor [StatefulWidget] widget
+ /// that matches the given [TypeMatcher].
+ ///
+ /// This method is deprecated. Please use [findAncestorStateOfType] instead.
// TODO(a14n): Remove this when it goes to stable, https://github.com/flutter/flutter/pull/44189
@Deprecated(
'Use findAncestorStateOfType instead. '
'This feature was deprecated after v1.12.1.'
)
- @override
State? ancestorStateOfType(TypeMatcher matcher) {
assert(_debugCheckStateIsActiveForAncestorLookup());
Element? ancestor = _parent;
@@ -4085,12 +4023,15 @@
return statefulAncestor?.state as T?;
}
+ /// Returns the [State] object of the furthest ancestor [StatefulWidget] widget
+ /// that matches the given [TypeMatcher].
+ ///
+ /// This method is deprecated. Please use [findRootAncestorStateOfType] instead.
// TODO(a14n): Remove this when it goes to stable, https://github.com/flutter/flutter/pull/44189
@Deprecated(
'Use findRootAncestorStateOfType instead. '
'This feature was deprecated after v1.12.1.'
)
- @override
State? rootAncestorStateOfType(TypeMatcher matcher) {
assert(_debugCheckStateIsActiveForAncestorLookup());
Element? ancestor = _parent;
@@ -4116,12 +4057,15 @@
return statefulAncestor?.state as T?;
}
+ /// Returns the [RenderObject] object of the nearest ancestor [RenderObjectWidget] widget
+ /// that matches the given [TypeMatcher].
+ ///
+ /// This method is deprecated. Please use [findAncestorRenderObjectOfType] instead.
// TODO(a14n): Remove this when it goes to stable, https://github.com/flutter/flutter/pull/44189
@Deprecated(
'Use findAncestorRenderObjectOfType instead. '
'This feature was deprecated after v1.12.1.'
)
- @override
RenderObject? ancestorRenderObjectOfType(TypeMatcher matcher) {
assert(_debugCheckStateIsActiveForAncestorLookup());
Element? ancestor = _parent;
diff --git a/packages/flutter/test_fixes/cupertino.dart b/packages/flutter/test_fixes/cupertino.dart
index 6bb1a8c..6860509 100644
--- a/packages/flutter/test_fixes/cupertino.dart
+++ b/packages/flutter/test_fixes/cupertino.dart
@@ -17,4 +17,14 @@
// Changes made in https://github.com/flutter/flutter/pull/44189
const StatefulElement statefulElement = StatefulElement(myWidget);
statefulElement.inheritFromElement(ancestor);
+
+ // Changes made in https://github.com/flutter/flutter/pull/44189
+ const BuildContext buildContext = Element(myWidget);
+ buildContext.inheritFromElement(ancestor);
+ buildContext.inheritFromWidgetOfExactType(targetType);
+ buildContext.ancestorInheritedElementForWidgetOfExactType(targetType);
+ buildContext.ancestorWidgetOfExactType(targetType);
+ buildContext.ancestorStateOfType(TypeMatcher<targetType>());
+ buildContext.rootAncestorStateOfType(TypeMatcher<targetType>());
+ buildContext.ancestorRenderObjectOfType(TypeMatcher<targetType>());
}
diff --git a/packages/flutter/test_fixes/cupertino.dart.expect b/packages/flutter/test_fixes/cupertino.dart.expect
index 50a87a6..d6b9fb2 100644
--- a/packages/flutter/test_fixes/cupertino.dart.expect
+++ b/packages/flutter/test_fixes/cupertino.dart.expect
@@ -17,4 +17,14 @@
// Changes made in https://github.com/flutter/flutter/pull/44189
const StatefulElement statefulElement = StatefulElement(myWidget);
statefulElement.dependOnInheritedElement(ancestor);
+
+ // Changes made in https://github.com/flutter/flutter/pull/44189
+ const BuildContext buildContext = Element(myWidget);
+ buildContext.dependOnInheritedElement(ancestor);
+ buildContext.dependOnInheritedWidgetOfExactType<targetType>();
+ buildContext.getElementForInheritedWidgetOfExactType<targetType>();
+ buildContext.findAncestorWidgetOfExactType<targetType>();
+ buildContext.findAncestorStateOfType<targetType>();
+ buildContext.findRootAncestorStateOfType<targetType>();
+ buildContext.findAncestorRenderObjectOfType<targetType>();
}
diff --git a/packages/flutter/test_fixes/material.dart b/packages/flutter/test_fixes/material.dart
index eb84fea..a5c259f 100644
--- a/packages/flutter/test_fixes/material.dart
+++ b/packages/flutter/test_fixes/material.dart
@@ -16,4 +16,14 @@
// Changes made in https://github.com/flutter/flutter/pull/44189
const StatefulElement statefulElement = StatefulElement(myWidget);
statefulElement.inheritFromElement(ancestor);
+
+ // Changes made in https://github.com/flutter/flutter/pull/44189
+ const BuildContext buildContext = Element(myWidget);
+ buildContext.inheritFromElement(ancestor);
+ buildContext.inheritFromWidgetOfExactType(targetType);
+ buildContext.ancestorInheritedElementForWidgetOfExactType(targetType);
+ buildContext.ancestorWidgetOfExactType(targetType);
+ buildContext.ancestorStateOfType(TypeMatcher<targetType>());
+ buildContext.rootAncestorStateOfType(TypeMatcher<targetType>());
+ buildContext.ancestorRenderObjectOfType(TypeMatcher<targetType>());
}
diff --git a/packages/flutter/test_fixes/material.dart.expect b/packages/flutter/test_fixes/material.dart.expect
index 256fef8..e0f9c9d 100644
--- a/packages/flutter/test_fixes/material.dart.expect
+++ b/packages/flutter/test_fixes/material.dart.expect
@@ -14,6 +14,16 @@
binding.allowFirstFrame();
// Changes made in https://github.com/flutter/flutter/pull/44189
- const StatefulElement statefulElement = StatefulElement(myWidget);
- statefulElement.dependOnInheritedElement(ancestor);
+ const StatefulElement statefulElement = StatefulElement(myWidget);
+ statefulElement.dependOnInheritedElement(ancestor);
+
+ // Changes made in https://github.com/flutter/flutter/pull/44189
+ const BuildContext buildContext = Element(myWidget);
+ buildContext.dependOnInheritedElement(ancestor);
+ buildContext.dependOnInheritedWidgetOfExactType<targetType>();
+ buildContext.getElementForInheritedWidgetOfExactType<targetType>();
+ buildContext.findAncestorWidgetOfExactType<targetType>();
+ buildContext.findAncestorStateOfType<targetType>();
+ buildContext.findRootAncestorStateOfType<targetType>();
+ buildContext.findAncestorRenderObjectOfType<targetType>();
}
diff --git a/packages/flutter/test_fixes/widgets.dart b/packages/flutter/test_fixes/widgets.dart
index f89f7d5..d288552 100644
--- a/packages/flutter/test_fixes/widgets.dart
+++ b/packages/flutter/test_fixes/widgets.dart
@@ -13,4 +13,14 @@
// Changes made in https://github.com/flutter/flutter/pull/44189
const StatefulElement statefulElement = StatefulElement(myWidget);
statefulElement.inheritFromElement(ancestor);
+
+ // Changes made in https://github.com/flutter/flutter/pull/44189
+ const BuildContext buildContext = Element(myWidget);
+ buildContext.inheritFromElement(ancestor);
+ buildContext.inheritFromWidgetOfExactType(targetType);
+ buildContext.ancestorInheritedElementForWidgetOfExactType(targetType);
+ buildContext.ancestorWidgetOfExactType(targetType);
+ buildContext.ancestorStateOfType(TypeMatcher<targetType>());
+ buildContext.rootAncestorStateOfType(TypeMatcher<targetType>());
+ buildContext.ancestorRenderObjectOfType(TypeMatcher<targetType>());
}
diff --git a/packages/flutter/test_fixes/widgets.dart.expect b/packages/flutter/test_fixes/widgets.dart.expect
index 2b6b7b4..e985bd4 100644
--- a/packages/flutter/test_fixes/widgets.dart.expect
+++ b/packages/flutter/test_fixes/widgets.dart.expect
@@ -13,4 +13,14 @@
// Changes made in https://github.com/flutter/flutter/pull/44189
const StatefulElement statefulElement = StatefulElement(myWidget);
statefulElement.dependOnInheritedElement(ancestor);
+
+ // Changes made in https://github.com/flutter/flutter/pull/44189
+ const BuildContext buildContext = Element(myWidget);
+ buildContext.dependOnInheritedElement(ancestor);
+ buildContext.dependOnInheritedWidgetOfExactType<targetType>();
+ buildContext.getElementForInheritedWidgetOfExactType<targetType>();
+ buildContext.findAncestorWidgetOfExactType<targetType>();
+ buildContext.findAncestorStateOfType<targetType>();
+ buildContext.findRootAncestorStateOfType<targetType>();
+ buildContext.findAncestorRenderObjectOfType<targetType>();
}