id
stringlengths 14
17
| text
stringlengths 23
1.11k
| source
stringlengths 35
114
|
---|---|---|
ba8e1b6f02ec-3 | Timeline
Landed in version: 2.6.0-12.0.pre
In stable release: not yet
References
API documentation:
EditableText
Relevant PRs:
Move text editing Actions to EditableTextState | https://docs.flutter.dev/release/breaking-changes/editable-text-focus-attachment/index.html |
eb1b0190ebdd-0 | Eliminating nullOk Parameters
Summary
Context
Description of change
Migration guide
Timeline
References
Summary
This migration guide describes conversion of code that uses the nullOk
parameter on multiple of static accessors and related accessors to use
alternate APIs with nullable return values.
Context
Flutter has a common pattern of allowing lookup of some types of widgets
(InheritedWidgets) using static member functions that are typically called
of, and take a BuildContext.
Before non-nullability was the default, it was useful to have a toggle on these
APIs that swapped between throwing an exception if the widget was not present in
the widget tree and returning null if it was not found. It was useful, and
wasn’t confusing, since every variable was nullable. | https://docs.flutter.dev/release/breaking-changes/eliminating-nullok-parameters/index.html |
eb1b0190ebdd-1 | When non-nullability was made the default, it was then desirable to have the
most commonly used APIs return a non-nullable value. This is because saying
MediaQuery.of(context, nullOk: false) and then still requiring an ! operator
or ? and a fallback value after that call felt awkward.
The nullOk parameter was a cheap form of providing a null safety toggle, which
in the face of true language support for non-nullability, was then supplying
redundant, and perhaps contradictory signals to the developer.
To solve this, the of accessors (and some related accessors that also used
nullOk) were split into two calls: one that returned a non-nullable value and
threw an exception when the sought-after widget was not present, and one that
returned a nullable value that didn’t throw an exception, and returned null if
the widget was not present.
The design document for this change is Eliminating nullOk parameters.
Description of change | https://docs.flutter.dev/release/breaking-changes/eliminating-nullok-parameters/index.html |
eb1b0190ebdd-2 | Description of change
The actual change modified these APIs to not have a nullOk parameter, and to
return a non-nullable value:
MediaQuery.of
Navigator.of
ScaffoldMessenger.of
Scaffold.of
Router.of
Localizations.localeOf
FocusTraversalOrder.of
FocusTraversalGroup.of
Focus.of
Shortcuts.of
Actions.handler
Actions.find
Actions.invoke
AnimatedList.of
SliverAnimatedList.of
CupertinoDynamicColor.resolve
CupertinoDynamicColor.resolveFrom
CupertinoUserInterfaceLevel.of
CupertinoTheme.brightnessOf | https://docs.flutter.dev/release/breaking-changes/eliminating-nullok-parameters/index.html |
eb1b0190ebdd-3 | CupertinoTheme.brightnessOf
CupertinoThemeData.resolveFrom
NoDefaultCupertinoThemeData.resolveFrom
CupertinoTextThemeData.resolveFrom
MaterialBasedCupertinoThemeData.resolveFrom
And introduced these new APIs alongside those, to return a nullable
value:
MediaQuery.maybeOf
Navigator.maybeOf
ScaffoldMessenger.maybeOf
Scaffold.maybeOf
Router.maybeOf
Localizations.maybeLocaleOf
FocusTraversalOrder.maybeOf
FocusTraversalGroup.maybeOf
Focus.maybeOf
Shortcuts.maybeOf
Actions.maybeFind
Actions.maybeInvoke
AnimatedList.maybeOf | https://docs.flutter.dev/release/breaking-changes/eliminating-nullok-parameters/index.html |
eb1b0190ebdd-4 | Actions.maybeInvoke
AnimatedList.maybeOf
SliverAnimatedList.maybeOf
CupertinoDynamicColor.maybeResolve
CupertinoUserInterfaceLevel.maybeOf
CupertinoTheme.maybeBrightnessOf
Migration guide
In order to modify your code to use the new form of the APIs, convert all
instances of calls that include nullOk = true as a parameter to use the
maybe form of the API instead.
So this:
MediaQueryData
data
MediaQuery
of
context
nullOk:
true
);
becomes:
MediaQueryData
data
MediaQuery
maybeOf
context
); | https://docs.flutter.dev/release/breaking-changes/eliminating-nullok-parameters/index.html |
eb1b0190ebdd-5 | maybeOf
context
);
You also need to modify all instances of calling the API with nullOk =
false (often the default), to accept non-nullable return values, or remove any
! operators:
So either of:
MediaQueryData
data
MediaQuery
of
context
// nullOk false by default.
MediaQueryData
data
MediaQuery
of
context
);
// nullOk false by default.
both become:
MediaQueryData
data
MediaQuery
of
context
);
// No ! or ? operator here now. | https://docs.flutter.dev/release/breaking-changes/eliminating-nullok-parameters/index.html |
eb1b0190ebdd-6 | );
// No ! or ? operator here now.
The unnecessary_non_null_assertion analysis option can be quite helpful in
finding the places where the ! operator should be removed, and the
unnecessary_nullable_for_final_variable_declarations analysis option can be
helpful in finding unnecessary question mark operators on final and const
variables.
Timeline
Landed in version: 1.24.0
In stable release: 2.0.0
References
API documentation:
MediaQuery.of
Navigator.of
ScaffoldMessenger.of
Scaffold.of
Router.of
Localizations.localeOf
FocusTraversalOrder.of
FocusTraversalGroup.of
Focus.of
Shortcuts.of | https://docs.flutter.dev/release/breaking-changes/eliminating-nullok-parameters/index.html |
eb1b0190ebdd-7 | Focus.of
Shortcuts.of
Actions.handler
Actions.find
Actions.invoke
AnimatedList.of
SliverAnimatedList.of
CupertinoDynamicColor.resolve
CupertinoDynamicColor.resolveFrom
CupertinoUserInterfaceLevel.of
CupertinoTheme.brightnessOf
CupertinoThemeData.resolveFrom
NoDefaultCupertinoThemeData.resolveFrom
CupertinoTextThemeData.resolveFrom
MaterialBasedCupertinoThemeData.resolveFrom
MediaQuery.maybeOf
Navigator.maybeOf
ScaffoldMessenger.maybeOf
Scaffold.maybeOf
Router.maybeOf
Localizations.maybeLocaleOf | https://docs.flutter.dev/release/breaking-changes/eliminating-nullok-parameters/index.html |
eb1b0190ebdd-8 | Router.maybeOf
Localizations.maybeLocaleOf
FocusTraversalOrder.maybeOf
FocusTraversalGroup.maybeOf
Focus.maybeOf
Shortcuts.maybeOf
Actions.maybeFind
Actions.maybeInvoke
AnimatedList.maybeOf
SliverAnimatedList.maybeOf
CupertinoDynamicColor.maybeResolve
CupertinoUserInterfaceLevel.maybeOf
CupertinoTheme.maybeBrightnessOf
Relevant issues:
Issue 68637
Relevant PRs:
Remove nullOk in MediaQuery.of
Remove nullOk in Navigator.of
Remove nullOk parameter from AnimatedList.of and SliverAnimatedList.of | https://docs.flutter.dev/release/breaking-changes/eliminating-nullok-parameters/index.html |
eb1b0190ebdd-9 | Remove nullOk parameter from AnimatedList.of and SliverAnimatedList.of
Remove nullOk parameter from Shortcuts.of, Actions.find, and Actions.handler
Remove nullOk parameter from Focus.of, FocusTraversalOrder.of, and FocusTraversalGroup.of
Remove nullOk parameter from Localizations.localeOf
Remove nullOk parameter from Router.of
Remove nullOk from Scaffold.of and ScaffoldMessenger.of
Remove nullOk parameter from Cupertino color resolution APIs
Remove vestigial nullOk parameter from Localizations.localeOf
Remove nullOk from Actions.invoke, add Actions.maybeInvoke | https://docs.flutter.dev/release/breaking-changes/eliminating-nullok-parameters/index.html |
f19fc80ec82a-0 | Change the enterText method to move the caret to the end of the input text
Summary
Context
Description of change
Migration guide
TestTextInput.enterText
WidgetTester.enterText
Timeline
References
Summary
The WidgetTester.enterText and TestTextInput.enterText methods
now move the caret to the end of the input text.
Context
The caret indicates the insertion point within the current text in an
active input field. Typically, when a new character is entered, the
caret stays immediately after it. In Flutter the caret position is
represented by a collapsed selection. When the selection is invalid,
usually the user won’t be able to modify or add text until they
change the selection to a valid value. | https://docs.flutter.dev/release/breaking-changes/enterText-trailing-caret/index.html |
f19fc80ec82a-1 | WidgetTester.enterText and TestTextInput.enterText are 2 methods
used in tests to replace the content of the target text field. Prior
to this change, WidgetTester.enterText and TestTextInput.enterText
set the selection to an invalid range (-1, -1), indicating there’s
no selection or caret. This contradicts the typical behavior of an
input field.
Description of change
In addition to replacing the text with the supplied text,
WidgetTester.enterText and TestTextInput.enterText now set the
selection to TextSelection.collapsed(offset: text.length), instead
of TextSelection.collapsed(offset: -1).
Migration guide
It should be very uncommon for tests to have to rely on the
previous behavior of enterText, since usually the selection
should not be invalid. Consider changing the expected values of
your tests to adopt the enterText change.
Common test failures this change may introduce includes: | https://docs.flutter.dev/release/breaking-changes/enterText-trailing-caret/index.html |
f19fc80ec82a-2 | Common test failures this change may introduce includes:
Golden test failures:
The caret appears at the end of the text, as opposed to before
the text prior to the change.
Different TextEditingValue.selection after calling enterText:
The text field’s TextEditingValue now has a collapsed
selection with a non-negative offset, as opposed to
TextSelection.collapsed(offset: -1) prior to the change.
For instance, you may see
expect(controller.value.selection.baseOffset, -1);
failing after enterText calls.
If your tests have to rely on setting the selection to invalid,
the previous behavior can be achieved usingupdateEditingValue:
TestTextInput.enterText
Code before migration:
await
testTextInput
enterText
text
);
Code after migration:
await | https://docs.flutter.dev/release/breaking-changes/enterText-trailing-caret/index.html |
f19fc80ec82a-3 | );
Code after migration:
await
testTextInput
updateEditingValue
TextEditingValue
text:
text
));
WidgetTester.enterText
Code before migration:
await
tester
enterText
finder
text
);
Code after migration:
await
tester
showKeyboard
finder
);
await
tester
updateEditingValue
TextEditingValue
text:
text
));
await
tester
idle
();
Timeline | https://docs.flutter.dev/release/breaking-changes/enterText-trailing-caret/index.html |
f19fc80ec82a-4 | idle
();
Timeline
Landed in version: 2.1.0-13.0.pre
In stable release: 2.5
References
API documentation:
WidgetTester.enterText
TestTextInput.enterText
Relevant issues:
Issue 79494
Relevant PRs:
enterText to move the caret to the end | https://docs.flutter.dev/release/breaking-changes/enterText-trailing-caret/index.html |
78715337436c-0 | FloatingActionButton and ThemeData's accent properties
Summary
Context
Description of change
Migration guide
Timeline
References
Summary
Removed Flutter’s FloatingActionButton (FAB) dependency on
ThemeData accent properties.
Context
This was a small part of the Material Theme System Updates project.
Previously, the ThemeData accentIconTheme property was only
used by FloatingActionButton to determine the default
color of the text or icons that appeared within the button.
FloatingActionButton also used the
ThemeData accentTextTheme property,
however this dependency was undocumented and unnecessary. | https://docs.flutter.dev/release/breaking-changes/fab-theme-data-accent-properties/index.html |
78715337436c-1 | Both of these dependencies were confusing.
For example if one configured the Theme’s accentIconTheme
to change the appearance of all floating action buttons,
it was difficult to know what other components would be affected,
or might be affected in the future.
The Material Design spec no longer includes an “accent” color.
The ColorScheme’s secondary color is now used instead.
With this change, the default behavior uses the color scheme’s
onSecondary color instead.
Description of change
Previously, the accentIconTheme provided a default for the
FloatingActionButton’s foregroundColor property:
final
Color
foregroundColor
this
foregroundColor
??
floatingActionButtonTheme
foregroundColor
??
theme
accentIconTheme
color
// To be removed. | https://docs.flutter.dev/release/breaking-changes/fab-theme-data-accent-properties/index.html |
78715337436c-2 | color
// To be removed.
??
theme
colorScheme
onSecondary
Apps that configure their theme’s accentIconTheme
to effectively configure the foregroundColor of all
floating action buttons, can get the same effect by
configuring the foregroundColor of their theme’s
floatingActionButtonTheme.
// theme.accentTextTheme becomes theme.textTheme
final
TextStyle
textStyle
theme
accentTextTheme
button
copyWith
color:
foregroundColor
letterSpacing:
1.2
); | https://docs.flutter.dev/release/breaking-changes/fab-theme-data-accent-properties/index.html |
78715337436c-3 | letterSpacing:
1.2
);
Except in a case where an app has explicitly configured the
accentTextTheme to take advantage of this undocumented dependency,
this use of accentTextTheme is unnecessary.
This change replaces this use of accentTextTheme with textTheme.
Migration guide
This change occurred in two steps:
If the foreground of a FloatingActionButton is set
to a non-default color, a warning is now printed.
The accentIconTheme dependency was removed.
If you haven’t already done so, migrate your apps
per the pattern below.
To configure the FloatingActionButton’s foregroundColor
for all FABs, you can configure the theme’s
floatingActionButtonTheme instead of its accentIconTheme.
Code before migration:
MaterialApp
theme:
ThemeData | https://docs.flutter.dev/release/breaking-changes/fab-theme-data-accent-properties/index.html |
78715337436c-4 | MaterialApp
theme:
ThemeData
accentIconTheme:
IconThemeData
color:
Colors
red
),
),
Code after migration:
MaterialApp
theme:
ThemeData
floatingActionButtonTheme:
FloatingActionButtonThemeData
foregroundColor:
Colors
red
),
),
Timeline
Landed in version: 1.16.3
In stable release: 1.17
References
Design doc:
Remove FAB Accent Theme Dependency
API documentation:
FloatingActionButton
ThemeData
FloatingActionButtonThemeData | https://docs.flutter.dev/release/breaking-changes/fab-theme-data-accent-properties/index.html |
78715337436c-5 | ThemeData
FloatingActionButtonThemeData
Relevant PRs:
Step 1 of 2 Warn about Flutter’s
FloatingActionButton dependency on ThemeData accent properties
Step 2 of 2 Remove Flutter’s FloatingActionButton dependency
on ThemeData accent properties
Other:
Material Theme System Updates | https://docs.flutter.dev/release/breaking-changes/fab-theme-data-accent-properties/index.html |
c19093a775a2-0 | The forgetChild() method must call super
Summary
Context
Description of change
Migration guide
Timeline
References
Summary
A recent global key duplication detection refactor now requires
Element subclasses that override the forgetChild() to call super().
Context
When encountering a global key duplication that will be
cleaned up by an element rebuild later,
we must not report global key duplication.
Our previous implementation threw an error as soon as
duplication was detected, and didn’t wait for the rebuild if the
element with the duplicated global key would have rebuilt. | https://docs.flutter.dev/release/breaking-changes/forgetchild-call-super/index.html |
c19093a775a2-1 | The new implementation keeps track of all global
key duplications during a build cycle, and only verifies global
key duplication at the end of the that cycle instead of
throwing an error immediately. As part of the refactoring,
we implemented a mechanism to remove previous global key
duplication in forgetChild if the rebuild had happened.
This, however, requires all Element subclasses that
override forgetChild to call the super method.
Description of change
The forgetChild of abstract class Element has a base
implementation to remove global key reservation,
and it is enforced by the @mustCallSuper meta tag.
All subclasses that override the method have to call super;
otherwise, the analyzer shows a linting error and
global key duplication detection might throw an unexpected error.
Migration guide
In the following example, an app’s Element
subclass overrides the forgetChild method.
Code before migration:
class
CustomElement
extends
Element | https://docs.flutter.dev/release/breaking-changes/forgetchild-call-super/index.html |
c19093a775a2-2 | CustomElement
extends
Element
@override
void
forgetChild
Element
child
...
Code after migration:
class
CustomElement
extends
Element
@override
void
forgetChild
Element
child
...
super
forgetChild
child
);
Timeline
Landed in version: 1.16.3
In stable release: 1.17
References
API documentation:
Element
forgetChild()
Relevant issues:
Issue 43780
Relevant PRs: | https://docs.flutter.dev/release/breaking-changes/forgetchild-call-super/index.html |
c19093a775a2-3 | Issue 43780
Relevant PRs:
PR 43790: Fix global key error | https://docs.flutter.dev/release/breaking-changes/forgetchild-call-super/index.html |
760196d12b23-0 | The new Form, FormField auto-validation API
Summary
Context
Description of change
Migration guide
Timeline
References
Summary
The previous auto validation API for the Form and
FormField widgets didn’t control when auto validation
should occur. So the auto validation for these widgets
always happened on first build when the widget was first
visible to the user, and you weren’t able to control
when the auto validation should happen.
Context
Due to the original API not allowing developers to change
the auto validation behavior for validating only when
the user interacts with the form field, we added new API
that allows developers to configure how they want
auto validation to behave for the Form and FormField
widgets.
Description of change
The following changes were made:
The autovalidate parameter is deprecated. | https://docs.flutter.dev/release/breaking-changes/form-field-autovalidation-api/index.html |
760196d12b23-1 | The autovalidate parameter is deprecated.
A new parameter called autovalidateMode,
an Enum that accepts values from the AutovalidateMode
Enum class, is added.
Migration guide
To migrate to the new auto validation API you need to
replace the usage of the deprecated autovalidate
parameter to the new autovalidateMode parameter.
If you want the same behavior as before you can use:
autovalidateMode = AutovalidateMode.always.
This makes your Form and FormField widgets auto
validate on first build and every time it changes.
Code before migration:
class
MyWidget
extends
StatelessWidget
@override
Widget
build
BuildContext
context
return
FormField
autovalidate:
true
builder: | https://docs.flutter.dev/release/breaking-changes/form-field-autovalidation-api/index.html |
760196d12b23-2 | autovalidate:
true
builder:
FormFieldState
state
return
Container
();
},
);
Code after migration:
class
MyWidget
extends
StatelessWidget
@override
Widget
build
BuildContext
context
return
FormField
autovalidateMode:
AutovalidateMode
always
builder:
FormFieldState
state
return
Container
();
},
);
Timeline | https://docs.flutter.dev/release/breaking-changes/form-field-autovalidation-api/index.html |
760196d12b23-3 | },
);
Timeline
Landed in version: 1.21.0-5.0.pre
In stable release: 1.22
References
API documentation:
AutovalidateMode
Relevant issues:
Issue 56363
Issue 18885
Issue 15404
Issue 36154
Issue 48876
Relevant PRs:
PR 56365: FormField should autovalidate only if its
content was changed
PR 59766: FormField should autovalidate only if its
content was changed
(fixed) | https://docs.flutter.dev/release/breaking-changes/form-field-autovalidation-api/index.html |
cd83951b295c-0 | GestureRecognizer cleanup
Summary
Context
Description of change
Migration guide
Timeline
References
Summary
OneSequenceGestureRecognizer.addAllowedPointer() was changed to take a
PointerDownEvent, like it superclass. Previously, it accepted the more
general PointerEvent type, which was incorrect.
Context
The framework only ever passes PointerDownEvent objects to
addAllowedPointer(). Declaring
OneSequenceGestureRecognizer.addAllowedPointer() to take the more general
type was confusing, and caused OneSequenceGestureRecognizer subclasses to
have to cast their argument to the right class.
Description of change
The previous declaration forced OneSequenceGestureRecognizer descendants to
override addAllowedPointer() like so:
class
CustomGestureRecognizer
extends
ScaleGestureRecognizer
@override | https://docs.flutter.dev/release/breaking-changes/gesture-recognizer-add-allowed-pointer/index.html |
cd83951b295c-1 | extends
ScaleGestureRecognizer
@override
void
addAllowedPointer
PointerEvent
event
// insert custom handling of event here...
super
addAllowedPointer
event
);
The new method declaration will cause this code to fail with the following
error message:
Migration guide
Code before migration:
class
CustomGestureRecognizer
extends
ScaleGestureRecognizer
@override
void
addAllowedPointer
PointerEvent
event
// insert custom handling of event here...
super
addAllowedPointer
event
);
Code after migration:
class | https://docs.flutter.dev/release/breaking-changes/gesture-recognizer-add-allowed-pointer/index.html |
cd83951b295c-2 | );
Code after migration:
class
CustomGestureRecognizer
extends
ScaleGestureRecognizer
@override
void
addAllowedPointer
PointerDownEvent
event
// insert custom handling of event here...
super
addAllowedPointer
event
);
Timeline
Landed in version: 2.3.0-13.0.pre
In stable release: 2.5
References
API documentation:
OneSequenceGestureRecognizer
Relevant PRs:
Fix addAllowedPointer() overrides | https://docs.flutter.dev/release/breaking-changes/gesture-recognizer-add-allowed-pointer/index.html |
d4826cdc457c-0 | More Strict Assertions in the Navigator and the Hero Controller Scope
Summary
Context
Description of change
Migration guide
Timeline
References
Summary
The framework throws an assertion error when it detects there are
multiple navigators registered with one hero controller scope.
Context
The hero controller scope hosts a hero controller for its widget
subtree. The hero controller can only support one navigator at
a time. Previously, there was no assertion to guarantee that.
Description of change
If the code starts throwing assertion errors after this change,
it means the code was already broken even before this change.
Multiple navigators may be registered under the same hero
controller scope, and they can not trigger hero animations when
their route changes. This change only surfaced this problem.
Migration guide
An example application that starts to throw exceptions.
import | https://docs.flutter.dev/release/breaking-changes/hero-controller-scope/index.html |
d4826cdc457c-1 | An example application that starts to throw exceptions.
import
'package:flutter/material.dart'
void
main
()
runApp
MaterialApp
builder:
BuildContext
context
Widget
child
// Builds two parallel navigators. This throws
// error because both of navigators are under the same
// hero controller scope created by MaterialApp.
return
Stack
children:
Widget
>[
Navigator
onGenerateRoute:
RouteSettings
settings
return
MaterialPageRoute
void
>(
settings:
settings
builder: | https://docs.flutter.dev/release/breaking-changes/hero-controller-scope/index.html |
d4826cdc457c-2 | settings:
settings
builder:
BuildContext
context
return
const
Text
'first Navigator'
);
);
},
),
Navigator
onGenerateRoute:
RouteSettings
settings
return
MaterialPageRoute
void
>(
settings:
settings
builder:
BuildContext
context
return
const
Text
'Second Navigator'
);
);
},
),
],
);
); | https://docs.flutter.dev/release/breaking-changes/hero-controller-scope/index.html |
d4826cdc457c-3 | ),
],
);
);
You can fix this application by introducing your own hero controller scopes.
import
'package:flutter/material.dart'
void
main
()
runApp
MaterialApp
builder:
BuildContext
context
Widget
child
// Builds two parallel navigators.
return
Stack
children:
Widget
>[
HeroControllerScope
controller:
MaterialApp
createMaterialHeroController
(),
child:
Navigator
onGenerateRoute:
RouteSettings
settings | https://docs.flutter.dev/release/breaking-changes/hero-controller-scope/index.html |
d4826cdc457c-4 | onGenerateRoute:
RouteSettings
settings
return
MaterialPageRoute
void
>(
settings:
settings
builder:
BuildContext
context
return
const
Text
'first Navigator'
);
);
},
),
),
HeroControllerScope
controller:
MaterialApp
createMaterialHeroController
(),
child:
Navigator
onGenerateRoute:
RouteSettings
settings
return
MaterialPageRoute
void
>(
settings: | https://docs.flutter.dev/release/breaking-changes/hero-controller-scope/index.html |
d4826cdc457c-5 | void
>(
settings:
settings
builder:
BuildContext
context
return
const
Text
'second Navigator'
);
);
},
),
),
],
);
);
Timeline
Landed in version: 1.20.0
In stable release: 1.20
References
API documentation:
Navigator
HeroController
HeroControllerScope
Relevant issue:
Issue 45938
Relevant PR:
Clean up hero controller scope | https://docs.flutter.dev/release/breaking-changes/hero-controller-scope/index.html |
6feb65ef05c5-0 | Migration guide for ignoringSemantics in IgnorePointer and related classes
Summary
Context
Description of change
Migration guide
Timeline
References
Summary
IgnorePointer,
AbsorbPointer,
SliverIgnorePointer,
RenderSliverIgnorePointer,
RenderIgnorePointer, and
RenderAbsorbPointer.
Context
The ignoreSemantics was introduced as a workaround to mitigate the result of
IgnorePointer and its related widgets dropping entire semantics subtrees.
Therefore, this workaround is no longer needed.
Description of change
ignoringSemantics was removed
Migration guide
If you set this parameter to true in these widgets, consider using
ExcludeSemantics instead.
Code before migration:
IgnorePointer | https://docs.flutter.dev/release/breaking-changes/ignoringsemantics-migration/index.html |
6feb65ef05c5-1 | Code before migration:
IgnorePointer
``
ignoringSemantics:
true
child:
const
PlaceHolder
(),
);
Code after migration:
ExcludeSemantics
child:
IgnorePointer
child:
const
PlaceHolder
(),
),
);
The behavior of setting ignoringSemantics to false is no longer supported.
Consider creating your own custom widget.
/// A widget ignores pointer event but still keeps semantics actions.
class
_IgnorePointerWithSemantics
extends
SingleChildRenderObjectWidget
const
_IgnorePointerWithSemantics
({
super | https://docs.flutter.dev/release/breaking-changes/ignoringsemantics-migration/index.html |
6feb65ef05c5-2 | _IgnorePointerWithSemantics
({
super
child
});
@override
_RenderIgnorePointerWithSemantics
createRenderObject
BuildContext
context
return
_RenderIgnorePointerWithSemantics
();
class
_RenderIgnorePointerWithSemantics
extends
RenderProxyBox
_RenderIgnorePointerWithSemantics
();
@override
bool
hitTest
BoxHitTestResult
result
required
Offset
position
})
false
Timeline
Landed in version: TBD
In stable release: TBD
References | https://docs.flutter.dev/release/breaking-changes/ignoringsemantics-migration/index.html |
6feb65ef05c5-3 | References
Relevant PRs:
PR 120619: Fixes IgnorePointer and AbsorbPointer to only block user
interactions in a11y. | https://docs.flutter.dev/release/breaking-changes/ignoringsemantics-migration/index.html |
15662a3387f6-0 | ImageCache and ImageProvider changes
Summary
Description of change
containsKey change
ImageProvider changes
Migration guide
ImageCache change
ImageProvider change
Timeline
References
Summary
ImageCache now has a method called containsKey.
ImageProvider subclasses should not override resolve,
but instead should implement new methods on ImageProvider.
These changes were submitted as a single commit to the framework.
Description of change
The sections below describe the changes to containsKey
and ImageProvider.
containsKey change
Clients of the ImageCache, such as a custom ImageProvider,
may want to know if the cache is already tracking an image.
Adding the containsKey method allows callers to discover
this without calling a method like putIfAbsent,
which can trigger an undesired call to ImageProvider.load.
The default implementation checks both pending and cached
image buckets. | https://docs.flutter.dev/release/breaking-changes/image-cache-and-provider/index.html |
15662a3387f6-1 | The default implementation checks both pending and cached
image buckets.
bool
containsKey
Object
key
return
_pendingImages
key
!=
null
||
_cache
key
!=
null
ImageProvider changes
To solve this issue, resolve is now marked as non-virtual,
and two new protected methods have been added: createStream()
and resolveStreamForKey().
These methods allow subclasses to control most of the behavior
of resolve, without having to duplicate all the error handling work.
It also allows subclasses that compose ImageProviders
to be more confident that there is only one public entrypoint
to the various chained providers.
Migration guide
ImageCache change
Before migration, the code would not have an override of containsKey. | https://docs.flutter.dev/release/breaking-changes/image-cache-and-provider/index.html |
15662a3387f6-2 | Before migration, the code would not have an override of containsKey.
Code after migration:
class
MyImageCache
implements
ImageCache
@override
bool
containsKey
Object
key
// Check if your custom cache is tracking this key.
...
ImageProvider change
Code before the migration:
class
MyImageProvider
extends
ImageProvider
Object
@override
ImageStream
resolve
ImageConfiguration
configuration
// create stream
// set up error handling
// interact with ImageCache
// call obtainKey/load, etc.
...
Code after the migration: | https://docs.flutter.dev/release/breaking-changes/image-cache-and-provider/index.html |
15662a3387f6-3 | ...
Code after the migration:
class
MyImageProvider
extends
ImageProvider
Object
@override
ImageStream
createStream
ImageConfiguration
configuration
// Return stream, or use super.createStream(),
// which returns a new ImageStream.
@override
void
resolveStreamForKey
ImageConfiguration
configuration
ImageStream
stream
Object
key
ImageErrorListener
handleError
// Interact with the cache, use the key, potentially call `load`,
// and report any errors back through `handleError`.
...
Timeline | https://docs.flutter.dev/release/breaking-changes/image-cache-and-provider/index.html |
15662a3387f6-4 | ...
Timeline
Landed in version: 1.16.3
In stable release: 1.17
References
API documentation:
ImageCache
ImageProvider
ScrollAwareImageProvider
Relevant issues:
Issue #32143
Issue #44510
Issue #48305
Issue #48775
Relevant PRs:
Defer image decoding when scrolling fast #49389 | https://docs.flutter.dev/release/breaking-changes/image-cache-and-provider/index.html |
a0ac2d9ae5df-0 | Adding ImageProvider.loadBuffer
Summary
Context
Description of change
Migration guide
Timeline
References
Summary
ImageProvider now has a method called loadBuffer that functions
similarly to load, except that it decodes from an ui.ImmutableBuffer.
ui.ImmutableBuffer can now be created directly from an asset key.
The AssetBundle classes can now load an ui.ImmutableBuffer.
The PaintingBinding now has a method called
instantiateImageCodecFromBuffer, which functions similarly to
instantiateImageCodec.
ImageProvider.load is now deprecated, it will be removed in a future
release.
PaintingBinding.instantiateImageCodec is now deprecated, it will be removed
in a future release.
Context | https://docs.flutter.dev/release/breaking-changes/image-provider-load-buffer/index.html |
a0ac2d9ae5df-1 | Context
ImageProvider.loadBuffer is a new method that must be implemented in order to
load images. This API allows asset-based image loading to be performed faster
and with less memory impact on application.
Description of change
When loading asset images, previously the image provider API required multiple
copies of the compressed data. First, when opening the asset the data was
copied into the external heap and exposed to Dart as a typed data array. Then
that typed data array was eventually converted into an ui.ImmutableBuffer,
which internally copies the data into a second structure for decoding.
With the addition of ui.ImmutableBuffer.fromAsset, compressed image bytes can
be loaded directly into the structure used for decoding. Using this approach
requires changes to the byte loading pipeline of ImageProvider. This process
is also faster, because it bypasses some additional scheduling overhead of the
previous method channel based loader.
Migration guide | https://docs.flutter.dev/release/breaking-changes/image-provider-load-buffer/index.html |
a0ac2d9ae5df-2 | Migration guide
Classes that subclass ImageProvider must implement the loadBuffer method for
loading assets. Classes that delegate to or call the methods of an
ImageProvider directly must use loadBuffer instead of load.
Code before migration:
class
MyImageProvider
extends
ImageProvider
MyImageProvider
@override
ImageStreamCompleter
load
MyImageProvider
key
DecoderCallback
decode
return
MultiFrameImageStreamCompleter
codec:
_loadData
key
decode
),
);
Future
ui
Codec
_loadData
MyImageProvider
key
DecoderCallback | https://docs.flutter.dev/release/breaking-changes/image-provider-load-buffer/index.html |
a0ac2d9ae5df-3 | MyImageProvider
key
DecoderCallback
decode
async
final
Uint8List
bytes
await
bytesFromSomeApi
();
return
decode
bytes
);
class
MyDelegatingProvider
extends
ImageProvider
MyDelegatingProvider
MyDelegatingProvider
this
provider
);
final
ImageProvder
provider
@override
ImageStreamCompleter
load
MyDelegatingProvider
key
DecoderCallback
decode
return
provider
load | https://docs.flutter.dev/release/breaking-changes/image-provider-load-buffer/index.html |
a0ac2d9ae5df-4 | decode
return
provider
load
key
decode
);
Code after migration:
class
MyImageProvider
extends
ImageProvider
MyImageProvider
@override
ImageStreamCompleter
loadBuffer
MyImageProvider
key
DecoderBufferCallback
decode
return
MultiFrameImageStreamCompleter
codec:
_loadData
key
decode
),
);
Future
ui
Codec
_loadData
MyImageProvider
key
DecoderBufferCallback
decode | https://docs.flutter.dev/release/breaking-changes/image-provider-load-buffer/index.html |
a0ac2d9ae5df-5 | key
DecoderBufferCallback
decode
async
final
Uint8List
bytes
await
bytesFromSomeApi
();
final
ui
ImmutableBuffer
buffer
await
ui
ImmutableBuffer
fromUint8List
bytes
);
return
decode
buffer
);
class
MyDelegatingProvider
extends
ImageProvider
MyDelegatingProvider
MyDelegatingProvider
this
provider
);
final
ImageProvder
provider
@override | https://docs.flutter.dev/release/breaking-changes/image-provider-load-buffer/index.html |
a0ac2d9ae5df-6 | ImageProvder
provider
@override
ImageStreamCompleter
loadBuffer
MyDelegatingProvider
key
DecoderCallback
decode
return
provider
loadBuffer
key
decode
);
In both cases you might choose to keep the previous implementation of ImageProvider.load
to give users of your code time to migrate as well.
Timeline
Landed in version: 3.1.0-0.0.pre.976
In stable release: 3.3.0
References
API documentation:
ImmutableBuffer
ImageProvider
Relevant PRs:
Use immutable buffer for loading asset images | https://docs.flutter.dev/release/breaking-changes/image-provider-load-buffer/index.html |
c6bd5a99535c-0 | ImageCache large images
Summary
Context
Description of change
Migration guide
Timeline
References
Summary
The maxByteSize of the ImageCache is no longer
automatically made larger to accommodate large images.
Context
Previously, when loading images into the ImageCache
that had larger byte sizes than the ImageCache’s maxByteSize,
Flutter permanently increased the maxByteSize value
to accommodate those images.
This logic sometimes led to bloated maxByteSize values that
made working in memory-limited systems more difficult.
Description of change
The following “before” and “after” pseudocode demonstrates
the changes made to the ImageCache algorithm:
// Old logic pseudocode
void
onLoadImage
Image
image
if
image | https://docs.flutter.dev/release/breaking-changes/imagecache-large-images/index.html |
c6bd5a99535c-1 | Image
image
if
image
byteSize
_cache
maxByteSize
_cache
maxByteSize
image
byteSize
1000
_cache
add
image
);
while
_cache
count
_cache
maxCount
||
_cache
byteSize
_cache
maxByteSize
_cache
discardOldestImage
();
// New logic pseudocode
void
onLoadImage
Image
image
if
image | https://docs.flutter.dev/release/breaking-changes/imagecache-large-images/index.html |
c6bd5a99535c-2 | Image
image
if
image
byteSize
_cache
maxByteSize
_cache
add
image
);
while
_cache
count
_cache
maxCount
||
_cache
byteSize
cache
maxByteSize
cache
discardOldestImage
();
Migration guide
There might be situations where the ImageCache
is thrashing with the new logic where it wasn’t previously,
specifically if you load images that are larger than your
cache.maxByteSize value.
This can be remedied by one of the following approaches:
Increase the ImageCache.maxByteSize value
to accommodate larger images. | https://docs.flutter.dev/release/breaking-changes/imagecache-large-images/index.html |
c6bd5a99535c-3 | Increase the ImageCache.maxByteSize value
to accommodate larger images.
Adjust your image loading logic to guarantee that
the images fit nicely into the ImageCache.maxByteSize
value of your choosing.
Subclass ImageCache, implement your desired logic,
and create a new binding that serves up your subclass
of ImageCache (see the image_cache.dart source).
Timeline
The old algorithm is no longer supported.
Landed in version: 1.16.3
In stable release: 1.17
References
API documentation:
ImageCache
Relevant issue:
Issue 45643
Relevant PR:
Stopped increasing the cache size to accommodate large images
Other:
ImageCache source | https://docs.flutter.dev/release/breaking-changes/imagecache-large-images/index.html |
1028d6c3d819-0 | Breaking changes
Not yet released to stable
Released in Flutter 3.7
Released in Flutter 3.3
Released in Flutter 3
Released in Flutter 2.10
Released in Flutter 2.5
Reverted change in 2.2
Released in Flutter 2.2
Released in Flutter 2
Released in Flutter 1.22
Released in Flutter 1.20
Released in Flutter 1.17
As described in the breaking change policy,
on occasion we publish guides
for migrating code across a breaking change.
To be notified about future breaking changes,
join the groups Flutter announce and Dart announce.
The following guides are available. They are sorted by
release, and listed in alphabetical order: | https://docs.flutter.dev/release/breaking-changes/index.html |
1028d6c3d819-1 | Not yet released to stable
Deprecated API removed after v3.7
Removed ignoringSemantics
Released in Flutter 3.7
Deprecated API removed after v3.3
iOS FlutterViewController splashScreenView made nullable
Migrate of to non-nullable return values, and add maybeOf
Removed RouteSettings.copyWith
ThemeData’s toggleableActiveColor property has been deprecated
A new way to customize context menus
Released in Flutter 3.3
Adding ImageProvider.loadBuffer
Default PrimaryScrollController on Desktop
Trackpad gestures can trigger GestureRecognizer
Released in Flutter 3
Deprecated API removed after v2.10
Migrate useDeleteButtonTooltip to deleteButtonTooltipMessage of Chips | https://docs.flutter.dev/release/breaking-changes/index.html |
1028d6c3d819-2 | 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 | https://docs.flutter.dev/release/breaking-changes/index.html |
1028d6c3d819-3 | Using HTML slots to render platform views in the web
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 (proposed)
Released in Flutter 2.2
Default Scrollbars on Desktop
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 | https://docs.flutter.dev/release/breaking-changes/index.html |
1028d6c3d819-4 | 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 | https://docs.flutter.dev/release/breaking-changes/index.html |
1028d6c3d819-5 | 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 | https://docs.flutter.dev/release/breaking-changes/index.html |
1028d6c3d819-6 | 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 | https://docs.flutter.dev/release/breaking-changes/index.html |
641269b4c743-0 | iOS FlutterViewController splashScreenView made nullable
Summary
Context
Description of change
Migration guide
Timeline
References
Summary
The FlutterViewController property splashScreenView has been changed from nonnull to nullable.
Old declaration of splashScreenView:
New declaration of splashScreenView:
Context
Prior to this change, on iOS the splashScreenView property returned nil when no splash screen view
was set, and setting the property to nil removed the splash screen view. However, the
splashScreenView API was incorrectly marked nonnull. This property is most often used
when transitioning to Flutter views in iOS add-to-app scenarios.
Description of change
While it was possible in Objective-C to work around the incorrect nonnull annotation by setting
splashScreenView to a nil UIView, in Swift this caused a compilation error: | https://docs.flutter.dev/release/breaking-changes/ios-flutterviewcontroller-splashscreenview-nullable/index.html |
641269b4c743-1 | PR #34743 updates the property attribute to nullable. It can return nil and can be set to nil to remove the view in both Objective-C and Swift.
Migration guide
If splashScreenView is stored in a UIView variable in Swift, update to an optional type UIView?.
Code before migration:
var
splashScreenView
UIView
()
var
flutterEngine
FlutterEngine
name
"my flutter engine"
let
flutterViewController
FlutterViewController
engine
flutterEngine
nibName
nil
bundle
nil
splashScreenView
flutterViewController
splashScreenView | https://docs.flutter.dev/release/breaking-changes/ios-flutterviewcontroller-splashscreenview-nullable/index.html |
641269b4c743-2 | flutterViewController
splashScreenView
// compilation error: Value of optional type 'UIView?' must be unwrapped to a value of type 'UIView'
Code after migration:
var
splashScreenView
UIView
UIView
()
var
flutterEngine
FlutterEngine
name
"my flutter engine"
let
flutterViewController
FlutterViewController
engine
flutterEngine
nibName
nil
bundle
nil
let
splashScreenView
flutterViewController
splashScreenView
// compiles successfully
if
let
splashScreenView
splashScreenView | https://docs.flutter.dev/release/breaking-changes/ios-flutterviewcontroller-splashscreenview-nullable/index.html |
641269b4c743-3 | let
splashScreenView
splashScreenView
Timeline
In stable release: 3.7
References
Relevant PR:
Make splashScreenView of FlutterViewController nullable | https://docs.flutter.dev/release/breaking-changes/ios-flutterviewcontroller-splashscreenview-nullable/index.html |
10d90dd8529a-0 | Required Kotlin version
Summary
Context
Description of change
Migration guide
Timeline
References
Summary
To build a Flutter app for Android, Kotlin 1.5.31 or greater is required.
If your app uses a lower version,
you will receive the following error message:
Context
Flutter added support for foldable devices on Android.
This required adding an AndroidX dependency to the Flutter embedding that
requires apps to use Kotlin 1.5.31 or greater.
Description of change
A Flutter app compiled for Android now includes the Gradle dependency
androidx.window:window-java.
Migration guide
Open <app-src>/android/build.gradle, and change ext.kotlin_version:
buildscript { | https://docs.flutter.dev/release/breaking-changes/kotlin-version/index.html |
10d90dd8529a-1 | buildscript {
ext.kotlin_version = '1.3.50'
+ ext.kotlin_version = '1.5.31'
Timeline
Landed in version: v2.9.0 beta
In stable release: 2.10
References
Relevant PRs:
PR 29585: Display Features support | https://docs.flutter.dev/release/breaking-changes/kotlin-version/index.html |
85f623e53f79-0 | LayoutBuilder optimization
Summary
Context
Description of change
Migration guide
Timeline
References
Summary
This guide explains how to migrate Flutter applications after the LayoutBuilder
optimization.
Context
LayoutBuilder and SliverLayoutBuilder call the builder function
more often than necessary to fulfill their primary goal of allowing apps to adapt
their widget structure to parent layout constraints. This has led to less
efficient and jankier applications because widgets are rebuilt unnecessarily.
This transitively affects OrientationBuilder as well.
In order to improve app performance the LayoutBuilder optimization was made,
which results in calling the builder function less often.
Apps that rely on this function to be called with a certain frequency may break.
The app may exhibit some combination of the following symptoms: | https://docs.flutter.dev/release/breaking-changes/layout-builder-optimization/index.html |
85f623e53f79-1 | The builder function is not called when it would before the upgrade to the
Flutter version that introduced the optimization.
The UI of a widget is missing.
The UI of a widget is not updating.
Description of change
Prior to the optimization the builder function passed to LayoutBuilder or
SliverLayoutBuilder was called when any one of the following happened:
LayoutBuilder is rebuilt due to a widget configuration change (this typically
happens when the widget that uses LayoutBuilder rebuilds due to setState,
didUpdateWidget or didChangeDependencies).
LayoutBuilder is laid out and receives layout constraints from its parent
that are different from the last received constraints.
LayoutBuilder is laid out and receives layout constraints from its parent
that are the same as the constraints received last time.
After the optimization the builder function is no longer called in the latter
case. If the constraints are the same and the widget configuration did not
change, the builder function is not called. | https://docs.flutter.dev/release/breaking-changes/layout-builder-optimization/index.html |
85f623e53f79-2 | Your app can break if it relies on the relayout to cause the rebuilding of the
LayoutBuilder rather than on an explicit call to setState. This usually
happens by accident. You meant to add setState, but you forgot because the app
continued functioning as you wanted, and therefore nothing reminded you to add
it.
Migration guide
Look for usages of LayoutBuilder and SliverLayoutBuilder and make sure to
call setState any time the widget state changes.
Code before migration (note the missing setState inside the onPressed
callback):
import
'package:flutter/material.dart'
void
main
()
runApp
MyApp
());
class
MyApp
extends
StatelessWidget
@override
Widget
build
BuildContext | https://docs.flutter.dev/release/breaking-changes/layout-builder-optimization/index.html |
85f623e53f79-3 | Widget
build
BuildContext
context
return
MaterialApp
title:
'Flutter Demo'
theme:
ThemeData
primarySwatch:
Colors
blue
),
home:
Counter
(),
);
class
Counter
extends
StatefulWidget
Counter
({
Key
key
})
super
key:
key
);
@override
_CounterState
createState
()
_CounterState
(); | https://docs.flutter.dev/release/breaking-changes/layout-builder-optimization/index.html |
85f623e53f79-4 | ()
_CounterState
();
class
_CounterState
extends
State
Counter
int
_counter
@override
Widget
build
BuildContext
context
return
Center
child:
Container
child:
LayoutBuilder
builder:
BuildContext
context
BoxConstraints
constraints
return
_ResizingBox
TextButton
onPressed:
()
_counter
++
},
child:
Text
'Increment Counter' | https://docs.flutter.dev/release/breaking-changes/layout-builder-optimization/index.html |
85f623e53f79-5 | child:
Text
'Increment Counter'
)),
Text
_counter
toString
()),
);
},
),
));
class
_ResizingBox
extends
StatefulWidget
_ResizingBox
this
child1
this
child2
);
final
Widget
child1
final
Widget
child2
@override
State
StatefulWidget
createState
()
_ResizingBoxState
();
class | https://docs.flutter.dev/release/breaking-changes/layout-builder-optimization/index.html |
85f623e53f79-6 | _ResizingBoxState
();
class
_ResizingBoxState
extends
State
_ResizingBox
with
SingleTickerProviderStateMixin
Animation
animation
@override
void
initState
()
super
initState
();
animation
AnimationController
vsync:
this
duration:
const
Duration
minutes:
),
forward
()
addListener
(()
setState
(()
{});
});
@override | https://docs.flutter.dev/release/breaking-changes/layout-builder-optimization/index.html |
85f623e53f79-7 | {});
});
@override
Widget
build
BuildContext
context
return
Row
mainAxisSize:
MainAxisSize
min
children:
SizedBox
width:
100
animation
value
100
child:
widget
child1
),
SizedBox
width:
100
animation
value
100
child:
widget
child2
),
],
); | https://docs.flutter.dev/release/breaking-changes/layout-builder-optimization/index.html |
85f623e53f79-8 | ),
],
);
Code after migration (setState added to onPressed):
import
'package:flutter/material.dart'
void
main
()
runApp
MyApp
());
class
MyApp
extends
StatelessWidget
@override
Widget
build
BuildContext
context
return
MaterialApp
title:
'Flutter Demo'
theme:
ThemeData
primarySwatch:
Colors
blue
),
home:
Counter
(),
); | https://docs.flutter.dev/release/breaking-changes/layout-builder-optimization/index.html |
85f623e53f79-9 | Counter
(),
);
class
Counter
extends
StatefulWidget
Counter
({
Key
key
})
super
key:
key
);
@override
_CounterState
createState
()
_CounterState
();
class
_CounterState
extends
State
Counter
int
_counter
@override
Widget
build
BuildContext
context
return
Center
child:
Container | https://docs.flutter.dev/release/breaking-changes/layout-builder-optimization/index.html |
85f623e53f79-10 | Center
child:
Container
child:
LayoutBuilder
builder:
BuildContext
context
BoxConstraints
constraints
return
_ResizingBox
TextButton
onPressed:
()
setState
(()
_counter
++
});
},
child:
Text
'Increment Counter'
)),
Text
_counter
toString
()),
);
},
),
));
class
_ResizingBox
extends
StatefulWidget | https://docs.flutter.dev/release/breaking-changes/layout-builder-optimization/index.html |
85f623e53f79-11 | _ResizingBox
extends
StatefulWidget
_ResizingBox
this
child1
this
child2
);
final
Widget
child1
final
Widget
child2
@override
State
StatefulWidget
createState
()
_ResizingBoxState
();
class
_ResizingBoxState
extends
State
_ResizingBox
with
SingleTickerProviderStateMixin
Animation
animation
@override
void
initState
()
super | https://docs.flutter.dev/release/breaking-changes/layout-builder-optimization/index.html |
85f623e53f79-12 | initState
()
super
initState
();
animation
AnimationController
vsync:
this
duration:
const
Duration
minutes:
),
forward
()
addListener
(()
setState
(()
{});
});
@override
Widget
build
BuildContext
context
return
Row
mainAxisSize:
MainAxisSize
min
children:
SizedBox
width:
100
animation | https://docs.flutter.dev/release/breaking-changes/layout-builder-optimization/index.html |
85f623e53f79-13 | width:
100
animation
value
100
child:
widget
child1
),
SizedBox
width:
100
animation
value
100
child:
widget
child2
),
],
);
Watch for usages of Animation and LayoutBuilder in the same widget.
Animations have internal mutable state that changes on every frame. If the
logic of your builder function depends on the value of the animation, it may
require a setState to update in tandem with the animation. To do that, add an
animation listener that calls setState, like so:
Animation
animation
create
animation | https://docs.flutter.dev/release/breaking-changes/layout-builder-optimization/index.html |
85f623e53f79-14 | animation
create
animation
animation
addListener
(()
setState
(()
// Intentionally empty. The state is inside the animation object.
});
});
Timeline
This change was released in Flutter v1.20.0.
References
API documentation:
LayoutBuilder
SliverLayoutBuilder
Relevant issues:
Issue 6469
Relevant PRs:
LayoutBuilder: skip calling builder when constraints are the same | https://docs.flutter.dev/release/breaking-changes/layout-builder-optimization/index.html |
57919600fc91-0 | Material Chip button semantics
Summary
Context
Description of change
Migration guide
Timeline
References
Summary
Flutter now applies the semantic label of button to
all interactive Material Chips for accessibility purposes.
Context
Interactive Material Chips (namely ActionChip,
ChoiceChip, FilterChip, and InputChip)
are now semantically marked as being buttons.
However, the non-interactive information Chip is not. | https://docs.flutter.dev/release/breaking-changes/material-chip-button-semantics/index.html |
57919600fc91-1 | Marking Chips as buttons helps accessibility tools,
search engines, and other semantic analysis software
understand the meaning of an app. For example, it
allows screen readers (such as TalkBack on Android
and VoiceOver on iOS) to announce a tappable Chip
as a “button”, which can assist users in navigating
your app. Prior to this change, users of accessibility
tools may have had a subpar experience,
unless you implemented a workaround by manually adding the
missing semantics to the Chip widgets in your app.
Description of change
The outermost Semantics widget that wraps all
Chip classes to describe their semantic properties
is modified.
The following changes apply to
ActionChip, ChoiceChip, FilterChip,
and InputChip:
The button property
is set to true.
The enabled property
reflects whether the Chip is currently tappable
(by having a callback set). | https://docs.flutter.dev/release/breaking-changes/material-chip-button-semantics/index.html |
57919600fc91-2 | These property changes bring interactive Chips’ semantic
behavior in-line with that of other Material Buttons.
For the non-interactive information Chip:
The button property
is set to false.
The enabled property
is set to null.
Migration guide
The following snippets use InputChip as an example,
but the same process applies to ActionChip,
ChoiceChip, and FilterChip as well.
Case 1: Remove the Semantics widget.
Code before migration:
Widget
myInputChip
InputChip
onPressed:
()
{},
label:
Semantics
button:
true
child:
Text
'My Input Chip'
),
), | https://docs.flutter.dev/release/breaking-changes/material-chip-button-semantics/index.html |
57919600fc91-3 | 'My Input Chip'
),
),
);
Code after migration:
Widget
myInputChip
InputChip
onPressed:
()
{},
label:
Text
'My Input Chip'
),
);
Case 2: Remove button:true from the Semantics widget.
Code before migration:
Widget
myInputChip
InputChip
onPressed:
()
{},
label:
Semantics
button:
true
hint:
'Example Hint'
child:
Text | https://docs.flutter.dev/release/breaking-changes/material-chip-button-semantics/index.html |
57919600fc91-4 | 'Example Hint'
child:
Text
'My Input Chip'
),
),
);
Code after migration:
Widget
myInputChip
InputChip
onPressed:
()
{},
label:
Semantics
hint:
'Example Hint'
child:
Text
'My Input Chip'
),
),
);
Timeline
Landed in version: 1.23.0-7.0.pre
In stable release: 2.0.0
References
API documentation:
ActionChip
Chip | https://docs.flutter.dev/release/breaking-changes/material-chip-button-semantics/index.html |
57919600fc91-5 | API documentation:
ActionChip
Chip
ChoiceChip
FilterChip
InputChip
Material Buttons
Material Chips
Semantics
SemanticsProperties.button
SemanticsProperties.enabled
Relevant issue:
Issue 58010: InputChip doesn’t announce any
action for a11y on iOS
Relevant PRs:
PR 60141: Tweaking Material Chip a11y semantics
to match buttons
PR 60645: Revert “Tweaking Material Chip a11y
semantics to match buttons (#60141)”
PR 61048: Re-land “Tweaking Material Chip a11y semantics to match buttons (#60141)” | https://docs.flutter.dev/release/breaking-changes/material-chip-button-semantics/index.html |
096a1f8af131-0 | Transition of platform channel test interfaces to flutter_test package
Summary
Context
Description of change
Migration guide
Timeline
References
Summary
Context
As part of a refactoring of the low-level plugin
communications architecture, we have moved from the
previous onPlatformMessage/handlePlatformMessage
logic to a per-channel buffering system implemented in
the engine in the ChannelBuffers class.
To maintain compatibility with existing code,
the existing BinaryMessenger.setMessageHandler API
has been refactored to use the new ChannelBuffers API.
One difference between the ChannelBuffers API and the
previous API is that the new API is more consistent in
its approach to asynchrony. As a side-effect,
the APIs around message passing are now entirely asynchronous. | https://docs.flutter.dev/release/breaking-changes/mock-platform-channels/index.html |
096a1f8af131-1 | This posed a problem for the implementation of the legacy
testing APIs which, for historical reasons,
were previously in the flutter package.
Since they relied on the underlying logic being partly synchronous,
they required refactoring.
To avoid adding even more test logic into the flutter package,
a decision was made to move this logic to the flutter_test package.
Description of change
Specifically, the following APIs were affected:
BinaryMessenger.checkMessageHandler: Obsolete.
BinaryMessenger.setMockMessageHandler: Replaced by
TestDefaultBinaryMessenger.setMockMessageHandler.
BinaryMessenger.checkMockMessageHandler: Replaced
by TestDefaultBinaryMessenger.checkMockMessageHandler.
BasicMessageChannel.setMockMessageHandler: Replaced
by TestDefaultBinaryMessenger.setMockDecodedMessageHandler.
MethodChannel.checkMethodCallHandler: Obsolete. | https://docs.flutter.dev/release/breaking-changes/mock-platform-channels/index.html |
096a1f8af131-2 | MethodChannel.checkMethodCallHandler: Obsolete.
MethodChannel.setMockMethodCallHandler: Replaced by
TestDefaultBinaryMessenger.setMockMethodCallHandler.
MethodChannel.checkMockMethodCallHandler: Replaced
by TestDefaultBinaryMessenger.checkMockMessageHandler.
These replacements are only available to code using the
new TestDefaultBinaryMessengerBinding
(such as any code using testWidgets in a flutter_test test).
There is no replacement for production code that was using
these APIs, as they were not intended for production code use.
Tests using checkMessageHandler have no equivalent in the
new API, since message handler registration is handled
directly by the ChannelBuffers object, which does not
expose the currently registered listener for a channel.
(Tests verifying handler registration appear to be rare.)
Code that needs migrating may see errors such as the following: | https://docs.flutter.dev/release/breaking-changes/mock-platform-channels/index.html |
096a1f8af131-3 | Code that needs migrating may see errors such as the following:
In addition, the onPlatformMessage callback,
which previously was hooked by the framework to
receive messages from plugins, is no longer used
(and will be removed in due course). As a result,
calling this callback to inject messages into the
framework no longer has an effect.
Migration guide
The flutter_test package provides some shims so that
uses of the obsolete setMock... and checkMock...
methods will continue to work.
Tests that previously did not import
package:flutter_test/flutter_test.dart can
do so to enable these shims;
this should be sufficient to migrate most code.
These shim APIs are deprecated, however. Instead,
in code using WidgetTester (for example, using testWidgets),
it is recommended to use the following patterns to
replace calls to those methods
(where tester is the WidgetTester instance):
// old code
ServicesBinding | https://docs.flutter.dev/release/breaking-changes/mock-platform-channels/index.html |
096a1f8af131-4 | // old code
ServicesBinding
defaultBinaryMessenger
setMockMessageHandler
(...);
ServicesBinding
defaultBinaryMessenger
checkMockMessageHandler
(...);
// new code
tester
binding
defaultBinaryMessenger
setMockMessageHandler
(...);
tester
binding
defaultBinaryMessenger
checkMockMessageHandler
(...);
// old code
myChannel
setMockMessageHandler
(...);
myChannel
checkMockMessageHandler
(...);
// new code
tester
binding
defaultBinaryMessenger | https://docs.flutter.dev/release/breaking-changes/mock-platform-channels/index.html |
096a1f8af131-5 | tester
binding
defaultBinaryMessenger
setMockDecodedMessageHandler
myChannel
...);
tester
binding
defaultBinaryMessenger
checkMockMessageHandler
myChannel
...);
// old code
myMethodChannel
setMockMethodCallHandler
(...);
myMethodChannel
checkMockMethodCallHandler
(...);
// new code
tester
binding
defaultBinaryMessenger
setMockMethodCallHandler
myMethodChannel
...);
tester
binding
defaultBinaryMessenger
checkMockMessageHandler
myMethodChannel | https://docs.flutter.dev/release/breaking-changes/mock-platform-channels/index.html |
096a1f8af131-6 | checkMockMessageHandler
myMethodChannel
...);
Tests that use package:test and test()
can be changed to use package:flutter_test and testWidgets()
to get access to a WidgetTester.
Code that does not have access to a WidgetTester can refer to
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger
instead of tester.binding.defaultBinaryMessenger.
Tests that do not use the default test widgets binding
(AutomatedTestWidgetsFlutterBinding,
which is initialized by testWidgets) can mix the
TestDefaultBinaryMessengerBinding mixin into their
binding to get the same results.
Tests that manipulate onPlatformMessage will no longer
function as designed. To send mock messages to the framework,
consider using ChannelBuffers.push.
There is no mechanism to intercept messages from the plugins
and forward them to the framework in the new API.
If your use case requires such a mechanism, please file a bug. | https://docs.flutter.dev/release/breaking-changes/mock-platform-channels/index.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.