Skip to main content

Deprecated API removed after v1.22

Summary

#

In accordance with Flutter's Deprecation Policy, deprecated APIs that reached end of life after the 1.22 stable release have been removed. This is the first time that deprecated APIs have been removed from Flutter, and some of these deprecations predate our migration guide policy.

All affected APIs have been compiled into this primary source to aid in migration. A quick reference sheet is available as well.

A design document and article are available for more context on Flutter's deprecation policy.

Changes

#

This section lists the deprecations, listed by the affected class.

CupertinoDialog

#

Supported by fix tool: IDE fix only.

CupertinoDialog was deprecated in v0.2.3. Use CupertinoAlertDialog or CupertinoPopupSurface instead.

Migration guide

CupertinoAlertDialog

Code before migration:

dart
CupertinoDialog(child: myWidget);

Code after migration:

dart
CupertinoAlertDialog(content: myWidget);

CupertinoPopupSurface

Code before migration:

dart
CupertinoDialog(child: myWidget);

Code after migration:

dart
CupertinoPopupSurface(child: myWidget);

References

API documentation:

Relevant issues:

Relevant PRs:


Cupertino navigation bars' actionsForegroundColor

#

Supported by fix tool: No

CupertinoNavigationBar.actionsForegroundColor and CupertinoSliverNavigationBar.actionsForegroundColor were deprecated in v1.1.2. Setting primaryColor in your CupertinoTheme propagates this instead. To access the primaryColor, call CupertinoTheme.of(context).primaryColor.

Migration guide

Code before migration:

dart
CupertinoNavigationBar(
  actionsForegroundColor: CupertinoColors.systemBlue,
);
CupertinoSliverNavigationBar(
  actionsForegroundColor: CupertinoColors.systemBlue,
);

Code after migration:

dart
CupertinoTheme(
  data: CupertinoThemeData(
    primaryColor: CupertinoColors.systemBlue
  ),
  child: ...
);

// To access the color from the `CupertinoTheme`
CupertinoTheme.of(context).primaryColor;

References

API documentation:

Relevant issues:

Relevant PRs:


CupertinoTextThemeData.brightness

#

Supported by fix tool: Yes

CupertinoTextThemeData.brightness was deprecated in v1.10.14. This field member was made ineffective at the time of deprecation. There is no replacement for this parameter, references should be removed.

Migration guide

Code before migration:

dart
const CupertinoTextThemeData themeData = CupertinoTextThemeData(brightness: Brightness.dark);
themeData.copyWith(brightness: Brightness.light);

Code after migration:

dart
const CupertinoTextThemeData themeData = CupertinoTextThemeData();
themeData.copyWith();

References

API documentation:

Relevant issues:

Relevant PRs:


Pointer events constructed fromHoverEvent

#

Supported by fix tool: Yes

The fromHoverEvent constructors for PointerEnterEvent and PointerExitEvent were deprecated in v1.4.3. The fromMouseEvent constructor should be used instead.

Migration guide

Code before migration:

dart
final PointerEnterEvent enterEvent = PointerEnterEvent.fromHoverEvent(PointerHoverEvent());
final PointerExitEvent exitEvent = PointerExitEvent.fromHoverEvent(PointerHoverEvent());

Code after migration:

dart
final PointerEnterEvent enterEvent = PointerEnterEvent.fromMouseEvent(PointerHoverEvent());
final PointerExitEvent exitEvent = PointerExitEvent.fromMouseEvent(PointerHoverEvent());

References

API documentation:

Relevant issues:

Relevant PRs:


showDialog uses builder

#

Supported by fix tool: Yes

The child parameter of showDialog was deprecated in v0.2.3. The builder parameter should be used instead.

Migration guide

Code before migration:

dart
showDialog(child: myWidget);

Code after migration:

dart
showDialog(builder: (context) => myWidget);

References

API documentation:

Relevant issues:

Relevant PRs:


Scaffold.resizeToAvoidBottomPadding

#

Supported by fix tool: Yes

The resizeToAvoidBottomPadding parameter of Scaffold was deprecated in v1.1.9. The resizeToAvoidBottomInset parameter should be used instead.

Migration guide

Code before migration:

dart
Scaffold(resizeToAvoidBottomPadding: true);

Code after migration:

dart
Scaffold(resizeToAvoidBottomInset: true);

References

API documentation:

Relevant issues:

Relevant PRs:


ButtonTheme.bar

#

Supported by fix tool: No

The bar constructor of ButtonTheme was deprecated in v1.9.1. ButtonBarTheme can be used instead for ButtonBars, or use another constructor of ButtonTheme if the use is not specific to ButtonBar.

Button-specific theming is also available with the TextButtonTheme, ElevatedButtonTheme, and OutlinedButtonTheme classes, each corresponding with the appropriate button class, TextButton, ElevatedButton and OutlinedButton.

Migration guide

Code before migration:

dart
ButtonTheme.bar(
  minWidth: 10.0,
  alignedDropdown: true,
  height: 40.0,
);

Code after migration, using ButtonTheme:

dart
ButtonTheme(
  minWidth: 10.0,
  alignedDropdown: true,
  height: 40.0,
);

Code after migration, using ButtonBarTheme:

dart
ButtonBarTheme(
  data: ButtonBarThemeData(
    buttonMinWidth: 10.0,
    buttonAlignedDropdown: true,
    buttonHeight: 40.0,
  )
);

References

API documentation:

Relevant issues:

Relevant PRs:


InlineSpan, TextSpan, PlaceholderSpan

#

Supported by fix tool: No

The following methods were deprecated in the InlineSpan, TextSpan and PlaceholderSpan in order to enable embedding widgets inline into paragraphs, like images.

Migration guide

Code before migrationCode after migration
InlineSpan.textTextSpan.text
InlineSpan.childrenTextSpan.children
InlineSpan.visitTextSpanInlineSpan.visitChildren
InlineSpan.recognizerTextSpan.recognizer
InlineSpan.describeSemanticsInlineSpan.computeSemanticsInformation
PlaceholderSpan.visitTextSpanPlaceHolderSpan.visitChildren
TextSpan.visitTextSpanTextSpan.visitChildren

References

API documentation:

Relevant issues:

Relevant PRs:


RenderView.scheduleInitialFrame

#

Supported by fix tool: No

The RenderView.scheduleInitialFrame method was deprecated and removed in order to prevent splash screens from being taken down too early, resulting in a black screen. This would happen when WidgetsFlutterBinding.ensureInitialized was called. Instead, replace calls to this method with RenderView.prepareInitialFrame, followed by RenderView.owner.requestVisualUpdate.

Migration guide

Code before migration:

dart
scheduleInitialFrame();

Code after migration:

dart
prepareInitialFrame();
owner.requestVisualUpdate();

References

API documentation:

Relevant issues:

Relevant PRs:


Layer.findAll

#

Supported by fix tool: No

The Layer.findAll method was deprecated with the introduction of Layer.findAnnotations in order to unify the implementations of find and findAll. To migrate affected code, call findAllAnnotations instead. This method returns an AnnotationResult, containing the former return value of findAll in AnnotationResult.annotations.

Migration guide

Code before migration:

dart
findAll(offset);

Code after migration:

dart
findAllAnnotations(offset).annotations;

References

API documentation:

Relevant issues:

Relevant PRs:


BinaryMessages

#

Supported by fix tool: No

The BinaryMessages class, its associated static methods and the defaultBinaryMessenger getter were deprecated and removed. The defaultBinaryMessenger instance was moved to ServicesBinding. This made it possible to register a different default BinaryMessenger under testing environment, by creating a ServicesBinding subclass for testing. Doing so allows you to track the number of pending platform messages for synchronization purposes.

Migration guide

Code before migration:Code after migration:
defaultBinaryMessengerServicesBinding.instance.defaultBinaryMessenger
BinaryMessagesBinaryMessenger
BinaryMessages.handlePlatformMessageServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage
BinaryMessages.sendServicesBinding.instance.defaultBinaryMessenger.send
BinaryMessages.setMessageHandlerServicesBinding.instance.defaultBinaryMessenger.setMessageHandler
BinaryMessages.setMockMessageHandlerServicesBinding.instance.defaultBinaryMessenger.setMockMessageHandler

References

API documentation:

Relevant issues:

Relevant PRs:


Generic methods for BuildContext

#

Supported by fix tool: Yes

Several methods in BuildContext were using Type to search for ancestors. Most of those methods implied a cast at call site because their return type was a parent type. Moreover the type provided was not checked at analysis time even if the type is actually constrained. Making these methods generics improves type safety and requires less code.

These method changes affect the BuildContext, Element, and StatefulElement classes. The TypeMatcher class was also removed.

Migration guide

Code before migration:

dart
ComplexLayoutState state = context.ancestorStateOfType(const TypeMatcher<ComplexLayoutState>()) as ComplexLayoutState;

Code after migration:

dart
ComplexLayoutState state = context.ancestorStateOfType<ComplexLayoutState>();

BuildContext

Code before migration:Code after migration:
inheritFromElementdependOnInheritedElement
inheritFromWidgetOfExactTypedependOnInheritedWidgetOfExactType
ancestorInheritedElementForWidgetOfExactTypegetElementForInheritedWidgetOfExactType
ancestorWidgetOfExactTypefindAncestorWidgetOfExactType
ancestorStateOfTypefindAncestorStateOfType
rootAncestorStateOfTypefindRootAncestorStateOfType
ancestorRenderObjectOfTypefindAncestorRenderObjectOfType

Element

Code before migration:Code after migration:
inheritFromElementdependOnInheritedElement
inheritFromWidgetOfExactTypedependOnInheritedWidgetOfExactType
ancestorInheritedElementForWidgetOfExactTypegetElementForInheritedWidgetOfExactType
ancestorWidgetOfExactTypefindAncestorWidgetOfExactType
ancestorStateOfTypefindAncestorStateOfType
rootAncestorStateOfTypefindRootAncestorStateOfType
ancestorRenderObjectOfTypefindAncestorRenderObjectOfType

StatefulElement

Code before migration:Code after migration:
inheritFromElementdependOnInheritedElement

References

API documentation:

Relevant PRs:


WidgetsBinding.deferFirstFrameReport & WidgetsBinding.allowFirstFrameReport

#

Supported by fix tool: Yes

The deferFirstFrameReport and allowFirstFrameReport methods of WidgetsBinding were deprecated and removed in order to provide the option to delay rendering the first frame. This is useful for widgets that need to obtain initialization information asynchronously and while they are waiting for that information no frame should render as that would take down the splash screen pre-maturely. The deferFirstFrame and allowFirstFrame methods should be used respectively instead.

Migration guide

Code before migration:

dart
final WidgetsBinding binding = WidgetsBinding.instance;
binding.deferFirstFrameReport();
binding.allowFirstFrameReport();

Code after migration:

dart
final WidgetsBinding binding = WidgetsBinding.instance;
binding.deferFirstFrame();
binding.allowFirstFrame();

References

API documentation:

Relevant PRs:


WaitUntilNoTransientCallbacks, WaitUntilNoPendingFrame, & WaitUntilFirstFrameRasterized

#

Supported by fix tool: No

The WaitUntilNoTransientCallbacks, WaitUntilNoPendingFrame, and WaitUntilFirstFrameRasterized methods from the flutter_driver packages were deprecated and removed in order to provide a more composable waitForCondition API that can be used to compose conditions that the client would like to wait for.

Migration guide

Code before migration:Code after migration:
WaitUntilNoTransientCallbacksWaitForCondition(NoTransientCallbacks())
WaitUntilNoPendingFrameWaitForCondition(NoPendingFrame())
WaitUntilFirstFrameRasterizedWaitForCondition(FirstFrameRasterized))

References

API documentation:

Relevant issues:

Relevant PRs:


Timeline

#

In stable release: 2.0.0