Skip to main content

Deprecated API removed after v2.10

Summary

#

In accordance with Flutter's Deprecation Policy, deprecated APIs that reached end of life after the 2.10 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

maxLengthEnforced was deprecated in v1.25.

Use maxLengthEnforcement instead. Where maxLengthEnforced was true, replace with MaxLengthEnforcement.enforce. Where maxLengthEnforced was false, replace with MaxLengthEnforcement.none. This change allows more behaviors to be specified beyond the original binary choice, adding MaxLengthEnforcement.truncateAfterCompositionEnds as an additional option.

The following classes all have the same change of API:

  • TextField
  • TextFormField
  • CupertinoTextField

Migration guide

In-depth migration guide available

Code before migration:

dart
const TextField textField = TextField(maxLengthEnforced: true);
const TextField textField = TextField(maxLengthEnforced: false);
final lengthEnforced = textField.maxLengthEnforced;

const TextFormField textFormField = TextFormField(maxLengthEnforced: true);
const TextFormField textFormField = TextFormField(maxLengthEnforced: false);
final lengthEnforced = textFormField.maxLengthEnforced;

const CupertinoTextField cupertinoTextField = CupertinoTextField(maxLengthEnforced: true);
const CupertinoTextField cupertinoTextField = CupertinoTextField(maxLengthEnforced: false);
final lengthEnforced = cupertinoTextField.maxLengthEnforced;

Code after migration:

dart
const TextField textField = TextField(maxLengthEnforcement: MaxLengthEnforcement.enforce);
const TextField textField = TextField(maxLengthEnforcement: MaxLengthEnforcement.none);
final lengthEnforced = textField.maxLengthEnforcement;

const TextFormField textFormField = TextFormField(maxLengthEnforcement: MaxLengthEnforcement.enforce);
const TextFormField textFormField = TextFormField(maxLengthEnforcement: MaxLengthEnforcement.none);
final lengthEnforced = textFormField.maxLengthEnforcement;

const CupertinoTextField cupertinoTextField = CupertinoTextField(maxLengthEnforcement: MaxLengthEnforcement.enforce);
const CupertinoTextField cupertinoTextField = CupertinoTextField(maxLengthEnforcement: MaxLengthEnforcement.none);
final lengthEnforced = cupertinoTextField.maxLengthEnforcement;

References

API documentation:

Relevant issues:

Relevant PRs:


VelocityTracker constructor

#

Supported by Flutter Fix: yes

The default constructor for VelocityTrackerwas deprecated in v1.22.

The VelocityTracker.withKind() should be used instead. This allows for a PointerDeviceKind to be specified for the tracker. The previous default for VelocityTracker.kind was PointerDeviceKind.touch.

Migration guide

Code before migration:

dart
final VelocityTracker tracker = VelocityTracker();

Code after migration:

dart
final VelocityTracker tracker = VelocityTracker.withKind(PointerDeviceKind.touch);

References

API documentation:

Relevant PRs:


DayPicker & MonthPicker

#

Supported by Flutter Fix: no

The DayPicker and MonthPicker widgets were first deprecated in v1.15, and then extended in v1.26.

They have been replaced by one comprehensive widget, CalendarDatePicker.

These widgets were displayed using the showDatePicker method. This method was migrated to present the new CalendarDatePicker before this release, and so their final removal should not necessitate further action.

References

Design document:

API documentation:

Relevant issues:

Relevant PRs:


FlatButton, RaisedButton, & OutlineButton

#

Supported by Flutter Fix: no

The FlatButton, RaisedButton, and OutlineButton widgets were first deprecated in v1.20, and then extended in v1.26.

They are replaced by new buttons, TextButton, ElevatedButton, and OutlinedButton. These new widgets also use new associated themes, rather than the generic ButtonTheme.

Old WidgetOld ThemeNew WidgetNew Theme
FlatButtonButtonThemeTextButtonTextButtonTheme
RaisedButtonButtonThemeElevatedButtonElevatedButtonTheme
OutlineButtonButtonThemeOutlinedButtonOutlinedButtonTheme

Migration guide

In-depth migration guide available for detailed styling

Code before migration:

dart
FlatButton(
  onPressed: onPressed,
  child: Text('Button'),
  // ...
);

RaisedButton(
  onPressed: onPressed,
  child: Text('Button'),
  // ...
);

OutlineButton(
  onPressed: onPressed,
  child: Text('Button'),
  // ...
);

Code after migration:

dart
TextButton(
  onPressed: onPressed,
  child: Text('Button'),
  // ...
);

ElevatedButton(
  onPressed: onPressed,
  child: Text('Button'),
  // ...
);

OutlinedButton(
  onPressed: onPressed,
  child: Text('Button'),
  // ...
);

References

Design document:

API documentation:

Relevant PRs:


Scaffold SnackBar methods

#

Supported by Flutter Fix: no

The following Scaffold SnackBar methods were deprecated in v1.23.

  • showSnackBar
  • removeCurrentSnackBar
  • hideCurrentSnackBar

The same named methods of the ScaffoldMessenger should be used instead. A default ScaffoldMessenger is already created in every MaterialApp.

Migration guide

In-depth migration guide available

Code before migration:

dart
Scaffold.of(context).showSnackBar(mySnackBar);
Scaffold.of(context).removeCurrentSnackBar(mySnackBar);
Scaffold.of(context).hideCurrentSnackBar(mySnackBar);

Code after migration:

dart
ScaffoldMessenger.of(context).showSnackBar(mySnackBar);
ScaffoldMessenger.of(context).removeCurrentSnackBar(mySnackBar);
ScaffoldMessenger.of(context).hideCurrentSnackBar(mySnackBar);

References

Design document:

Video content:

API documentation:

Relevant issues:

Relevant PRs:


RectangularSliderTrackShape.disabledThumbGapWidth

#

Supported by Flutter Fix: yes

The RectangularSliderTrackShape.disabledThumbGapWidth was first deprecated in v1.5, and then extended in v1.26.

This was no longer used by the framework, as the animation of the slider thumb no longer occurs when disabled.

Migration guide

Code before migration:

dart
RectangularSliderTrackShape(disabledThumbGapWidth: 2.0);

Code after migration:

dart
RectangularSliderTrackShape();

References

API documentation:

Relevant PRs:


Text selection of ThemeData to TextSelectionThemeData

#

Supported by Flutter Fix: yes

The following ThemeData members were first deprecated in v1.23, and extended in v1.26.

  • useTextSelectionTheme
  • textSelectionColor
  • cursorColor
  • textSelectionHandleColor

These should be replaced by a more comprehensive TextSelectionThemeData, which is now specified in ThemeData itself.

The useTextSelectionTheme flag served as a temporary migration flag to distinguish the two APIs, it can be removed now.

Migration guide

In-depth migration guide available

Code before migration:

dart
ThemeData(
  useTextSelectionTheme: false,
  textSelectionColor: Colors.blue,
  cursorColor: Colors.green,
  textSelectionHandleColor: Colors.red,
);

Code after migration:

dart
ThemeData(
  textSelectionTheme: TextSelectionThemeData(
    selectionColor: Colors.blue,
    cursorColor: Colors.green,
    selectionHandleColor: Colors.red,
  ),
);

References

Design document:

API documentation:

Relevant issues:

Relevant PRs:


RenderEditable.onSelectionChanged to TextSelectionDelegate.textEditingValue

#

Supported by Flutter Fix: no

RenderEditable.onSelectionChanged and TextSelectionDelegate.textEditingValue were deprecated in v1.26.

Instead of calling one or both of these methods, call TextSelectionDelegate.userUpdateTextEditingValue. This fixed a bug where the TextInputFormatter would receive the wrong selection value.

Migration guide

Code before migration:

dart
renderEditable.onSelectionChanged(selection, renderObject, cause);
textSelectionDelegate.textEditingValue = value;

Code after migration:

dart
textSelectionDelegate.userUpdateTextEditingValue(value, cause);

References

API documentation:

Relevant issues:

Relevant PRs:


Stack.overflow

#

Supported by Flutter Fix: yes

Stack.overflow, as well as the Overflow enum were deprecated in v1.22.

The replacement is Stack.clipBehavior, a change made as part of unifying clip behaviors and semantics across the framework. Where Overflow.visible was used, use Clip.none. Where Overflow.clip was used, use Clip.hardEdge.

Migration guide

In-depth migration guide available

Code before migration:

dart
const Stack stack = Stack(overflow: Overflow.visible);
const Stack stack = Stack(overflow: Overflow.clip);

Code after migration:

dart
const Stack stack = Stack(clipBehavior: Clip.none);
const Stack stack = Stack(clipBehavior: Clip.hardEdge);

References

API documentation:

Relevant issues:

Relevant PRs:


UpdateLiveRegionEvent

#

Supported by Flutter Fix: no

The SemanticsEvent UpdateLiveRegionEvent, was first deprecated in v1.12, and then extended in v1.26.

This was never implemented by the framework, and any references should be removed.

References

API documentation:

Relevant PRs:


RenderObjectElement methods

#

Supported by Flutter Fix: yes

The following RenderObjectElement methods were deprecated in v1.21.

  • insertChildRenderObject
  • moveChildRenderObject
  • removeChildRenderObject

These methods are replaced, respectively, by:

  • insertRenderObjectChild
  • moveRenderObjectChild
  • removeRenderObjectChild

These changes were made as a soft breaking deprecation in order to change the function signature.

Migration guide

Code before migration:

dart
element.insertChildRenderObject(child, slot);
element.moveChildRenderObject(child, slot);
element.removeChildRenderObject(child);

Code after migration:

dart
element.insertRenderObjectChild(child, slot);
element.moveRenderObjectChild(child, oldSlot, newSlot);
element.removeRenderObjectChild(child, slot);

References

API documentation:

Relevant issues:

Relevant PRs:


Timeline

#

In stable release: 3.0.0