破坏性改动 (Breaking changes) 及迁移指南
正如 破坏性改动策略 中描述的,我们会不定期地发布关于破坏性改动的迁移指南。
你可以加入 Flutter announce 和 Dart announce,以获得关于未来破坏性改动的通知。
当你在升级 Flutter 后遇到 Dart 错误时,可以考虑使用 dart fix 命令自动迁移你的代码。并非所有的破坏性改动都支持这种方式,但很多都是支持的。
为了避免被未来的 Flutter 版本破坏,可以考虑将你的测试提交到我们的 测试注册表。
所有版本的破坏性改动
#以下是可用的迁移指南,它们按发行版本分类并按字母顺序排列:
Not yet released to stable
#-
FontWeightalso controls the weight attribute of variable fonts - UISceneDelegate adoption
-
$FLUTTER_ROOT/versionreplaced by$FLUTTER_ROOT/bin/cache/flutter.version.json -
Stop generating
AssetManifest.json -
Deprecate
TextField.canRequestFocus
Released in Flutter 3.38
#-
CupertinoDynamicColorwide gamut support -
Deprecate
OverlayPortal.targetsRootOverlay -
Deprecate
SemanticsProperties.focusableandSemanticsConfiguration.isFocusable - SnackBar with action no longer auto-dismisses
-
The default page transition on Android is now
PredictiveBackPageTransitionBuilder
Released in Flutter 3.35
#- Component theme normalization updates
-
Deprecate
DropdownButtonFormFieldvalueparameter in favor ofinitialValue - Deprecate app bar color
- Redesigned the
Radiowidget - Removed semantics elevation and thickness
-
The
Formwidget no longer supports being a sliver -
Flutter now sets default
abiFiltersin Android builds - Merged threads on macOS and Windows
-
The
Visibilitywidget is no longer focusable by default whenmaintainStateis enabled
Released in Flutter 3.32
#-
Deprecate
SystemContextMenuController.show -
Deprecate
ExpansionTileControllerin favor ofExpansibleController -
Deprecate
RouteTransitionRecord.markForRemovein favor ofRouteTransitionRecord.markForComplete -
Deprecate
ThemeData.indicatorColorin favor ofTabBarThemeData.indicatorColor - Material Theme System Updates
-
.flutter-plugins-dependenciesreplaces.flutter-plugins - Localized messages are generated into source, not a synthetic package
-
Changing the default
goldenFileComparatorforintegration_tests -
Deprecate
InputDecoration.maintainHintHeightin favor ofInputDecoration.maintainHintSize - Underdamped spring formula changed
Released in Flutter 3.29
#- Removal of v1 Android embedding Java APIs
-
Deprecate
WebGoldenComparator -
Deprecate
ThemeData.dialogBackgroundColorin favor ofDialogThemeData.backgroundColor -
ImageFilter.blurdefault tile mode automatic selection -
Updated Material 3
Slider - Updated Material 3 progress indicators
Released in Flutter 3.27
#Colorwide gamut support- Component theme normalization
- Deep links flag change
- Material 3 Tokens Update in Flutter
-
Remove invalid parameters for
InputDecoration.collapsed - Set default for SystemUiMode to Edge-to-Edge
Released in Flutter 3.24
#- Navigator's page APIs breaking change
- Generic types in
PopScope -
Deprecate
ButtonBarin favor ofOverflowBar -
New APIs for Android plugins that render to a
Surface
Released in Flutter 3.22
#- Deprecated API removed after v3.19
-
Rename
MaterialStatetoWidgetState -
Introduce new
ColorSchemeroles - Dropping support for Android KitKat
-
Nullable
PageView.controller -
Rename
MemoryAllocationstoFlutterMemoryAllocations
Released in Flutter 3.19
#- Deprecated API removed after v3.16
- Migrate RawKeyEvent/RawKeyboard system to KeyEvent/HardwareKeyboard system
- Deprecate imperative apply of Flutter's Gradle plugins
- Default multitouch scrolling
- Accessibility traversal order of tooltip changed
Released in Flutter 3.16
#- Migrating to Material 3
- Migrate ShortcutActivator and ShortcutManager to KeyEvent system
-
The
ThemeData.useMaterial3property is now set to true by default - Deprecated API removed after v3.13
-
Customize tabs alignment using the new
TabBar.tabAlignmentproperty -
Deprecate
textScaleFactorin favor ofTextScaler - Android 14 nonlinear font scaling enabled
-
Deprecate
describeEnumand updateEnumPropertyto be type strict - Deprecated just-in-time navigation pop APIs for Android Predictive Back
-
Deprecated
Paint.enableDithering - Updated default text styles for menus
- Windows: External windows should notify Flutter engine of lifecycle changes
- Windows build path changed to add the target architecture
Released in Flutter 3.13
#-
Added missing
dispose()for some disposable objects in Flutter - Deprecated API removed after v3.10
- Added AppLifecycleState.hidden enum value
- Moved ReorderableListView's localized strings from material to widgets localizations
-
Removed
ignoringSemanticsproperties -
Deprecated
RouteInformation.locationand its related APIs - Updated EditableText scroll into view behavior
- Migrate a Windows project to ensure the window is shown
-
Updated
Checkbox.fillColorbehavior
Released in Flutter 3.10
#- Dart 3 changes in Flutter v3.10 and later
- Deprecated API removed after v3.7
- Insert content text input client
- Deprecated the window singleton
- Resolve the Android Java Gradle error
-
Require one data variant for
ClipboardDataconstructor - "Zone mismatch" message
Released in Flutter 3.7
#- Deprecated API removed after v3.3
- Replaced parameters for customizing context menus with a generic widget builder
- iOS FlutterViewController splashScreenView made nullable
-
Migrate
ofto non-nullable return values, and addmaybeOf - Removed RouteSettings.copyWith
- ThemeData's toggleableActiveColor property has been deprecated
- Migrate a Windows project to support dark title bars
Released in Flutter 3.3
#- Adding ImageProvider.loadBuffer
- Default PrimaryScrollController on Desktop
- Trackpad gestures can trigger GestureRecognizer
- Migrate a Windows project to set version information
Released in Flutter 3
#- Deprecated API removed after v2.10
- Migrate useDeleteButtonTooltip to deleteButtonTooltipMessage of Chips
- Page transitions replaced by ZoomPageTransitionsBuilder
Released in Flutter 2.10
#- Deprecated API removed after v2.5
- Raw images on Web uses correct origin and colors
- Required Kotlin version
- Scribble Text Input Client
Released in Flutter 2.5
#- Default drag scrolling devices
- Deprecated API removed after v2.2
- Change the enterText method to move the caret to the end of the input text
- GestureRecognizer cleanup
- Introducing package:flutter_lints
- Replace AnimationSheetBuilder.display with collate
- ThemeData's accent properties have been deprecated
- Transition of platform channel test interfaces to flutter_test package
- Using HTML slots to render platform views in the web
- Migrate a Windows project to the idiomatic run loop
Reverted change in 2.2
#The following breaking change was reverted in release 2.2:
-
Network Policy on iOS and Android
-
Introduced in version: 2.0.0
Reverted in version: 2.2.0
Released in Flutter 2.2
#Released in Flutter 2
#- Added BuildContext parameter to TextEditingController.buildTextSpan
- Android ActivityControlSurface attachToActivity signature change
- Android FlutterMain.setIsRunningInRobolectricTest testing API removed
- Clip behavior
- Deprecated API removed after v1.22
- Dry layout support for RenderBox
- Eliminating nullOk Parameters
- Material Chip button semantics
- SnackBars managed by the ScaffoldMessenger
- TextSelectionTheme migration
- Transition of platform channel test interfaces to flutter_test package
- Use maxLengthEnforcement instead of maxLengthEnforced
Released in Flutter 1.22
#- Android v1 embedding app and plugin creation deprecation
- Cupertino icons 1.0.0
- The new Form, FormField auto-validation API
Released in Flutter 1.20
#- Actions API revision
- Adding TextInputClient.currentAutofillScope property
- New Buttons and Button Themes
- Dialogs' Default BorderRadius
- More Strict Assertions in the Navigator and the Hero Controller Scope
- The Route Transition record and Transition delegate updates
- The RenderEditable needs to be laid out before hit testing
- Reversing the dependency between the scheduler and services layer
- Semantics Order of the Overlay Entries in Modal Routes
- showAutocorrectionPromptRect method added to TextInputClient
- TestWidgetsFlutterBinding.clock
- TextField requires MaterialLocalizations
Released in Flutter 1.17
#- Adding 'linux' and 'windows' to TargetPlatform enum
- Annotations return local position relative to object
- Container color optimization
- CupertinoTabBar requires Localizations parent
- Generic type of ParentDataWidget changed to ParentData
- ImageCache and ImageProvider changes
- ImageCache large images
- MouseTracker moved to rendering
- MouseTracker no longer attaches annotations
- Nullable CupertinoTheme.brightness
- Rebuild optimization for OverlayEntries and Routes
- Scrollable AlertDialog
- TestTextInput state reset
- TextInputClient currentTextEditingValue
- The forgetChild() method must call super
- The Route and Navigator refactoring
- FloatingActionButton and ThemeData's accent properties
除非另有说明,本文档之所提及适用于 Flutter 3.38.1 版本。本页面最后更新时间:2025-11-12。查看文档源码 或者 为本页面内容提出建议。