Deprecated API removed after v2.5

Summary

#

In accordance with Flutter's Deprecation Policy, deprecated APIs that reached end of life after the 2.5 stable release have been removed.

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

Changes

#

This section lists the deprecations by affected class.


#

Supported by Flutter Fix: yes

autovalidate was deprecated in v1.19.

Use autovalidateMode instead. Where autovalidate was true, replace with AutovalidateMode.always. Where autovalidate was false, replace with AutovalidateMode.disabled. This change allows more behaviors to be specified beyond the original binary choice, adding AutovalidateMode.onUserInteraction as an additional option.

The following classes all have the same change of API:

  • Form
  • FormField
  • DropdownButtonFormField
  • TextFormField

Migration guide

In-depth migration guide available

Code before migration:

dart
const Form form = Form(autovalidate: true);
const Form form = Form(autovalidate: false);
final autoMode = form.autovalidate;

const FormField formField = FormField(autovalidate: true);
const FormField formField = FormField(autovalidate: false);
final autoMode = formField.autovalidate;

const TextFormField textFormField = TextFormField(autovalidate: true);
const TextFormField textFormField = TextFormField(autovalidate: false);

const DropdownButtonFormField dropDownButtonFormField = DropdownButtonFormField(autovalidate: true);
const DropdownButtonFormField dropdownButtonFormField = DropdownButtonFormField(autovalidate: false);

Code after migration:

dart
const Form form = Form(autovalidateMode: AutovalidateMode.always);
const Form form = Form(autovalidateMode: AutovalidateMode.disabled);
final autoMode = form.autovalidateMode;

const FormField formField = FormField(autovalidateMode: AutovalidateMode.always);
const FormField formField = FormField(autovalidateMode: AutovalidateMode.disabled);
final autoMode = formField.autovalidateMode;

const TextFormField textFormField = TextFormField(autovalidateMode: AutovalidateMode.always);
const TextFormField textFormField = TextFormField(autovalidateMode: AutovalidateMode.disabled);

const DropdownButtonFormField dropDownButtonFormField = DropdownButtonFormField(autovalidateMode: AutovalidateMode.always);
const DropdownButtonFormField dropdownButtonFormField = DropdownButtonFormField(autovalidateMode: AutovalidateMode.disabled);

References

API documentation:

Relevant issues:

Relevant PRs:


FloatingHeaderSnapConfiguration.vsync

#

Supported by Flutter Fix: no

The TickerProvider vsync property of FloatingHeaderSnapConfiguration was deprecated in v1.19.

The vsync for the animation should instead be specified using SliverPersistentHeaderDelegate.vsync.

Migration guide

Code before migration:

dart
class MySliverPersistentHeaderDelegate extends SliverPersistentHeaderDelegate {
  FloatingHeaderSnapConfiguration? get snapConfiguration => FloatingHeaderSnapConfiguration(vsync: myTickerProvider);
}

Code after migration:

dart
class MySliverPersistentHeaderDelegate extends SliverPersistentHeaderDelegate {
  FloatingHeaderSnapConfiguration? get snapConfiguration => FloatingHeaderSnapConfiguration();
  TickerProvider? get vsync => myTickerProvider;
}

References

Design document:

API documentation:

Relevant issues:

Relevant PRs:


AndroidViewController & subclasses' id

#

Supported by Flutter Fix: yes

The id of AndroidViewController, TextureAndroidViewController, and SurfaceAndroidViewController, was deprecated in v1.20.

For all of these use cases, viewId should be used instead.

Migration guide

Code before migration:

dart
final SurfaceAndroidViewController surfaceController = SurfaceAndroidViewController(
  viewId: 10,
  viewType: 'FixTester',
  layoutDirection: TextDirection.ltr,
);
int viewId = surfaceController.id;
final SurfaceAndroidViewController surfaceController = SurfaceAndroidViewController(
  error: '',
);
final TextureAndroidViewController textureController = TextureAndroidViewController(
  error: '',
);
final TextureAndroidViewController textureController = TextureAndroidViewController(
  viewId: 10,
  viewType: 'FixTester',
  layoutDirection: TextDirection.ltr,
);
viewId = textureController.id;

Code after migration:

dart
final SurfaceAndroidViewController surfaceController = SurfaceAndroidViewController(
  viewId: 10,
  viewType: 'FixTester',
  layoutDirection: TextDirection.ltr,
);
int viewId = surfaceController.viewId;
final SurfaceAndroidViewController surfaceController = SurfaceAndroidViewController(
  error: '',
);
final TextureAndroidViewController textureController = TextureAndroidViewController(
  error: '',
);
final TextureAndroidViewController textureController = TextureAndroidViewController(
  viewId: 10,
  viewType: 'FixTester',
  layoutDirection: TextDirection.ltr,
);
viewId = textureController.viewId;

References

Design document:

API documentation:

Relevant issues:

Relevant PRs:


BlacklistingTextInputFormatter & WhitelistingTextInputFormatter

#

Supported by Flutter Fix: no

The entire classes of BlacklistingTextInputFormatter and WhitelistingTextInoutFormatter were deprecated in v1.20.

Their functionality has been rewritten into a single class, FilteringTextInputFormatter.

Migration guide

Code before migration:

dart
formatter = BlacklistingTextInputFormatter(pattern, replacementString: 'replacedPattern');
formatter = BlacklistingTextInputFormatter.singleLineFormatter;
pattern = formatter.blacklistedPattern;
formatter = WhitelistingTextInputFormatter(pattern);
formatter = WhitelistingTextInputFormatter.digitsOnly;
pattern = formatter.whitelistedPattern;

Code after migration:

dart
formatter = FilteringTextInputFormatter.deny(pattern, replacementString: 'replacedPattern');
formatter = FilteringTextInputFormatter.singleLineFormatter;
pattern = formatter.filterPattern;
formatter = FilteringTextInputFormatter.allow(pattern);
formatter = FilteringTextInputFormatter.digitsOnly;
pattern = formatter.filterPattern;

References

API documentation:

Relevant PRs:


BottomNavigationBarItem.title

#

Supported by Flutter Fix: yes

The title of BottomNavigationBarItem was deprecated in v1.19. The label property should be used instead. This migration allows for better text scaling, and presents built-in Tooltips for the BottomNavigationBarItem in the context of a BottomNavigationBar.

Migration guide

In-depth migration guide available

Code before migration:

dart
const BottomNavigationBarItem bottomNavigationBarItem = BottomNavigationBarItem(title: myTitle);
const BottomNavigationBarItem bottomNavigationBarItem = BottomNavigationBarItem();
bottomNavigationBarItem.title;

Code after migration:

dart
const BottomNavigationBarItem bottomNavigationBarItem = BottomNavigationBarItem(label: myTitle);
const BottomNavigationBarItem bottomNavigationBarItem = BottomNavigationBarItem();
bottomNavigationBarItem.label;

References

Design document:

API documentation:

Relevant PRs:


packageRoot in dart:core, dart:isolate, and package:platform

#

The following APIs have been removed:

These APIs were marked deprecated in Dart 2.0, and did not work correctly in any Dart 2.x release.

Migration guide

These packageRoot APIs have been replaced by a new set of packageConfig APIs, which you should migrate to.

If you are using the package:platform package, note that regardless of whether you are using the packageRoot API or not, older versions of that package are not compatible with Dart 2.16 and later, as they depend on the now removed packageRoot API. You may see an error like this when attempting to run your app:

../../.pub-cache/hosted/pub.dartlang.org/platform-3.0.0/
  lib/src/interface/local_platform.dart:46:19:
  Error: Member not found: 'packageRoot'.
      io.Platform.packageRoot; // ignore: deprecated_member_use
                  ^^^^^^^^^^^

To resolve that, upgrade to version 3.1.0 or later of package:platform by upgrading the constraint in your pubspec.yaml file:

yaml
dependencies:
  platform: ^3.1.0

References

Relevant PRs:

  • Removed from the Dart libraries in #47769
  • Removed from package:platform in PR #38
  • Updated Flutter to use package:platform 3.1.0 in PR #94603

Timeline

#