id
stringlengths
14
17
text
stringlengths
23
1.11k
source
stringlengths
35
114
e8c753927e1e-13
'Looks like a RaisedButton' ), The OutlineButton style for OutlinedButton is a little more complicated because the outline’s color changes to the primary color when the button is pressed. The outline’s appearance is defined by a BorderSide and you’ll use a MaterialStateProperty to define the pressed outline color: final ButtonStyle outlineButtonStyle OutlinedButton styleFrom primary: Colors black87 minimumSize: Size 88 36 ), padding: EdgeInsets symmetric horizontal: 16 ), shape: const RoundedRectangleBorder
https://docs.flutter.dev/release/breaking-changes/buttons/index.html
e8c753927e1e-14
shape: const RoundedRectangleBorder borderRadius: BorderRadius all Radius circular )), ), copyWith side: MaterialStateProperty resolveWith BorderSide >( Set MaterialState states if states contains MaterialState pressed )) return BorderSide color: Theme of context colorScheme primary width: ); return null
https://docs.flutter.dev/release/breaking-changes/buttons/index.html
e8c753927e1e-15
); return null // Defer to the widget's default. }, ), ); OutlinedButton style: outlineButtonStyle onPressed: () }, child: Text 'Looks like an OutlineButton' ), To restore the default appearance for buttons throughout an application, you can configure the new button themes in the application’s theme: MaterialApp theme: ThemeData from colorScheme: ColorScheme light ()) copyWith textButtonTheme: TextButtonThemeData style:
https://docs.flutter.dev/release/breaking-changes/buttons/index.html
e8c753927e1e-16
TextButtonThemeData style: flatButtonStyle ), elevatedButtonTheme: ElevatedButtonThemeData style: raisedButtonStyle ), outlinedButtonTheme: OutlinedButtonThemeData style: outlineButtonStyle ), ), To restore the default appearance for buttons in part of an application you can wrap a widget subtree with TextButtonTheme, ElevatedButtonTheme, or OutlinedButtonTheme. For example: TextButtonTheme data: TextButtonThemeData style: flatButtonStyle ), child: myWidgetSubtree Migrating buttons with custom colors
https://docs.flutter.dev/release/breaking-changes/buttons/index.html
e8c753927e1e-17
myWidgetSubtree Migrating buttons with custom colors The following sections cover use of the following FlatButton, RaisedButton, and OutlineButton color parameters: textColor disabledTextColor color disabledColor focusColor hoverColor highlightColor splashColor The new button classes do not support a separate highlight color because it’s no longer part of the Material Design. Migrating buttons with custom foreground and background colors Two common customizations for the original button classes are a custom foreground color for FlatButton, or custom foreground and background colors for RaisedButton. Producing the same result with the new button classes is simple: FlatButton textColor: Colors red // foreground onPressed:
https://docs.flutter.dev/release/breaking-changes/buttons/index.html
e8c753927e1e-18
red // foreground onPressed: () }, child: Text 'FlatButton with custom foreground/background' ), TextButton style: TextButton styleFrom primary: Colors red // foreground ), onPressed: () }, child: Text 'TextButton with custom foreground' ), In this case the TextButton’s foreground (text/icon) color as well as its hovered/focused/pressed overlay colors will be based on Colors.red. By default, the TextButton’s background fill color is transparent.
https://docs.flutter.dev/release/breaking-changes/buttons/index.html
e8c753927e1e-19
Migrating a RaisedButton with custom foreground and background colors: RaisedButton color: Colors red // background textColor: Colors white // foreground onPressed: () }, child: Text 'RaisedButton with custom foreground/background' ), ElevatedButton style: ElevatedButton styleFrom primary: Colors red // background onPrimary: Colors white // foreground ), onPressed: () },
https://docs.flutter.dev/release/breaking-changes/buttons/index.html
e8c753927e1e-20
onPressed: () }, child: Text 'ElevatedButton with custom foreground/background' ), In this case the button’s use of the color scheme’s primary color is reversed relative to the TextButton: primary is button’s background fill color and onPrimary is the foreground (text/icon) color. Migrating buttons with custom overlay colors FlatButton focusColor: Colors red hoverColor: Colors green splashColor: Colors blue onPressed: () }, child: Text 'FlatButton with custom overlay colors' ), TextButton
https://docs.flutter.dev/release/breaking-changes/buttons/index.html
e8c753927e1e-21
), TextButton style: ButtonStyle overlayColor: MaterialStateProperty resolveWith Color >( Set MaterialState states if states contains MaterialState focused )) return Colors red if states contains MaterialState hovered )) return Colors green if states contains MaterialState pressed )) return Colors blue
https://docs.flutter.dev/release/breaking-changes/buttons/index.html
e8c753927e1e-22
return Colors blue return null // Defer to the widget's default. }), ), onPressed: () }, child: Text 'TextButton with custom overlay colors' ), The new version is more flexible although less compact. In the original version, the the precedence of the different states is implicit (and undocumented) and fixed, in the new version, it’s explicit. For an app that specified these colors frequently, the easiest migration path would be to define one or more ButtonStyles that match the example above - and just use the style parameter - or to define a stateless wrapper widget that encapsulated the three color parameters. Migrating buttons with custom disabled colors
https://docs.flutter.dev/release/breaking-changes/buttons/index.html
e8c753927e1e-23
Migrating buttons with custom disabled colors By default, all of the buttons use the color scheme’s onSurface color, with opacity 0.38 for the disabled foreground color. Only ElevatedButton has a non-transparent background color and its default value is the onSurface color with opacity 0.12. So in many cases one can just use the styleFrom method to override the disabled colors: RaisedButton disabledColor: Colors red withOpacity 0.12 ), disabledTextColor: Colors red withOpacity 0.38 ), onPressed: null child: Text 'RaisedButton with custom disabled colors' ),
https://docs.flutter.dev/release/breaking-changes/buttons/index.html
e8c753927e1e-24
'RaisedButton with custom disabled colors' ), ), ElevatedButton style: ElevatedButton styleFrom onSurface: Colors red ), onPressed: null child: Text 'ElevatedButton with custom disabled colors' ), For complete control over the disabled colors, one must define the ElevatedButton’s style explicitly, in terms of MaterialStateProperties: RaisedButton disabledColor: Colors red disabledTextColor: Colors blue onPressed: null child: Text
https://docs.flutter.dev/release/breaking-changes/buttons/index.html
e8c753927e1e-25
null child: Text 'RaisedButton with custom disabled colors' ), ElevatedButton style: ButtonStyle backgroundColor: MaterialStateProperty resolveWith Color >( Set MaterialState states if states contains MaterialState disabled )) return Colors red return null // Defer to the widget's default. }), foregroundColor: MaterialStateProperty resolveWith Color >( Set
https://docs.flutter.dev/release/breaking-changes/buttons/index.html
e8c753927e1e-26
Color >( Set MaterialState states if states contains MaterialState disabled )) return Colors blue return null // Defer to the widget's default. }), ), onPressed: null child: Text 'ElevatedButton with custom disabled colors' ), As with the previous case, there are obvious ways to make the new version more compact in an app where this migration comes up often. Migrating buttons with custom elevations
https://docs.flutter.dev/release/breaking-changes/buttons/index.html
e8c753927e1e-27
Migrating buttons with custom elevations This is also a relatively rare customization. Typically, only ElevatedButtons (originally called RaisedButtons) include elevation changes. For elevations that are proportional to a baseline elevation (per the Material Design specification), one can override all of them quite simply. By default a disabled button’s elevation is 0, and the remaining states are defined relative to a baseline of 2: disabled: hovered or focused: baseline pressed: baseline So to migrate a RaisedButton for which all elevations have been defined: RaisedButton elevation: focusElevation: hoverElevation: highlightElevation: disabledElevation: onPressed:
https://docs.flutter.dev/release/breaking-changes/buttons/index.html
e8c753927e1e-28
disabledElevation: onPressed: () }, child: Text 'RaisedButton with custom elevations' ), ElevatedButton style: ElevatedButton styleFrom elevation: ), onPressed: () }, child: Text 'ElevatedButton with custom elevations' ), To arbitrarily override just one elevation, like the pressed elevation: RaisedButton highlightElevation: 16 onPressed: () }, child: Text
https://docs.flutter.dev/release/breaking-changes/buttons/index.html
e8c753927e1e-29
}, child: Text 'RaisedButton with a custom elevation' ), ElevatedButton style: ButtonStyle elevation: MaterialStateProperty resolveWith double >( Set MaterialState states if states contains MaterialState pressed )) return 16 return null }), ), onPressed: () }, child: Text 'ElevatedButton with a custom elevation' ),
https://docs.flutter.dev/release/breaking-changes/buttons/index.html
e8c753927e1e-30
'ElevatedButton with a custom elevation' ), Migrating buttons with custom shapes and borders The original FlatButton, RaisedButton, and OutlineButton classes all provide a shape parameter which defines both the button’s shape and the appearance of its outline. The corresponding new classes and their themes support specifying the button’s shape and its border separately, with OutlinedBorder shape and BorderSide side parameters. In this example the original OutlineButton version specifies the same color for border in its highlighted (pressed) state as for other states. OutlineButton shape: StadiumBorder (), highlightedBorderColor: Colors red borderSide: BorderSide width: color: Colors red ),
https://docs.flutter.dev/release/breaking-changes/buttons/index.html
e8c753927e1e-31
Colors red ), onPressed: () }, child: Text 'OutlineButton with custom shape and border' ), OutlinedButton style: OutlinedButton styleFrom shape: StadiumBorder (), side: BorderSide width: color: Colors red ), ), onPressed: () }, child: Text 'OutlinedButton with custom shape and border' ),
https://docs.flutter.dev/release/breaking-changes/buttons/index.html
e8c753927e1e-32
'OutlinedButton with custom shape and border' ), Most of the new OutlinedButton widget’s style parameters, including its shape and border, can be specified with MaterialStateProperty values, which is to say that they can have different values depending on the button’s state. To specify a different border color when the button is pressed, do the following: OutlineButton shape: StadiumBorder (), highlightedBorderColor: Colors blue borderSide: BorderSide width: color: Colors red ), onPressed: () }, child: Text 'OutlineButton with custom shape and border' ), OutlinedButton
https://docs.flutter.dev/release/breaking-changes/buttons/index.html
e8c753927e1e-33
), OutlinedButton style: ButtonStyle shape: MaterialStateProperty all OutlinedBorder >( StadiumBorder ()), side: MaterialStateProperty resolveWith BorderSide >( Set MaterialState states final Color color states contains MaterialState pressed Colors blue Colors red return BorderSide color: color width: ); ), ),
https://docs.flutter.dev/release/breaking-changes/buttons/index.html
e8c753927e1e-34
); ), ), onPressed: () }, child: Text 'OutlinedButton with custom shape and border' ), Timeline Landed in version: 1.20.0-0.0.pre In stable release: 2.0 References API documentation: ButtonStyle ButtonStyleButton ElevatedButton ElevatedButtonTheme ElevatedButtonThemeData OutlinedButton OutlinedButtonTheme OutlinedButtonThemeData TextButton TextButtonTheme TextButtonThemeData Relevant PRs: PR 59702: New Button Universe
https://docs.flutter.dev/release/breaking-changes/buttons/index.html
e8c753927e1e-35
PR 59702: New Button Universe PR 73352: Deprecated obsolete Material classes: FlatButton, RaisedButton, OutlineButton
https://docs.flutter.dev/release/breaking-changes/buttons/index.html
0f8c63327b4e-0
Migrate useDeleteButtonTooltip to deleteButtonTooltipMessage of Chips Summary Context Description of change Migration guide Timeline References Summary Using useDeleteButtonTooltip of any chip that has a delete button gives a deprecation warning, or no longer exists when referenced. This includes the Chip, InputChip, and RawChip widgets. Context The useDeleteButtonTooltip of Chip, InputChip, and RawChip widgets is deprecated in favor of deleteButtonTooltipMessage, as the latter can be used to disable the tooltip of the chip’s delete button. Description of change The deleteButtonTooltipMessage property provides a message to the tooltip on the delete button of the chip widgets. Subsequently, a change was made such that providing an empty string to this property disables the tooltip.
https://docs.flutter.dev/release/breaking-changes/chip-usedeletebuttontooltip-migration/index.html
0f8c63327b4e-1
To avoid redundancy of the API, this change deprecated useDeleteButtonTooltip, which was introduced for this exact functionality. A Flutter fix is available to help you migrate existing code from useDeleteButtonTooltip to deleteButtonTooltipMessage, if you explicity disabled the tooltip. Migration guide By default, the tooltip of the delete button is always enabled. To explicitly disable the tooltip, provide an empty string to the deleteButtonTooltipMessage property. The following code snippets show the migration changes, which are applicable for Chip, InputChip, and RawChip widgets: Code before migration: Chip label: const Text 'Disabled delete button tooltip' ), onDeleted: _handleDeleteChip useDeleteButtonTooltip: false ); RawChip
https://docs.flutter.dev/release/breaking-changes/chip-usedeletebuttontooltip-migration/index.html
0f8c63327b4e-2
false ); RawChip label: const Text 'Enabled delete button tooltip' ), onDeleted: _handleDeleteChip useDeleteButtonTooltip: true ); Code after migration: Chip label: const Text 'Disabled delete button tooltip' ), onDeleted: _handleDeleteChip deleteButtonTooltipMessage: '' ); RawChip label: const Text 'Enabled delete button tooltip' ), onDeleted:
https://docs.flutter.dev/release/breaking-changes/chip-usedeletebuttontooltip-migration/index.html
0f8c63327b4e-3
), onDeleted: _handleDeleteChip ); Timeline Landed in version: 2.11.0-0.1.pre In stable release: 3.0.0 References API documentation: Chip InputChip RawChip Relevant PRs: Deprecate useDeleteButtonTooltip for Chips
https://docs.flutter.dev/release/breaking-changes/chip-usedeletebuttontooltip-migration/index.html
1e8e91fbb2f4-0
Clip Behavior Summary Context Migration guide Timeline References Summary Flutter now defaults to not clip except for a few specialized widgets (such as ClipRect). To override the no-clip default, explicitly set clipBehavior in widgets constructions. Context Flutter used to be slow because of clips. For example, the Flutter gallery app benchmark had an average frame rasterization time of about 35ms in May 2018, where the budget for smooth 60fps rendering is 16ms. By removing unnecessary clips and their related operations, we saw an almost 2x speedup from 35ms/frame to 17.5ms/frame. Issue 18057. Such behaviors were universal to material apps through widgets like
https://docs.flutter.dev/release/breaking-changes/clip-behavior/index.html
1e8e91fbb2f4-1
A saveLayer call is especially expensive in older devices because it creates an offscreen render target, and a render target switch can sometimes cost about 1ms. Even without saveLayer call, a clip is still expensive because it applies to all subsequent draws until it’s restored. Therefore a single clip may slow down the performance on hundreds of draw operations. In addition to performance issues, Flutter also suffered from some correctness issues as the clip was not managed and implemented in a single place. In several places, saveLayer was inserted in the wrong place and it therefore only increased the performance cost without fixing any bleeding edge artifacts. So, we unified the clipBehavior control and its implementation in this breaking change. The default clipBehavior is Clip.none for most widgets to save performance, except the following: ClipPath defaults to Clip.antiAlias ClipRRect defaults to Clip.antiAlias ClipRect defaults to Clip.hardEdge
https://docs.flutter.dev/release/breaking-changes/clip-behavior/index.html
1e8e91fbb2f4-2
ClipRect defaults to Clip.hardEdge Stack defaults to Clip.hardEdge EditableText defaults to Clip.hardEdge ListWheelScrollView defaults to Clip.hardEdge SingleChildScrollView defaults to Clip.hardEdge NestedScrollView defaults to Clip.hardEdge ShrinkWrappingViewport defaults to Clip.hardEdge Migration guide You have 4 choices for migrating your code: Leave your code as is if your content does not need to be clipped (for example, none of the widgets’ children expand outside their parent’s boundary). This will likely have a positive impact on your app’s overall performance.
https://docs.flutter.dev/release/breaking-changes/clip-behavior/index.html
1e8e91fbb2f4-3
Add clipBehavior: Clip.hardEdge if you need clipping, and clipping without anti-alias is good enough for your (and your clients’) eyes. This is the common case when you clip rectangles or shapes with very small curved areas (such as the corners of rounded rectangles). Add clipBehavior: Clip.antiAlias if you need anti-aliased clipping. This gives you smoother edges at a slightly higher cost. This is the common case when dealing with circles and arcs. Add clip.antiAliasWithSaveLayer if you want the exact same behavior as before (May 2018). Be aware that it’s very costly in performance. This is likely to be only rarely needed. One case where you might need this is if you have an image overlaid on a very different background color. In these cases, consider whether you can avoid overlapping multiple colors in one spot (for example, by having the background color only present where the image is absent).
https://docs.flutter.dev/release/breaking-changes/clip-behavior/index.html
1e8e91fbb2f4-4
For the Stack widget specifically, if you previously used overflow: Overflow.visible, replace it with clipBehavior: Clip.none. Code before migration: await tester pumpWidget Directionality textDirection: TextDirection ltr child: Center child: Stack overflow: Overflow visible children: const Widget >[ SizedBox width: 100.0 height: 100.0 ), ], ), ), ), ); Code after migration:
https://docs.flutter.dev/release/breaking-changes/clip-behavior/index.html
1e8e91fbb2f4-5
), ); Code after migration: await tester pumpWidget Directionality textDirection: TextDirection ltr child: Center child: Stack clipBehavior: Clip none children: const Widget >[ SizedBox width: 100.0 height: 100.0 ), ], ), ), ), ); Timeline Landed in version: various In stable release: 2.0.0
https://docs.flutter.dev/release/breaking-changes/clip-behavior/index.html
1e8e91fbb2f4-6
Landed in version: various In stable release: 2.0.0 References API documentation: Clip Relevant issues: Issue 13736 Issue 18057 Issue 21830 Relevant PRs: PR 5420: Remove unnecessary saveLayer PR 18576: Add Clip enum to Material and related widgets PR 18616: Remove saveLayer after clip from dart PR 5647: Add ClipMode to ClipPath/ClipRRect and PhysicalShape layers PR 5670: Add anti-alias switch to canvas clip calls PR 5853: Rename clip mode to clip behavior PR 5868: Rename clip to clipBehavior in compositing.dart
https://docs.flutter.dev/release/breaking-changes/clip-behavior/index.html
1e8e91fbb2f4-7
PR 5868: Rename clip to clipBehavior in compositing.dart PR 5973: Call drawPaint instead of drawPath if there’s clip PR 5952: Call drawPath without clip if possible PR 20205: Set default clipBehavior to Clip.none and update tests PR 20538: Expose clipBehavior to more Material Buttons PR 20751: Add customBorder to InkWell so it can clip ShapeBorder PR 20752: Set the default clip to Clip.none again PR 21012: Add default-no-clip tests to more buttons PR 21703: Default clipBehavior of ClipRect to hardEdge PR 21826: Missing default hardEdge clip for ClipRectLayer
https://docs.flutter.dev/release/breaking-changes/clip-behavior/index.html
812fa3d5d903-0
Container with color optimization Summary Context Migration guide Timeline References Summary A new ColoredBox widget has been added to the framework, and the Container widget has been optimized to use it if a user specifies a color instead of a decoration. Context It is very common to use the Container widget as follows: return Container color: Colors red ); Previously, this code resulted in a widget hierarchy that used a BoxDecoration to actually paint the background color. The BoxDecoration widget covers many cases other than just painting a background color, and is not as efficient as the new ColoredBox widget, which only paints a background color. Migration guide
https://docs.flutter.dev/release/breaking-changes/container-color/index.html
812fa3d5d903-1
Migration guide Tests that assert on the color of a Container or that expected it to create a BoxDecoration need to be modified. Code before migration: testWidgets 'Container color' WidgetTester tester async await tester pumpWidget Container color: Colors red )); final Container container tester widgetList Container >() first expect container decoration color Colors red );
https://docs.flutter.dev/release/breaking-changes/container-color/index.html
812fa3d5d903-2
color Colors red ); // Or, a test may have specifically looked for the BoxDecoration, e.g.: expect find byType BoxDecoration ), findsOneWidget ); }); Code after migration: testWidgets 'Container color' WidgetTester tester async await tester pumpWidget Container color: Colors red )); final Container container tester widgetList Container >() first
https://docs.flutter.dev/release/breaking-changes/container-color/index.html
812fa3d5d903-3
Container >() first expect container color Colors red ); // If your test needed to work directly with the BoxDecoration, it should // instead look for the ColoredBox, e.g.: expect find byType BoxDecoration ), findsNothing ); expect find byType ColoredBox ), findsOneWidget ); }); Timeline Landed in version: 1.15.4 In stable release: 1.17 References API documentation: Container
https://docs.flutter.dev/release/breaking-changes/container-color/index.html
812fa3d5d903-4
References API documentation: Container ColoredBox BoxDecoration Relevant issues: Issue 9672 Issue 28753 Relevant PRs: Colored box and container optimization #50979
https://docs.flutter.dev/release/breaking-changes/container-color/index.html
47978d905c8b-0
A new way to customize context menus Summary Context Description of change Migration guide ToolbarOptions TextSelectionControls.canCut and other button booleans TextSelectionControls.handleCut and other button callbacks buildToolbar Timeline References Summary Context Previously, it was possible to disable buttons from the context menus using TextSelectionControls, but any customization beyond that required copying and editing hundreds of lines of custom classes in the framework. Now, all of this has been replaced by a simple builder function, contextMenuBuilder, which allows any Flutter widget to be used as a context menu. Description of change
https://docs.flutter.dev/release/breaking-changes/context-menus/index.html
47978d905c8b-1
Description of change Context menus are now built from the contextMenuBuilder parameter, which has been added to all text-editing and text-selection widgets. If one is not provided, then Flutter just sets it to a default that builds the correct context menu for the given platform. All of these default widgets are exposed to users for re-use. Customizing context menus now consists of using contextMenuBuilder to return whatever widget you want, possibly including reusing the built-in context menu widgets. Here’s an example that shows how to add a Send email button to the default context menus whenever an email address is selected. The full code can be found in the samples repository in email_button_page.dart on GitHub. TextField contextMenuBuilder: context editableTextState final TextEditingValue value editableTextState textEditingValue
https://docs.flutter.dev/release/breaking-changes/context-menus/index.html
47978d905c8b-2
value editableTextState textEditingValue final List ContextMenuButtonItem buttonItems editableTextState contextMenuButtonItems if isValidEmail value selection textInside value text ))) buttonItems insert ContextMenuButtonItem label: 'Send email' onPressed: () ContextMenuController removeAny (); Navigator of context push _showDialog context )); },
https://docs.flutter.dev/release/breaking-changes/context-menus/index.html
47978d905c8b-3
context )); }, )); return AdaptiveTextSelectionToolbar buttonItems anchors: editableTextState contextMenuAnchors buttonItems: buttonItems ); }, A large number of examples of different custom context menus are available in the samples repo on GitHub. All related deprecated features were flagged with the deprecation warning “Use contextMenuBuilder instead.” Migration guide
https://docs.flutter.dev/release/breaking-changes/context-menus/index.html
47978d905c8b-4
Migration guide In general, any previous changes to context menus that have been deprecated now require the use of the contextMenuBuilder parameter on the relevant text-editing or text-selection widget ( on TextField, for example). Return a built-in context menu widget like AdaptiveTextSelectionToolbar to use Flutter’s built-in context menus, or return your own widget for something totally custom. To transition to contextMenuBuilder, the following parameters and classes have been deprecated. ToolbarOptions This class was previously used to explicitly enable or disable certain buttons in a context menu. Before this change, you might have passed it into TextField or other widgets like this: // Deprecated. TextField toolbarOptions: ToolbarOptions copy: true ),
https://docs.flutter.dev/release/breaking-changes/context-menus/index.html
47978d905c8b-5
copy: true ), Now, you can achieve the same effect by adjusting the buttonItems passed into AdaptiveTextSelectionToolbar. For example, you could ensure that the Cut button never appears, but the other buttons do appear as usual: TextField contextMenuBuilder: context editableTextState final List ContextMenuButtonItem buttonItems editableTextState contextMenuButtonItems buttonItems removeWhere (( ContextMenuButtonItem buttonItem return buttonItem type == ContextMenuButtonType cut }); return AdaptiveTextSelectionToolbar
https://docs.flutter.dev/release/breaking-changes/context-menus/index.html
47978d905c8b-6
}); return AdaptiveTextSelectionToolbar buttonItems anchors: editableTextState contextMenuAnchors buttonItems: buttonItems ); }, Or, you could ensure that the Cut button appears exclusively and always: TextField contextMenuBuilder: context editableTextState return AdaptiveTextSelectionToolbar buttonItems anchors: editableTextState contextMenuAnchors buttonItems: ContextMenuButtonItem >[ ContextMenuButtonItem onPressed: () editableTextState cutSelection
https://docs.flutter.dev/release/breaking-changes/context-menus/index.html
47978d905c8b-7
() editableTextState cutSelection SelectionChangedCause toolbar ); }, type: ContextMenuButtonType cut ), ], ); }, TextSelectionControls.canCut and other button booleans These booleans previously had the same effect of enabling and disabling certain buttons as ToolbarOptions.cut, and so on had. Before this change, you might have been hiding and showing buttons by overriding TextSelectionControls and setting these booleans like this: // Deprecated. class _MyMaterialTextSelectionControls extends MaterialTextSelectionControls @override bool canCut () false
https://docs.flutter.dev/release/breaking-changes/context-menus/index.html
47978d905c8b-8
canCut () false See the previous section on ToolbarOptions for how to achieve a similar effect with contextMenuBuilder. TextSelectionControls.handleCut and other button callbacks These functions allowed the modification of the callback called when the buttons were pressed. Before this change, you might have been modifying context menu button callbacks by overriding these handler methods like this: // Deprecated. class _MyMaterialTextSelectionControls extends MaterialTextSelectionControls @override bool handleCut () // My custom cut implementation here. }, This is still possible using contextMenuBuilder, including calling out to the original buttons’ actions in the custom handler, using toolbar widgets like AdaptiveTextSelectionToolbar.buttonItems.
https://docs.flutter.dev/release/breaking-changes/context-menus/index.html
47978d905c8b-9
This example shows modifying the Copy button to show a dialog in addition to doing its usual copy logic. TextField contextMenuBuilder: BuildContext context EditableTextState editableTextState final List ContextMenuButtonItem buttonItems editableTextState contextMenuButtonItems final int copyButtonIndex buttonItems indexWhere ContextMenuButtonItem buttonItem return buttonItem type == ContextMenuButtonType copy }, ); if copyButtonIndex final ContextMenuButtonItem
https://docs.flutter.dev/release/breaking-changes/context-menus/index.html
47978d905c8b-10
copyButtonIndex final ContextMenuButtonItem copyButtonItem buttonItems copyButtonIndex ]; buttonItems copyButtonIndex copyButtonItem copyWith onPressed: () copyButtonItem onPressed (); Navigator of context push DialogRoute void >( context: context builder: BuildContext context const AlertDialog title: Text 'Copied, but also showed this dialog.' ), ),
https://docs.flutter.dev/release/breaking-changes/context-menus/index.html
47978d905c8b-11
), ), ); }, ); return AdaptiveTextSelectionToolbar buttonItems anchors: editableTextState contextMenuAnchors buttonItems: buttonItems ); }, A full example of modifying a built-in context menu action can be found in the samples repository in modified_action_page.dart on GitHub. buildToolbar This function generated the context menu widget similarly to contextMenuBuilder, but required more setup to use. Before this change, you might have been overriding buildToolbar as a part of TextSelectionControls, like this: // Deprecated. class _MyMaterialTextSelectionControls extends MaterialTextSelectionControls
https://docs.flutter.dev/release/breaking-changes/context-menus/index.html
47978d905c8b-12
extends MaterialTextSelectionControls @override Widget buildToolbar BuildContext context Rect globalEditableRegion double textLineHeight Offset selectionMidpoint List TextSelectionPoint endpoints TextSelectionDelegate delegate ClipboardStatusNotifier clipboardStatus Offset lastSecondaryTapDownPosition return _MyCustomToolbar (); }, Now you can simply use contextMenuBuilder directly as a parameter to TextField (and others). The information provided in the parameters to buildToolbar can be obtained from the EditableTextState that is passed to contextMenuBuilder.
https://docs.flutter.dev/release/breaking-changes/context-menus/index.html
47978d905c8b-13
The following example shows how to build a fully-custom toolbar from scratch while still using the default buttons. class _MyContextMenu extends StatelessWidget const _MyContextMenu ({ required this anchor required this children }); final Offset anchor final List Widget children @override Widget build BuildContext context return Stack children: Widget >[ Positioned top: anchor dy
https://docs.flutter.dev/release/breaking-changes/context-menus/index.html
47978d905c8b-14
top: anchor dy left: anchor dx child: Container width: 200.0 height: 200.0 color: Colors amberAccent child: Column children: children ), ), ), ], ); class _MyTextField extends StatelessWidget const _MyTextField (); @override Widget build BuildContext context return
https://docs.flutter.dev/release/breaking-changes/context-menus/index.html
47978d905c8b-15
BuildContext context return TextField controller: _controller maxLines: minLines: contextMenuBuilder: context editableTextState return _MyContextMenu anchor: editableTextState contextMenuAnchors primaryAnchor children: AdaptiveTextSelectionToolbar getAdaptiveButtons context editableTextState contextMenuButtonItems toList (), ); }, ); A full example of building a custom context menu can be found in the samples repository in cutom_menu_page.dart on GitHub.
https://docs.flutter.dev/release/breaking-changes/context-menus/index.html
47978d905c8b-16
Timeline Landed in version: 3.6.0-0.0.pre In stable release: 3.7.0 References API documentation: TextField.contextMenuBuilder AdaptiveTextSelectionToolbar Relevant issues: Simple custom text selection toolbars Right click menu outside of text fields Text editing for desktop - stable Ability to disable context menu on TextFields Missing APIs for text selection toolbar styling Enable copy toolbar in all widgets Disable context menu from browser Custom context menus don’t show up for Flutter web Relevant PRs: ContextMenus Ability to disable the browser’s context menu on web Ability to disable the browser’s context menu on web (engine)
https://docs.flutter.dev/release/breaking-changes/context-menus/index.html
47978d905c8b-17
Ability to disable the browser’s context menu on web (engine) Custom context menus in SelectableRegion on web
https://docs.flutter.dev/release/breaking-changes/context-menus/index.html
8fadbb24e06b-0
New CupertinoIcons has icon glyph changes Summary Description of change Unchanged icons Merged icons Migration guide Timeline References Summary The existing cupertino_icons 0.1.3 icons are based on iOS 11 aesthetics with sharp angles and thin lines. As Apple’s iconography updates with new OS versions, the cupertino_icons package is also refreshed. Generally, all previous glyphs referenced from the CupertinoIcons API are automatically mapped to very similar looking icons in the new SF Symbols style (featuring rounder, thicker lines). Some icons that have no equivalents in the new SF Symbols style are left as is.
https://docs.flutter.dev/release/breaking-changes/cupertino-icons-1.0.0/index.html
8fadbb24e06b-1
Some icons that have less variation (such as thickness, alterative looks, and so on) are automapped and collapsed to the best matching variation in the new SF Symbols style but should be double checked to determine whether they preserve the intended visual effect. Description of change The new cupertino_icons 1.0.0 font is handcrafted to best preserve the intent and aesthetic of the symbology through the transition. All existing CupertinoIcons’ static IconData fields (and thus all of the font .ttf’s codepoints) continue to work and point to a reasonable new icon. The new cupertino_icons 1.0.0 package also has ~1,000 more icons to choose from. Unchanged icons No SF Symbols styled alternatives exist for the icons in the following list. The previous cupertino_icons 0.1.3 icons have been kept as is in 1.0.0.
https://docs.flutter.dev/release/breaking-changes/cupertino-icons-1.0.0/index.html
8fadbb24e06b-2
bluetooth bus car car_detailed chevron_back chevron_forward lab_flask lab_flask_solid news news_solid train_style_one train_style_two Merged icons Icons within the same group are now the exact same icon in 1.0.0. In other words, the distinctions between those icon variations that existed in 0.1.3 is lost and now renders the same SF Symbols styled icon that represents the theme of the group. This affects the following icon groups: share, share_up battery_charging, battery_full, battery_75_percent shuffle, shuffle_medium, shuffle_thick delete, delete_simple
https://docs.flutter.dev/release/breaking-changes/cupertino-icons-1.0.0/index.html
8fadbb24e06b-3
delete, delete_simple refresh, refresh_thin, refresh_thick clear, clear_thick clear_circled_solid, clear_thick_circled gear, gear_alt, gear_big loop, loop_thick time_solid, clock_solid time, clock tag, tags tag_solid, tags_solid This is mainly due to some artistic liberties taken when creating the original cupertino_icons set that no longer match the variations diversity of the more formal SF Symbols icon set for some of the icons. Migration guide After upgrading to 1.22, if you also upgrade the cupertino_icons pubspec dependency from 0.1.3 to 1.0.0, for example, by changing: dependencies ... // Other dependencies
https://docs.flutter.dev/release/breaking-changes/cupertino-icons-1.0.0/index.html
8fadbb24e06b-4
dependencies ... // Other dependencies cupertino_icons ^0.1.0 to: dependencies ... // Other dependencies cupertino_icons ^1.0.0 All your CupertinoIcons should automatically update to the new aesthetic (except for the unchanged icons listed above). At this point, you can also explore CupertinoIcons for new icons to use in your application. You’re encouraged to verify your application after migrating to ensure that the automatically mapped new icons are suitable for your desired aesthetics. Timeline Landed in: 1.22.0-10.0.pre.65 In stable release: 1.22 References
https://docs.flutter.dev/release/breaking-changes/cupertino-icons-1.0.0/index.html
e114628aeb63-0
CupertinoTabBar requires Localizations parent Summary Context Migration guide Timeline References Summary Instances of CupertinoTabBar must have a Localizationsparent in order to provide a localized Semantics hint. Trying to instantiate a CupertinoTabBar without localizations results in an assertion such as the following: Context To support localized semantics information, the CupertinoTabBar requires localizations. Before this change, the Semantics hint provided to the CupertinoTabBar was a hard-coded String, ‘tab, $index of $total’. The content of the semantics hint was also updated from this original String to ‘Tab $index of $total’ in English.
https://docs.flutter.dev/release/breaking-changes/cupertino-tab-bar-localizations/index.html
e114628aeb63-1
If your CupertinoTabBar is within the scope of a CupertinoApp, the DefaultCupertinoLocalizations is already instantiated and may suit your needs without having to make a change to your existing code. If your CupertinoTabBar is not within a CupertinoApp, you may provide the localizations of your choosing using the Localizations widget. Migration guide If you are seeing a 'localizations != null' assertion error, make sure locale information is being provided to your CupertinoTabBar. Code before migration: import 'package:flutter/cupertino.dart' void main () runApp Foo ()); class Foo extends StatelessWidget @override Widget build
https://docs.flutter.dev/release/breaking-changes/cupertino-tab-bar-localizations/index.html
e114628aeb63-2
@override Widget build BuildContext context return MediaQuery data: const MediaQueryData (), child: CupertinoTabBar items: const BottomNavigationBarItem >[ BottomNavigationBarItem icon: Icon CupertinoIcons add_circled ), label: 'Tab 1' ), BottomNavigationBarItem icon: Icon CupertinoIcons add_circled_solid ), label:
https://docs.flutter.dev/release/breaking-changes/cupertino-tab-bar-localizations/index.html
e114628aeb63-3
), label: 'Tab 2' ), ], currentIndex: ), ); Code after migration (Providing localizations via the CupertinoApp): import 'package:flutter/cupertino.dart' void main () runApp Foo ()); class Foo extends StatelessWidget @override Widget build BuildContext context return CupertinoApp home: CupertinoTabBar items: const BottomNavigationBarItem
https://docs.flutter.dev/release/breaking-changes/cupertino-tab-bar-localizations/index.html
e114628aeb63-4
items: const BottomNavigationBarItem >[ BottomNavigationBarItem icon: Icon CupertinoIcons add_circled ), label: 'Tab 1' ), BottomNavigationBarItem icon: Icon CupertinoIcons add_circled_solid ), label: 'Tab 2' ), ], currentIndex: ), ); Code after migration (Providing localizations by using the Localizations widget): import 'package:flutter/cupertino.dart' void
https://docs.flutter.dev/release/breaking-changes/cupertino-tab-bar-localizations/index.html
e114628aeb63-5
'package:flutter/cupertino.dart' void main () runApp Foo ()); class Foo extends StatelessWidget @override Widget build BuildContext context return Localizations locale: const Locale 'en' 'US' ), delegates: LocalizationsDelegate dynamic >>[ DefaultWidgetsLocalizations delegate DefaultCupertinoLocalizations delegate ], child: MediaQuery
https://docs.flutter.dev/release/breaking-changes/cupertino-tab-bar-localizations/index.html
e114628aeb63-6
], child: MediaQuery data: const MediaQueryData (), child: CupertinoTabBar items: const BottomNavigationBarItem >[ BottomNavigationBarItem icon: Icon CupertinoIcons add_circled ), label: 'Tab 1' ), BottomNavigationBarItem icon: Icon CupertinoIcons add_circled_solid ), label: 'Tab 2' ), ], currentIndex:
https://docs.flutter.dev/release/breaking-changes/cupertino-tab-bar-localizations/index.html
e114628aeb63-7
), ], currentIndex: ), ), ); Timeline This change was introduced in May 2020, in 1.18.0-9.0.pre. References API documentation: CupertinoTabBar Localizations DefaultCupertinoLocalizations Semantics CupertinoApp Internationalizing Flutter Apps Relevant PR: PR 55336: Adding tabSemanticsLabel to CupertinoLocalizations PR 56582: Update Tab semantics in Cupertino to be the same as Material
https://docs.flutter.dev/release/breaking-changes/cupertino-tab-bar-localizations/index.html
cb2174d59ef7-0
Default Scrollbars on Desktop Summary Context Description of change Migration guide Removing manual Scrollbars on desktop Setting a custom ScrollBehavior for your application Setting a custom ScrollBehavior for a specific widget Copy and modify existing ScrollBehavior Timeline References Summary ScrollBehaviors now automatically apply Scrollbars to scrolling widgets on desktop platforms - Mac, Windows and Linux. Context Prior to this change, Scrollbars were applied to scrolling widgets manually by the developer across all platforms. This did not match developer expectations when executing Flutter applications on desktop platforms. Now, the inherited ScrollBehavior applies a Scrollbar automatically to most scrolling widgets. This is similar to how GlowingOverscrollIndicator is created by ScrollBehavior. The few widgets that are exempt from this behavior are listed below.
https://docs.flutter.dev/release/breaking-changes/default-desktop-scrollbars/index.html
cb2174d59ef7-1
Further more, ScrollBehavior subclasses MaterialScrollBehavior and CupertinoScrollBehavior have been made public, allowing developers to extend and build upon the other existing ScrollBehaviors in the framework. These subclasses were previously private. Description of change The previous approach called on developers to create their own Scrollbars on all platforms. In some use cases, a ScrollController would need to be provided to the Scrollbar and the scrollable widget. final ScrollController controller ScrollController (); Scrollbar controller: controller child: ListView builder controller: controller itemBuilder: BuildContext context int index return Text 'Item $index
https://docs.flutter.dev/release/breaking-changes/default-desktop-scrollbars/index.html
cb2174d59ef7-2
Text 'Item $index ); ); The ScrollBehavior now applies the Scrollbar automatically when executing on desktop, and handles providing the ScrollController to the Scrollbar for you. final ScrollController controller ScrollController (); ListView builder controller: controller itemBuilder: BuildContext context int index return Text 'Item $index ); ); Some widgets in the framework are exempt from this automatic Scrollbar application. They are: EditableText, when maxLines is 1. ListWheelScrollView PageView
https://docs.flutter.dev/release/breaking-changes/default-desktop-scrollbars/index.html
cb2174d59ef7-3
ListWheelScrollView PageView NestedScrollView Since these widgets manually override the inherited ScrollBehavior to remove Scrollbars, all of these widgets now have a scrollBehavior parameter so that one can be provided to use instead of the override. This change did not cause any test failures, crashes, or error messages in the course of development, but it may result in two Scrollbars being rendered in your application if you are manually adding Scrollbars on desktop platforms. If you are seeing this in your application, there are several ways to control and configure this feature. Remove the manually applied Scrollbars in your application when running on desktop. Extend ScrollBehavior, MaterialScrollBehavior, or CupertinoScrollBehavior to modify the default behavior.
https://docs.flutter.dev/release/breaking-changes/default-desktop-scrollbars/index.html
cb2174d59ef7-4
With your own ScrollBehavior, you can apply it app-wide by setting MaterialApp.scrollBehavior or CupertinoApp.scrollBehavior. Or, if you wish to only apply it to specific widgets, add a ScrollConfiguration above the widget in question with your custom ScrollBehavior. Your scrollable widgets then inherits this and reflects this behavior. Instead of creating your own ScrollBehavior, another option for changing the default behavior is to copy the existing ScrollBehavior, and toggle the desired feature. Create a ScrollConfiguration in your widget tree, and provide a modified copy of the existing ScrollBehavior in the current context using copyWith. Migration guide Removing manual Scrollbars on desktop Code before migration: final ScrollController controller ScrollController (); Scrollbar controller: controller child:
https://docs.flutter.dev/release/breaking-changes/default-desktop-scrollbars/index.html
cb2174d59ef7-5
controller: controller child: ListView builder controller: controller itemBuilder: BuildContext context int index return Text 'Item $index ); ); Code after migration: final ScrollController controller ScrollController (); final Widget child ListView builder controller: controller itemBuilder: BuildContext context int index return Text 'Item
https://docs.flutter.dev/release/breaking-changes/default-desktop-scrollbars/index.html
cb2174d59ef7-6
return Text 'Item $index ); ); // Only manually add a `Scrollbar` when not on desktop platforms. // Or, see other migrations for changing `ScrollBehavior`. switch currentPlatform case TargetPlatform linux case TargetPlatform macOS case TargetPlatform windows return child case TargetPlatform android case TargetPlatform fuchsia case TargetPlatform iOS return Scrollbar controller: controller child:
https://docs.flutter.dev/release/breaking-changes/default-desktop-scrollbars/index.html
cb2174d59ef7-7
controller: controller child: child ); Setting a custom ScrollBehavior for your application Code before migration: // MaterialApps previously had a private ScrollBehavior. MaterialApp // ... ); Code after migration: // MaterialApps previously had a private ScrollBehavior. // This is available to extend now. class MyCustomScrollBehavior extends MaterialScrollBehavior // Override behavior methods like buildOverscrollIndicator and buildScrollbar // ScrollBehavior can now be configured for an entire application. MaterialApp scrollBehavior: MyCustomScrollBehavior (), // ... ); Setting a custom ScrollBehavior for a specific widget
https://docs.flutter.dev/release/breaking-changes/default-desktop-scrollbars/index.html
cb2174d59ef7-8
); Setting a custom ScrollBehavior for a specific widget Code before migration: final ScrollController controller ScrollController (); ListView builder controller: controller itemBuilder: BuildContext context int index return Text 'Item $index ); ); Code after migration: // MaterialApps previously had a private ScrollBehavior. // This is available to extend now. class MyCustomScrollBehavior extends MaterialScrollBehavior // Override behavior methods like buildOverscrollIndicator and buildScrollbar
https://docs.flutter.dev/release/breaking-changes/default-desktop-scrollbars/index.html
cb2174d59ef7-9
// Override behavior methods like buildOverscrollIndicator and buildScrollbar // ScrollBehavior can be set for a specific widget. final ScrollController controller ScrollController (); ScrollConfiguration behavior: MyCustomScrollBehavior (), child: ListView builder controller: controller itemBuilder: BuildContext context int index return Text 'Item $index ); ), ); Copy and modify existing ScrollBehavior Code before migration: final ScrollController controller ScrollController
https://docs.flutter.dev/release/breaking-changes/default-desktop-scrollbars/index.html
cb2174d59ef7-10
ScrollController controller ScrollController (); ListView builder controller: controller itemBuilder: BuildContext context int index return Text 'Item $index ); ); Code after migration: // ScrollBehavior can be copied and adjusted. final ScrollController controller ScrollController (); ScrollConfiguration behavior: ScrollConfiguration of context copyWith scrollbars: false ), child: ListView
https://docs.flutter.dev/release/breaking-changes/default-desktop-scrollbars/index.html
cb2174d59ef7-11
), child: ListView builder controller: controller itemBuilder: BuildContext context int index return Text 'Item $index ); ), ); Timeline Landed in version: 2.2.0-10.0.pre In stable release: 2.2.0 References API documentation: ScrollConfiguration ScrollBehavior MaterialScrollBehavior CupertinoScrollBehavior Scrollbar CupertinoScrollbar Relevant issues: Issue #40107 Issue #70866
https://docs.flutter.dev/release/breaking-changes/default-desktop-scrollbars/index.html
cb2174d59ef7-12
Issue #40107 Issue #70866 Relevant PRs: Exposing ScrollBehaviors for app-wide settings Automatically applying Scrollbars on desktop platforms with configurable ScrollBehaviors
https://docs.flutter.dev/release/breaking-changes/default-desktop-scrollbars/index.html
da545305f635-0
Default drag scrolling devices Summary Context Description of change Migration guide Setting a custom ScrollBehavior for your application Setting a custom ScrollBehavior for a specific widget Copy and modify existing ScrollBehavior Migrate GestureDetectors from kind to supportedDevices Timeline References Summary ScrollBehaviors now allow or disallow drag scrolling from specified PointerDeviceKinds. ScrollBehavior.dragDevices, by default, allows scrolling widgets to be dragged by all PointerDeviceKinds except for PointerDeviceKind.mouse. Context Prior to this change, all PointerDeviceKinds could drag a Scrollable widget. This did not match developer expectations when interacting with Flutter applications using mouse input devices. This also made it difficult to execute other mouse gestures, like selecting text that was contained in a Scrollable widget.
https://docs.flutter.dev/release/breaking-changes/default-scroll-behavior-drag/index.html
da545305f635-1
Now, the inherited ScrollBehavior manages which devices can drag scrolling widgets as specified by ScrollBehavior.dragDevices. This set of PointerDeviceKinds are allowed to drag. Description of change This change fixed the unexpected ability to scroll by dragging with a mouse. If you have relied on the previous behavior in your application, there are several ways to control and configure this feature. Extend ScrollBehavior, MaterialScrollBehavior, or CupertinoScrollBehavior to modify the default behavior, overriding ScrollBehavior.dragDevices. With your own ScrollBehavior, you can apply it app-wide by setting MaterialApp.scrollBehavior or CupertinoApp.scrollBehavior. Or, if you wish to only apply it to specific widgets, add a ScrollConfiguration above the widget in question with your custom ScrollBehavior. Your scrollable widgets then inherit and reflect this behavior.
https://docs.flutter.dev/release/breaking-changes/default-scroll-behavior-drag/index.html
da545305f635-2
Your scrollable widgets then inherit and reflect this behavior. Instead of creating your own ScrollBehavior, another option for changing the default behavior is to copy the existing ScrollBehavior, and set different dragDevices. Create a ScrollConfiguration in your widget tree, and provide a modified copy of the existing ScrollBehavior in the current context using copyWith. Migration guide Setting a custom ScrollBehavior for your application Code before migration: MaterialApp // ... ); Code after migration: class MyCustomScrollBehavior extends MaterialScrollBehavior // Override behavior methods and getters like dragDevices @override Set PointerDeviceKind get dragDevices PointerDeviceKind touch
https://docs.flutter.dev/release/breaking-changes/default-scroll-behavior-drag/index.html
da545305f635-3
dragDevices PointerDeviceKind touch PointerDeviceKind mouse // etc. }; // Set ScrollBehavior for an entire application. MaterialApp scrollBehavior: MyCustomScrollBehavior (), // ... ); Setting a custom ScrollBehavior for a specific widget Code before migration: final ScrollController controller ScrollController (); ListView builder controller: controller itemBuilder: BuildContext context int index return Text 'Item $index
https://docs.flutter.dev/release/breaking-changes/default-scroll-behavior-drag/index.html
da545305f635-4
Text 'Item $index ); ); Code after migration: class MyCustomScrollBehavior extends MaterialScrollBehavior // Override behavior methods and getters like dragDevices @override Set PointerDeviceKind get dragDevices PointerDeviceKind touch PointerDeviceKind mouse // etc. }; // ScrollBehavior can be set for a specific widget. final ScrollController controller ScrollController (); ScrollConfiguration behavior: MyCustomScrollBehavior (), child:
https://docs.flutter.dev/release/breaking-changes/default-scroll-behavior-drag/index.html
da545305f635-5
MyCustomScrollBehavior (), child: ListView builder controller: controller itemBuilder: BuildContext context int index return Text 'Item $index ); ), ); Copy and modify existing ScrollBehavior Code before migration: final ScrollController controller ScrollController (); ListView builder controller: controller itemBuilder: BuildContext context int index return Text 'Item
https://docs.flutter.dev/release/breaking-changes/default-scroll-behavior-drag/index.html
da545305f635-6
return Text 'Item $index ); ); Code after migration: // ScrollBehavior can be copied and adjusted. final ScrollController controller ScrollController (); ScrollConfiguration behavior: ScrollConfiguration of context copyWith dragDevices: PointerDeviceKind touch PointerDeviceKind mouse }), child: ListView builder controller: controller itemBuilder: BuildContext context int index return
https://docs.flutter.dev/release/breaking-changes/default-scroll-behavior-drag/index.html
da545305f635-7
context int index return Text 'Item $index ); ), ); Migrate GestureDetectors from kind to supportedDevices Code before migration: VerticalDragGestureRecognizer kind: PointerDeviceKind touch ); Code after migration: VerticalDragGestureRecognizer supportedDevices: PointerDeviceKind >{ PointerDeviceKind touch }, ); Timeline Landed in version: 2.3.0-12.0.pre In stable release: 2.5 References API documentation:
https://docs.flutter.dev/release/breaking-changes/default-scroll-behavior-drag/index.html
da545305f635-8
References API documentation: ScrollConfiguration ScrollBehavior MaterialScrollBehavior CupertinoScrollBehavior PointerDeviceKind GestureDetector Relevant issues: Issue #71322 Relevant PRs: Reject mouse drags by default in scrollables Deprecate GestureDetector.kind in favor of new supportedDevices
https://docs.flutter.dev/release/breaking-changes/default-scroll-behavior-drag/index.html
edb1a633867c-0
Dialogs' Default BorderRadius Summary Context Migration guide Timeline References Summary Context Dialogs and their associated subclasses (SimpleDialog, AlertDialog, and showTimePicker), appears slightly different as the border radius is larger. if you have master golden file images that have the prior rendering of the Dialog with a 2.0 pixel border radius, your widget tests will fail. These golden file images can be updated to reflect the new rendering, or you can update your code to maintain the original behavior. The showDatePicker dialog already matched this specification and is unaffected by this change. Migration guide If you would prefer to maintain the old shape, you can use the shape property of your Dialog to specify the original 2.0 pixel radius. Setting the Dialog shape to the original radius: import 'package:flutter/material.dart'
https://docs.flutter.dev/release/breaking-changes/dialog-border-radius/index.html
edb1a633867c-1
import 'package:flutter/material.dart' void main () runApp Foo ()); class Foo extends StatelessWidget @override Widget build BuildContext context return MaterialApp home: Scaffold floatingActionButton: FloatingActionButton onPressed: () showDialog context: context builder: BuildContext context return AlertDialog content: Text 'Alert!'
https://docs.flutter.dev/release/breaking-changes/dialog-border-radius/index.html
edb1a633867c-2
content: Text 'Alert!' ), shape: RoundedRectangleBorder borderRadius: BorderRadius all Radius circular 2.0 ))), ); }, ); }), ), ); If you prefer the new behavior and have failing golden file tests, you can update your master golden files using this command: test -update-goldens Timeline Landed in version: 1.20.0-0.0.pre In stable release: 1.20 References API documentation: Dialog SimpleDialog AlertDialog
https://docs.flutter.dev/release/breaking-changes/dialog-border-radius/index.html
edb1a633867c-3
Dialog SimpleDialog AlertDialog showTimePicker showDatePicker Relevant PR: PR 58829: Matching Material Spec for Dialog shape
https://docs.flutter.dev/release/breaking-changes/dialog-border-radius/index.html
ba8e1b6f02ec-0
TextField FocusNode attach location change Summary Context Description of change Migration guide Timeline References Summary EditableText.focusNode is now attached to a dedicated Focus widget below EditableText. Context A text input field widget (TextField, for example) typically owns a FocusNode. When that FocusNode is the primary focus of the app, events (such as key presses) are sent to the BuildContext to which the FocusNode is attached. Description of change This change does not involve any public API changes but breaks codebases relying on that particular implementation detail to tell if a FocusNode is associated with a text input field. This change does not break any builds but can introduce runtime issues, or cause existing tests to fail. Migration guide
https://docs.flutter.dev/release/breaking-changes/editable-text-focus-attachment/index.html
ba8e1b6f02ec-1
Migration guide The EditableText widget takes a FocusNode as a paramter, which was previously attached to its EditableText’s BuildContext. If you are relying on runtime typecheck to find out if a FocusNode is attached to a text input field or a selectable text field like so: focusNode.context.widget is EditableText (focusNode.context as StatefulElement).state as EditableTextState Then please read on and consider following the migration steps to avoid breakages. If you’re not sure whether a codebase needs migration, search for is EditableText, as EditableText, is EditableTextState, and as EditableTextState and verify if any of the search results are doing a typecheck or typecast on a FocusNode.context. If so, then migration is needed. Code before migration: final Widget focusedWidget primaryFocus ?.
https://docs.flutter.dev/release/breaking-changes/editable-text-focus-attachment/index.html
ba8e1b6f02ec-2
focusedWidget primaryFocus ?. context ?. widget if focusedWidget is EditableText widget controller text 'Updated Text' Code after migration: final BuildContext focusedContext primaryFocus ?. context if focusedContext != null Actions maybeInvoke focusedContext ReplaceTextIntent 'UpdatedText' )); For a comprehensive list of Intents supported by the EditableText widget, refer to the documentation of the EditableText widget. Timeline
https://docs.flutter.dev/release/breaking-changes/editable-text-focus-attachment/index.html