diff --git a/packages/flutter/lib/fix_data.yaml b/packages/flutter/lib/fix_data.yaml index 52d64a4a7ee0..b676546716ae 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 71b3bc791e8e..91764b32296f 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -2233,17 +2233,6 @@ abstract class BuildContext { /// render object is usually short. Size? get size; - /// 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. /// @@ -2257,20 +2246,6 @@ abstract class BuildContext { /// 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 @@ abstract class BuildContext { /// widget this context depends on. T? dependOnInheritedWidgetOfExactType({ 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 @@ abstract class BuildContext { /// the widget is removed from the tree. InheritedElement? getElementForInheritedWidgetOfExactType(); - /// 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. /// @@ -2378,17 +2331,6 @@ abstract class BuildContext { /// ancestors of this context. T? findAncestorWidgetOfExactType(); - /// 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`. /// @@ -2422,17 +2364,6 @@ abstract class BuildContext { /// {@end-tool} T? findAncestorStateOfType(); - /// 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`. /// @@ -2444,17 +2375,6 @@ abstract class BuildContext { /// a subtree. T? findRootAncestorStateOfType(); - /// 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`. /// @@ -3959,12 +3879,15 @@ abstract class Element extends DiagnosticableTree implements BuildContext { 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 @@ abstract class Element extends DiagnosticableTree implements BuildContext { 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 @@ abstract class Element extends DiagnosticableTree implements BuildContext { 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 @@ abstract class Element extends DiagnosticableTree implements BuildContext { _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 @@ abstract class Element extends DiagnosticableTree implements BuildContext { 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 @@ abstract class Element extends DiagnosticableTree implements BuildContext { 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 @@ abstract class Element extends DiagnosticableTree implements BuildContext { 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 6bb1a8cb5310..686050917427 100644 --- a/packages/flutter/test_fixes/cupertino.dart +++ b/packages/flutter/test_fixes/cupertino.dart @@ -17,4 +17,14 @@ void main() { // 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()); + buildContext.rootAncestorStateOfType(TypeMatcher()); + buildContext.ancestorRenderObjectOfType(TypeMatcher()); } diff --git a/packages/flutter/test_fixes/cupertino.dart.expect b/packages/flutter/test_fixes/cupertino.dart.expect index 50a87a60aaae..d6b9fb2fbd0a 100644 --- a/packages/flutter/test_fixes/cupertino.dart.expect +++ b/packages/flutter/test_fixes/cupertino.dart.expect @@ -17,4 +17,14 @@ void main() { // 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(); + buildContext.getElementForInheritedWidgetOfExactType(); + buildContext.findAncestorWidgetOfExactType(); + buildContext.findAncestorStateOfType(); + buildContext.findRootAncestorStateOfType(); + buildContext.findAncestorRenderObjectOfType(); } diff --git a/packages/flutter/test_fixes/material.dart b/packages/flutter/test_fixes/material.dart index eb84fea84bc8..a5c259ff3f89 100644 --- a/packages/flutter/test_fixes/material.dart +++ b/packages/flutter/test_fixes/material.dart @@ -16,4 +16,14 @@ void main() { // 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()); + buildContext.rootAncestorStateOfType(TypeMatcher()); + buildContext.ancestorRenderObjectOfType(TypeMatcher()); } diff --git a/packages/flutter/test_fixes/material.dart.expect b/packages/flutter/test_fixes/material.dart.expect index 256fef873e84..e0f9c9d4d567 100644 --- a/packages/flutter/test_fixes/material.dart.expect +++ b/packages/flutter/test_fixes/material.dart.expect @@ -14,6 +14,16 @@ void main() { 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(); + buildContext.getElementForInheritedWidgetOfExactType(); + buildContext.findAncestorWidgetOfExactType(); + buildContext.findAncestorStateOfType(); + buildContext.findRootAncestorStateOfType(); + buildContext.findAncestorRenderObjectOfType(); } diff --git a/packages/flutter/test_fixes/widgets.dart b/packages/flutter/test_fixes/widgets.dart index f89f7d54f01d..d2885520c130 100644 --- a/packages/flutter/test_fixes/widgets.dart +++ b/packages/flutter/test_fixes/widgets.dart @@ -13,4 +13,14 @@ void main() { // 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()); + buildContext.rootAncestorStateOfType(TypeMatcher()); + buildContext.ancestorRenderObjectOfType(TypeMatcher()); } diff --git a/packages/flutter/test_fixes/widgets.dart.expect b/packages/flutter/test_fixes/widgets.dart.expect index 2b6b7b45cea9..e985bd47f5c4 100644 --- a/packages/flutter/test_fixes/widgets.dart.expect +++ b/packages/flutter/test_fixes/widgets.dart.expect @@ -13,4 +13,14 @@ void main() { // 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(); + buildContext.getElementForInheritedWidgetOfExactType(); + buildContext.findAncestorWidgetOfExactType(); + buildContext.findAncestorStateOfType(); + buildContext.findRootAncestorStateOfType(); + buildContext.findAncestorRenderObjectOfType(); }