Unverified Commit 550a85da authored by Kate Lovett's avatar Kate Lovett Committed by GitHub

Remove deprecated Element methods (#72903)

parent 45cf2792
......@@ -11,6 +11,149 @@
version: 1
transforms:
# Changes made in https://github.com/flutter/flutter/pull/44189.
- title: 'Rename to dependOnInheritedElement'
date: 2020-12-23
element:
uris: [ 'material.dart', 'cupertino.dart', 'widgets.dart' ]
method: 'inheritFromElement'
inClass: 'Element'
changes:
- kind: 'rename'
newName: 'dependOnInheritedElement'
# Changes made in https://github.com/flutter/flutter/pull/44189.
- title: 'Rename to dependOnInheritedWidgetOfExactType'
date: 2020-09-14
element:
uris: [ 'material.dart', 'cupertino.dart', 'widgets.dart' ]
method: 'inheritFromWidgetOfExactType'
inClass: 'Element'
changes:
- kind: 'rename'
newName: 'dependOnInheritedWidgetOfExactType'
- kind: 'addTypeParameter'
index: 0
name: 'T'
argumentValue:
expression: '{% type %}'
variables:
type:
kind: 'fragment'
value: 'arguments[0]'
- kind: 'removeParameter'
index: 0
# Changes made in https://github.com/flutter/flutter/pull/44189.
- title: 'Rename to getElementForInheritedWidgetOfExactType'
date: 2020-09-14
element:
uris: [ 'material.dart', 'cupertino.dart', 'widgets.dart' ]
method: 'ancestorInheritedElementForWidgetOfExactType'
inClass: 'Element'
changes:
- kind: 'rename'
newName: 'getElementForInheritedWidgetOfExactType'
- kind: 'addTypeParameter'
index: 0
name: 'T'
argumentValue:
expression: '{% type %}'
variables:
type:
kind: 'fragment'
value: 'arguments[0]'
- kind: 'removeParameter'
index: 0
# Changes made in https://github.com/flutter/flutter/pull/44189.
- title: 'Rename to getElementForInheritedWidgetOfExactType'
date: 2020-12-23
element:
uris: [ 'material.dart', 'cupertino.dart', 'widgets.dart' ]
method: 'ancestorWidgetOfExactType'
inClass: 'Element'
changes:
- kind: 'rename'
newName: 'findAncestorWidgetOfExactType'
- kind: 'addTypeParameter'
index: 0
name: 'T'
argumentValue:
expression: '{% type %}'
variables:
type:
kind: 'fragment'
value: 'arguments[0]'
- kind: 'removeParameter'
index: 0
# Changes made in https://github.com/flutter/flutter/pull/44189.
- title: 'Rename to findAncestorStateOfType'
date: 2020-12-23
element:
uris: [ 'material.dart', 'cupertino.dart', 'widgets.dart' ]
method: 'ancestorStateOfType'
inClass: 'Element'
changes:
- kind: 'rename'
newName: 'findAncestorStateOfType'
- kind: 'addTypeParameter'
index: 0
name: 'T'
argumentValue:
expression: '{% type %}'
variables:
type:
kind: 'fragment'
value: 'arguments[0].typeArguments[0]'
- kind: 'removeParameter'
index: 0
# Changes made in https://github.com/flutter/flutter/pull/44189.
- title: 'Rename to findAncestorRenderObjectOfType'
date: 2020-12-23
element:
uris: [ 'material.dart', 'cupertino.dart', 'widgets.dart' ]
method: 'ancestorRenderObjectOfType'
inClass: 'Element'
changes:
- kind: 'rename'
newName: 'findAncestorRenderObjectOfType'
- kind: 'addTypeParameter'
index: 0
name: 'T'
argumentValue:
expression: '{% type %}'
variables:
type:
kind: 'fragment'
value: 'arguments[0].typeArguments[0]'
- kind: 'removeParameter'
index: 0
# Changes made in https://github.com/flutter/flutter/pull/44189.
- title: 'Rename to findAncestorRenderObjectOfType'
date: 2020-12-23
element:
uris: [ 'material.dart', 'cupertino.dart', 'widgets.dart' ]
method: 'rootAncestorStateOfType'
inClass: 'Element'
changes:
- kind: 'rename'
newName: 'findRootAncestorStateOfType'
- kind: 'addTypeParameter'
index: 0
name: 'T'
argumentValue:
expression: '{% type %}'
variables:
type:
kind: 'fragment'
value: 'arguments[0].typeArguments[0]'
- kind: 'removeParameter'
index: 0
# Changes made in https://github.com/flutter/flutter/pull/26259
- title: 'Rename to resizeToAvoidBottomInset'
date: 2020-12-23
......
......@@ -3879,19 +3879,6 @@ 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.'
)
InheritedWidget inheritFromElement(InheritedElement ancestor, { Object? aspect }) {
return dependOnInheritedElement(ancestor, aspect: aspect);
}
@override
InheritedWidget dependOnInheritedElement(InheritedElement ancestor, { Object? aspect }) {
assert(ancestor != null);
......@@ -3901,29 +3888,6 @@ 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.'
)
InheritedWidget? inheritFromWidgetOfExactType(Type targetType, { Object? aspect }) {
assert(_debugCheckStateIsActiveForAncestorLookup());
final InheritedElement? ancestor = _inheritedWidgets == null ? null : _inheritedWidgets![targetType];
if (ancestor != null) {
assert(ancestor is InheritedElement);
return inheritFromElement(ancestor, aspect: aspect);
}
_hadUnsatisfiedDependencies = true;
return null;
}
@override
T? dependOnInheritedWidgetOfExactType<T extends InheritedWidget>({Object? aspect}) {
assert(_debugCheckStateIsActiveForAncestorLookup());
......@@ -3936,21 +3900,6 @@ 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.'
)
InheritedElement? ancestorInheritedElementForWidgetOfExactType(Type targetType) {
assert(_debugCheckStateIsActiveForAncestorLookup());
final InheritedElement? ancestor = _inheritedWidgets == null ? null : _inheritedWidgets![targetType];
return ancestor;
}
@override
InheritedElement? getElementForInheritedWidgetOfExactType<T extends InheritedWidget>() {
assert(_debugCheckStateIsActiveForAncestorLookup());
......@@ -3963,23 +3912,6 @@ 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.'
)
Widget? ancestorWidgetOfExactType(Type targetType) {
assert(_debugCheckStateIsActiveForAncestorLookup());
Element? ancestor = _parent;
while (ancestor != null && ancestor.widget.runtimeType != targetType)
ancestor = ancestor._parent;
return ancestor?.widget;
}
@override
T? findAncestorWidgetOfExactType<T extends Widget>() {
assert(_debugCheckStateIsActiveForAncestorLookup());
......@@ -3989,27 +3921,6 @@ 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.'
)
State? ancestorStateOfType(TypeMatcher matcher) {
assert(_debugCheckStateIsActiveForAncestorLookup());
Element? ancestor = _parent;
while (ancestor != null) {
if (ancestor is StatefulElement && matcher.check(ancestor.state))
break;
ancestor = ancestor._parent;
}
final StatefulElement? statefulAncestor = ancestor as StatefulElement?;
return statefulAncestor?.state;
}
@override
T? findAncestorStateOfType<T extends State<StatefulWidget>>() {
assert(_debugCheckStateIsActiveForAncestorLookup());
......@@ -4023,27 +3934,6 @@ 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.'
)
State? rootAncestorStateOfType(TypeMatcher matcher) {
assert(_debugCheckStateIsActiveForAncestorLookup());
Element? ancestor = _parent;
StatefulElement? statefulAncestor;
while (ancestor != null) {
if (ancestor is StatefulElement && matcher.check(ancestor.state))
statefulAncestor = ancestor;
ancestor = ancestor._parent;
}
return statefulAncestor?.state;
}
@override
T? findRootAncestorStateOfType<T extends State<StatefulWidget>>() {
assert(_debugCheckStateIsActiveForAncestorLookup());
......@@ -4057,26 +3947,6 @@ 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.'
)
RenderObject? ancestorRenderObjectOfType(TypeMatcher matcher) {
assert(_debugCheckStateIsActiveForAncestorLookup());
Element? ancestor = _parent;
while (ancestor != null) {
if (ancestor is RenderObjectElement && matcher.check(ancestor.renderObject))
return ancestor.renderObject;
ancestor = ancestor._parent;
}
return null;
}
@override
T? findAncestorRenderObjectOfType<T extends RenderObject>() {
assert(_debugCheckStateIsActiveForAncestorLookup());
......
......@@ -9,6 +9,16 @@ void main() {
const CupertinoTextThemeData themeData = CupertinoTextThemeData(brightness: Brightness.dark);
themeData.copyWith(brightness: Brightness.light);
// Changes made in https://github.com/flutter/flutter/pull/44189
const Element element = Element(myWidget);
element.inheritFromElement(ancestor);
element.inheritFromWidgetOfExactType(targetType);
element.ancestorInheritedElementForWidgetOfExactType(targetType);
element.ancestorWidgetOfExactType(targetType);
element.ancestorStateOfType(TypeMatcher<targetType>());
element.rootAncestorStateOfType(TypeMatcher<targetType>());
element.ancestorRenderObjectOfType(TypeMatcher<targetType>());
// Changes made in https://github.com/flutter/flutter/pull/45941
final WidgetsBinding binding = WidgetsBinding.instance!;
binding.deferFirstFrameReport();
......
......@@ -9,6 +9,16 @@ void main() {
const CupertinoTextThemeData themeData = CupertinoTextThemeData();
themeData.copyWith();
// Changes made in https://github.com/flutter/flutter/pull/44189
const Element element = Element(myWidget);
element.dependOnInheritedElement(ancestor);
element.dependOnInheritedWidgetOfExactType<targetType>();
element.getElementForInheritedWidgetOfExactType<targetType>();
element.findAncestorWidgetOfExactType<targetType>();
element.findAncestorStateOfType<targetType>();
element.findRootAncestorStateOfType<targetType>();
element.findAncestorRenderObjectOfType<targetType>();
// Changes made in https://github.com/flutter/flutter/pull/45941
final WidgetsBinding binding = WidgetsBinding.instance!;
binding.deferFirstFrame();
......
......@@ -13,6 +13,16 @@ void main() {
// Change made in https://github.com/flutter/flutter/pull/15303
showDialog(child: Text('Fix me.'));
// Changes made in https://github.com/flutter/flutter/pull/44189
const Element element = Element(myWidget);
element.inheritFromElement(ancestor);
element.inheritFromWidgetOfExactType(targetType);
element.ancestorInheritedElementForWidgetOfExactType(targetType);
element.ancestorWidgetOfExactType(targetType);
element.ancestorStateOfType(TypeMatcher<targetType>());
element.rootAncestorStateOfType(TypeMatcher<targetType>());
element.ancestorRenderObjectOfType(TypeMatcher<targetType>());
// Changes made in https://github.com/flutter/flutter/pull/45941
final WidgetsBinding binding = WidgetsBinding.instance!;
binding.deferFirstFrameReport();
......
......@@ -13,6 +13,16 @@ void main() {
// Change made in https://github.com/flutter/flutter/pull/15303
showDialog(builder: (context) => Text('Fix me.'));
// Changes made in https://github.com/flutter/flutter/pull/44189
const Element element = Element(myWidget);
element.dependOnInheritedElement(ancestor);
element.dependOnInheritedWidgetOfExactType<targetType>();
element.getElementForInheritedWidgetOfExactType<targetType>();
element.findAncestorWidgetOfExactType<targetType>();
element.findAncestorStateOfType<targetType>();
element.findRootAncestorStateOfType<targetType>();
element.findAncestorRenderObjectOfType<targetType>();
// Changes made in https://github.com/flutter/flutter/pull/45941
final WidgetsBinding binding = WidgetsBinding.instance!;
binding.deferFirstFrame();
......
......@@ -5,6 +5,16 @@
import 'package:flutter/widgets.dart';
void main() {
// Changes made in https://github.com/flutter/flutter/pull/44189
const Element element = Element(myWidget);
element.inheritFromElement(ancestor);
element.inheritFromWidgetOfExactType(targetType);
element.ancestorInheritedElementForWidgetOfExactType(targetType);
element.ancestorWidgetOfExactType(targetType);
element.ancestorStateOfType(TypeMatcher<targetType>());
element.rootAncestorStateOfType(TypeMatcher<targetType>());
element.ancestorRenderObjectOfType(TypeMatcher<targetType>());
// Changes made in https://github.com/flutter/flutter/pull/45941
final WidgetsBinding binding = WidgetsBinding.instance!;
binding.deferFirstFrameReport();
......
......@@ -5,6 +5,16 @@
import 'package:flutter/widgets.dart';
void main() {
// Changes made in https://github.com/flutter/flutter/pull/44189
const Element element = Element(myWidget);
element.dependOnInheritedElement(ancestor);
element.dependOnInheritedWidgetOfExactType<targetType>();
element.getElementForInheritedWidgetOfExactType<targetType>();
element.findAncestorWidgetOfExactType<targetType>();
element.findAncestorStateOfType<targetType>();
element.findRootAncestorStateOfType<targetType>();
element.findAncestorRenderObjectOfType<targetType>();
// Changes made in https://github.com/flutter/flutter/pull/45941
final WidgetsBinding binding = WidgetsBinding.instance!;
binding.deferFirstFrame();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment