id
stringlengths 14
17
| text
stringlengths 23
1.11k
| source
stringlengths 35
114
|
---|---|---|
11c5cb0899f8-1 | Description of change
We added additional semantics node above both the overlay entries of modal routes.
Those semantics nodes denote the semantics traverse order of these two overlay entries.
This also changed the structure of semantics tree.
Migration guide
If your tests start failing due to semantics tree changes after the update,
you can migrate your code by expecting a new node on above of the modal route
overlay entries.
Code before migration:
import
'dart:ui'
import
'package:flutter_test/flutter_test.dart'
import
'package:flutter/rendering.dart'
import
'package:flutter/material.dart'
void
main
()
testWidgets
'example test'
WidgetTester
tester
async | https://docs.flutter.dev/release/breaking-changes/modal-router-semantics-order/index.html |
11c5cb0899f8-2 | WidgetTester
tester
async
final
SemanticsHandle
handle
tester
binding
pipelineOwner
ensureSemantics
();
// Build our app and trigger a frame.
await
tester
pumpWidget
MaterialApp
home:
Scaffold
body:
Text
'test'
))));
final
SemanticsNode
root
tester
binding
pipelineOwner
semanticsOwner
rootSemanticsNode
final
SemanticsNode
firstNode
getChild
root | https://docs.flutter.dev/release/breaking-changes/modal-router-semantics-order/index.html |
11c5cb0899f8-3 | firstNode
getChild
root
);
expect
firstNode
rect
Rect
fromLTRB
0.0
0.0
800.0
600.0
));
// Fixes the test by expecting an additional node above the scope route.
final
SemanticsNode
secondNode
getChild
firstNode
);
expect
secondNode
rect
Rect
fromLTRB
0.0
0.0
800.0
600.0
)); | https://docs.flutter.dev/release/breaking-changes/modal-router-semantics-order/index.html |
11c5cb0899f8-4 | 600.0
));
final
SemanticsNode
thirdNode
getChild
secondNode
);
expect
thirdNode
rect
Rect
fromLTRB
0.0
0.0
800.0
600.0
));
expect
thirdNode
hasFlag
SemanticsFlag
scopesRoute
),
true
);
final
SemanticsNode
forthNode
getChild
thirdNode
);
expect
forthNode
rect | https://docs.flutter.dev/release/breaking-changes/modal-router-semantics-order/index.html |
11c5cb0899f8-5 | expect
forthNode
rect
Rect
fromLTRB
0.0
0.0
56.0
14.0
));
expect
forthNode
label
'test'
);
handle
dispose
();
});
SemanticsNode
getChild
SemanticsNode
node
SemanticsNode
child
bool
visiter
SemanticsNode
target
child
target
return
false
node
visitChildren
visiter | https://docs.flutter.dev/release/breaking-changes/modal-router-semantics-order/index.html |
11c5cb0899f8-6 | node
visitChildren
visiter
);
return
child
Code after migration:
import
'dart:ui'
import
'package:flutter_test/flutter_test.dart'
import
'package:flutter/rendering.dart'
import
'package:flutter/material.dart'
void
main
()
testWidgets
'example test'
WidgetTester
tester
async
final
SemanticsHandle
handle
tester
binding
pipelineOwner
ensureSemantics
();
// Build our app and trigger a frame. | https://docs.flutter.dev/release/breaking-changes/modal-router-semantics-order/index.html |
11c5cb0899f8-7 | ();
// Build our app and trigger a frame.
await
tester
pumpWidget
MaterialApp
home:
Scaffold
body:
Text
'test'
))));
final
SemanticsNode
root
tester
binding
pipelineOwner
semanticsOwner
rootSemanticsNode
final
SemanticsNode
firstNode
getChild
root
);
expect
firstNode
rect
Rect
fromLTRB
0.0
0.0
800.0 | https://docs.flutter.dev/release/breaking-changes/modal-router-semantics-order/index.html |
11c5cb0899f8-8 | 0.0
800.0
600.0
));
// Fixes the test by expecting an additional node above the scope route.
final
SemanticsNode
secondNode
getChild
firstNode
);
expect
secondNode
rect
Rect
fromLTRB
0.0
0.0
800.0
600.0
));
final
SemanticsNode
thirdNode
getChild
secondNode
);
expect
thirdNode
rect
Rect | https://docs.flutter.dev/release/breaking-changes/modal-router-semantics-order/index.html |
11c5cb0899f8-9 | thirdNode
rect
Rect
fromLTRB
0.0
0.0
800.0
600.0
));
expect
thirdNode
hasFlag
SemanticsFlag
scopesRoute
),
true
);
final
SemanticsNode
forthNode
getChild
thirdNode
);
expect
forthNode
rect
Rect
fromLTRB
0.0
0.0
56.0
14.0
)); | https://docs.flutter.dev/release/breaking-changes/modal-router-semantics-order/index.html |
11c5cb0899f8-10 | 14.0
));
expect
forthNode
label
'test'
);
handle
dispose
();
});
SemanticsNode
getChild
SemanticsNode
node
SemanticsNode
child
bool
visiter
SemanticsNode
target
child
target
return
false
node
visitChildren
visiter
);
return
child
Timeline
Landed in version: 1.19.0
In stable release: 1.20
References
API documentation: | https://docs.flutter.dev/release/breaking-changes/modal-router-semantics-order/index.html |
11c5cb0899f8-11 | References
API documentation:
ModalRoute
OverlayEntry
Relevant issue:
Issue 46625
Relevant PRs:
PR 59290 | https://docs.flutter.dev/release/breaking-changes/modal-router-semantics-order/index.html |
fd83d326824a-0 | The RenderEditable needs to be laid out before hit testing
Summary
Context
Migration guide
Timeline
References
Summary
Instances of RenderEditable must be laid out before processing hit
testing. Trying to hit-test a RenderEditable object before layout
results in an assertion such as the following:
Failed assertion: line 123 pos 45: '!debugNeedsLayout': is not true.
Context
To support gesture recognizers in selectable text, the
RenderEditable requires the layout information for its
text spans to determine which text span receives the
pointer event. (Before this change, RenderEditable objects
didn’t take their text into account when evaluating hit tests.)
To implement this, layout was made a prerequisite for performing
hit testing on a RenderEditable object. | https://docs.flutter.dev/release/breaking-changes/rendereditable-layout-before-hit-test/index.html |
fd83d326824a-1 | In practice, this is rarely an issue. The widget library
ensures that layout is performed before any hit test on all
render objects. This problem is only likely to be seen in
code that directly interacts with render objects, for
example in tests of custom render objects.
Migration guide
If you see the '!debugNeedsLayout': is not true
assertion error while hit testing the RenderEditable,
lay out the RenderEditable before doing so.
Code before migration:
import
'package:flutter/rendering.dart'
import
'package:flutter_test/flutter_test.dart'
import
'package:flutter/material.dart'
void
main
()
test
'attach and detach correctly handle gesture'
()
final
RenderEditable
editable | https://docs.flutter.dev/release/breaking-changes/rendereditable-layout-before-hit-test/index.html |
fd83d326824a-2 | final
RenderEditable
editable
RenderEditable
textDirection:
TextDirection
ltr
offset:
ViewportOffset
zero
(),
textSelectionDelegate:
FakeEditableTextState
(),
startHandleLayerLink:
LayerLink
(),
endHandleLayerLink:
LayerLink
(),
);
final
PipelineOwner
owner
PipelineOwner
onNeedVisualUpdate:
()
{});
editable
attach
owner
);
// This throws an assertion error because | https://docs.flutter.dev/release/breaking-changes/rendereditable-layout-before-hit-test/index.html |
fd83d326824a-3 | owner
);
// This throws an assertion error because
// the RenderEditable hasn't been laid out.
editable
handleEvent
const
PointerDownEvent
(),
BoxHitTestEntry
editable
const
Offset
10
10
)));
editable
detach
();
});
class
FakeEditableTextState
extends
TextSelectionDelegate
@override
TextEditingValue
textEditingValue
@override
void
hideToolbar
()
{}
@override | https://docs.flutter.dev/release/breaking-changes/rendereditable-layout-before-hit-test/index.html |
fd83d326824a-4 | ()
{}
@override
void
bringIntoView
TextPosition
position
{}
Code after migration:
import
'package:flutter/rendering.dart'
import
'package:flutter_test/flutter_test.dart'
import
'package:flutter/material.dart'
void
main
()
test
'attach and detach correctly handle gesture'
()
final
RenderEditable
editable
RenderEditable
textDirection:
TextDirection
ltr
offset:
ViewportOffset
zero
(), | https://docs.flutter.dev/release/breaking-changes/rendereditable-layout-before-hit-test/index.html |
fd83d326824a-5 | ViewportOffset
zero
(),
textSelectionDelegate:
FakeEditableTextState
(),
startHandleLayerLink:
LayerLink
(),
endHandleLayerLink:
LayerLink
(),
);
// Lay out the RenderEditable first.
editable
layout
BoxConstraints
loose
const
Size
1000.0
1000.0
)));
final
PipelineOwner
owner
PipelineOwner
onNeedVisualUpdate:
()
{});
editable
attach | https://docs.flutter.dev/release/breaking-changes/rendereditable-layout-before-hit-test/index.html |
fd83d326824a-6 | {});
editable
attach
owner
);
editable
handleEvent
const
PointerDownEvent
(),
BoxHitTestEntry
editable
const
Offset
10
10
)));
editable
detach
();
});
class
FakeEditableTextState
extends
TextSelectionDelegate
@override
TextEditingValue
textEditingValue
@override
void
hideToolbar
()
{}
@override
void | https://docs.flutter.dev/release/breaking-changes/rendereditable-layout-before-hit-test/index.html |
fd83d326824a-7 | {}
@override
void
bringIntoView
TextPosition
position
{}
Timeline
Landed in version: 1.18.0
In stable release: 1.20
References
API documentation:
RenderEditable
Relevant issue:
Issue 43494: SelectableText.rich used along with
TapGestureRecognizer isn’t working
Relevant PR:
PR 54479: Enable gesture recognizer in selectable rich text | https://docs.flutter.dev/release/breaking-changes/rendereditable-layout-before-hit-test/index.html |
ce6feb62785e-0 | Notable Rendering and Layout Changes after v3.7
Changes
(Only Affects Tests) FlutterTest is now the default test font
Changes
This section lists the notable non-API breaking changes.
(Only Affects Tests) FlutterTest is now the default test font
The FlutterTest font produces more precise font and glyph metrics than Ahem,
and the metrics are generally font-engine agnostic. See the Flutter Test Fonts
wiki page for more details about the test font.
Differences
The FlutterTest font looks almost identical to the old default Ahem: the
glyph for most characters is a box that fills the em square. The notable
differences between the FlutterTest font and Ahem font are:
1. Different baseline location | https://docs.flutter.dev/release/breaking-changes/rendering-changes/index.html |
ce6feb62785e-1 | 1. Different baseline location
The FlutterTest font’s ascent and descent are 0.75 em and 0.25 em, while
Ahem’s are 0.8 em and 0.2 em, respectively.
2. Different decoration position
The underline location is slightly higher in FlutterTest than Ahem.
TextDecoration.overline/
TextDecoration.lineThrough/
TextDecoration.underline
positions for each line.
| Before (
3. The glyph used for unmapped characters are slightly different
Unmapped characters are rendered as hollow boxes in both fonts, with a slight
difference:
| Before (Ahem) | After | Diff |
| :—: | :—: | :—: |
| | | |
References
Relevant PRs: | https://docs.flutter.dev/release/breaking-changes/rendering-changes/index.html |
ce6feb62785e-2 | References
Relevant PRs:
the FlutterTest font was added in: Add new test font
the FlutterTest font was made the default in: Make FlutterTest the default test font
Wiki Page:
Flutter Test Fonts | https://docs.flutter.dev/release/breaking-changes/rendering-changes/index.html |
f1370cf8d0bd-0 | Route and Navigator Refactoring
Summary
Context
Description of change
Migration guide
Timeline
References
Summary
Context
We refactored the navigator APIs to prepare for the new page API
and the introduction of the Router widget as outlined in
the Router design document.
This refactoring introduced some function signature changes
in order to make the existing navigator APIs continue to work
with the new page API.
Description of change
The boolean return value of Navigator.pop() was not well
defined, and the user could achieve the same result by calling
Navigator.canPop().
Since the API for Navigator.canPop() was better defined,
we simplified Navigator.pop() to not return a boolean value. | https://docs.flutter.dev/release/breaking-changes/route-navigator-refactoring/index.html |
f1370cf8d0bd-1 | On the other hand, the navigator requires the ability
to manually rearrange entries in the overlay to allow
the user to change the route history in the new API.
We changed it so that the route only creates and destroys
its overlay entries, while the navigator inserts or
removes overlay entries from the overlay.
We also removed the insertionPoint argument of
Route.install() because it was obsolete after the change.
Finally, we removed the isInitialRoute property from
RouteSetting as part of refactoring, and provided the
onGenerateInitialRoutes API for full control of
initial routes generation.
Migration guide
Case 1: An app depends on pop() returning a boolean value.
TextField
onTap:
()
if
Navigator
pop
context
))
print
There
still
is | https://docs.flutter.dev/release/breaking-changes/route-navigator-refactoring/index.html |
f1370cf8d0bd-2 | print
There
still
is
at
least
one
route
after
pop
);
else
print
Oops
No
more
routes
);
You could use Navigator.canPop() in combination with
Navigator.pop() to achieve the same result.
TextField
onTap:
()
if
Navigator
canPop
context
))
print
There
still
is
at
least
one
route
after
pop | https://docs.flutter.dev/release/breaking-changes/route-navigator-refactoring/index.html |
f1370cf8d0bd-3 | one
route
after
pop
);
else
print
Oops
No
more
routes
);
// Our navigator pops the route anyway.
Navigator
pop
context
);
Case 2: An app generates routes based on isInitialRoute.
MaterialApp
onGenerateRoute:
RouteSetting
setting
if
setting
isInitialRoute
return
FakeSplashRoute
();
else
return
RealRoute
setting
); | https://docs.flutter.dev/release/breaking-changes/route-navigator-refactoring/index.html |
f1370cf8d0bd-4 | RealRoute
setting
);
There are different ways to migrate this change.
One way is to set the initial route name
to a fixed value and generate a specific route
(FakeSplashRoute in the above example)
for the route name.
MaterialApp
initialRouteName:
fakeSplash
onGenerateRoute:
RouteSetting
setting
if
setting
name
==
fakeSplash
return
FakeSplashRoute
();
else
return
RealRoute
setting
);
If there is a more complicated use case,
you can use the new API, onGenerateInitialRoutes,
in MaterialApp or CupertinoApp.
MaterialApp | https://docs.flutter.dev/release/breaking-changes/route-navigator-refactoring/index.html |
f1370cf8d0bd-5 | MaterialApp
onGenerateRoute:
RouteSetting
setting
return
RealRoute
setting
);
},
onGenerateInitialRoutes:
String
initialRouteName
return
Route
>[
FakeSplashRoute
()];
Timeline
Landed in version: 1.16.3
In stable release: 1.17
References
Design doc:
Router
API documentation:
Route
Route.install
RouteSetting.isInitialRoute
Navigator
Navigator.pop
Navigator.canPop
Relevant issue: | https://docs.flutter.dev/release/breaking-changes/route-navigator-refactoring/index.html |
f1370cf8d0bd-6 | Navigator.canPop
Relevant issue:
Issue 45938: Router
Relevant PR:
PR 44930 - Refactor the imperative api to continue working in the new navigation system | https://docs.flutter.dev/release/breaking-changes/route-navigator-refactoring/index.html |
4537a03d47af-0 | Route transition record and transition delegate updates
Summary
Context
Migration guide
Timeline
References
Summary
Context
When the navigator receives a new list of pages, it tries to update its
current routes stack to match the list. However, it requires explicit
decisions on how to transition the route on and off the screen.
Previously, routes that were not in the new list required decisions
on how to transition off the screen. However, we later found out
this is not always true. If a route is popped,
but is still waiting for the popping animation to finish,
this route would sit in the navigator routes stack until
the animation was done. If a page update occurred during this time,
this route exits but doesn’t requires a decision
on how to transition off the screen. Therefore,
isWaitingForExitingDecision was added to cover that case. | https://docs.flutter.dev/release/breaking-changes/route-transition-record-and-transition-delegate/index.html |
4537a03d47af-1 | The isEntering getter is also renamed to
isWaitingForEnteringDecision to be more descriptive,
and also to make the naming more consistent.
Migration guide
Code before migration:
import
'package:flutter/widgets.dart'
class
NoAnimationTransitionDelegate
extends
TransitionDelegate
void
@override
Iterable
RouteTransitionRecord
resolve
({
List
RouteTransitionRecord
newPageRouteHistory
Map
RouteTransitionRecord
RouteTransitionRecord
locationToExitingPageRoute
Map
RouteTransitionRecord
List
RouteTransitionRecord
>> | https://docs.flutter.dev/release/breaking-changes/route-transition-record-and-transition-delegate/index.html |
4537a03d47af-2 | List
RouteTransitionRecord
>>
pageRouteToPagelessRoutes
})
final
List
RouteTransitionRecord
results
RouteTransitionRecord
>[];
for
final
RouteTransitionRecord
pageRoute
in
newPageRouteHistory
if
pageRoute
isEntering
pageRoute
markForAdd
();
results
add
pageRoute
);
for
final
RouteTransitionRecord
exitingPageRoute
in
locationToExitingPageRoute
values | https://docs.flutter.dev/release/breaking-changes/route-transition-record-and-transition-delegate/index.html |
4537a03d47af-3 | in
locationToExitingPageRoute
values
exitingPageRoute
markForRemove
();
final
List
RouteTransitionRecord
pagelessRoutes
pageRouteToPagelessRoutes
exitingPageRoute
];
if
pagelessRoutes
!=
null
for
final
RouteTransitionRecord
pagelessRoute
in
pagelessRoutes
pagelessRoute
markForRemove
();
results
add
exitingPageRoute
);
return
results
Code after migration:
import | https://docs.flutter.dev/release/breaking-changes/route-transition-record-and-transition-delegate/index.html |
4537a03d47af-4 | results
Code after migration:
import
'package:flutter/widgets.dart'
class
NoAnimationTransitionDelegate
extends
TransitionDelegate
void
@override
Iterable
RouteTransitionRecord
resolve
({
List
RouteTransitionRecord
newPageRouteHistory
Map
RouteTransitionRecord
RouteTransitionRecord
locationToExitingPageRoute
Map
RouteTransitionRecord
List
RouteTransitionRecord
>>
pageRouteToPagelessRoutes
})
final
List
RouteTransitionRecord
results | https://docs.flutter.dev/release/breaking-changes/route-transition-record-and-transition-delegate/index.html |
4537a03d47af-5 | List
RouteTransitionRecord
results
RouteTransitionRecord
>[];
for
final
RouteTransitionRecord
pageRoute
in
newPageRouteHistory
// Renames isEntering to isWaitingForEnteringDecision.
if
pageRoute
isWaitingForEnteringDecision
pageRoute
markForAdd
();
results
add
pageRoute
);
for
final
RouteTransitionRecord
exitingPageRoute
in
locationToExitingPageRoute
values
// Checks the isWaitingForExitingDecision before calling the markFor methods. | https://docs.flutter.dev/release/breaking-changes/route-transition-record-and-transition-delegate/index.html |
4537a03d47af-6 | // Checks the isWaitingForExitingDecision before calling the markFor methods.
if
exitingPageRoute
isWaitingForExitingDecision
exitingPageRoute
markForRemove
();
final
List
RouteTransitionRecord
pagelessRoutes
pageRouteToPagelessRoutes
exitingPageRoute
];
if
pagelessRoutes
!=
null
for
final
RouteTransitionRecord
pagelessRoute
in
pagelessRoutes
pagelessRoute
markForRemove
();
results
add
exitingPageRoute
); | https://docs.flutter.dev/release/breaking-changes/route-transition-record-and-transition-delegate/index.html |
4537a03d47af-7 | add
exitingPageRoute
);
return
results
Timeline
Landed in version: 1.18.0
In stable release: 1.20
References
API documentation:
Navigator
TransitionDelegate
RouteTransitionRecord
Relevant issue:
Issue 45938: Navigator 2.0
Relevant PR:
PR 55998: Fixes the navigator pages update crash
when there is still a route waiting | https://docs.flutter.dev/release/breaking-changes/route-transition-record-and-transition-delegate/index.html |
ae981d3f5937-0 | Migration guide for RouteSettings copyWith
Summary
Context
Description of change
Migration guide
Timeline
References
Summary
The RouteSettings.copyWith method is removed, and apps that use
it need to use the constructor to create a new RouteSettings
instance instead.
Context
With the introduction of the Page class,
the RouteSettings.copyWith was no longer a viable API.
Description of change
RouteSettings.copyWith was removed
Migration guide
Code before migration:
RouteSettings
newSettings
oldSettings
copyWith
name:
'new name'
);
Code after migration:
RouteSettings
newSettings
RouteSettings | https://docs.flutter.dev/release/breaking-changes/routesettings-copywith-migration/index.html |
ae981d3f5937-1 | RouteSettings
newSettings
RouteSettings
name:
'new name'
arguments:
oldSettings
arguments
);
Timeline
Landed in version: 3.5.0-9.0.pre-137-gc6f6095acd
In stable release: 3.7
References
Relevant PRs:
PR 113860: Removes RouteSetting.copyWith. | https://docs.flutter.dev/release/breaking-changes/routesettings-copywith-migration/index.html |
a13d627ebb98-0 | SnackBars managed by the ScaffoldMessenger
Summary
Context
Description of change
Migration guide
Timeline
References
Summary
The SnackBar API within the Scaffold is now handled by the
ScaffoldMessenger, one of which is
available by default within the context of a MaterialApp.
Context
Description of change
The previous approach called upon the Scaffold to show a SnackBar.
Scaffold
key:
scaffoldKey
body:
Builder
builder:
BuildContext
context
return
GestureDetector
onTap:
()
Scaffold
of | https://docs.flutter.dev/release/breaking-changes/scaffold-messenger/index.html |
a13d627ebb98-1 | ()
Scaffold
of
context
showSnackBar
SnackBar
content:
const
Text
'snack'
),
duration:
const
Duration
seconds:
),
action:
SnackBarAction
label:
'ACTION'
onPressed:
()
},
),
));
},
child:
const
Text
'SHOW SNACK'
),
);
},
); | https://docs.flutter.dev/release/breaking-changes/scaffold-messenger/index.html |
a13d627ebb98-2 | ),
);
},
);
The new approach calls on the ScaffoldMessenger to show
the SnackBar. In this case, the Builder is no longer
required to provide a new scope with a BuildContext that
is “under” the Scaffold.
Scaffold
key:
scaffoldKey
body:
GestureDetector
onTap:
()
ScaffoldMessenger
of
context
showSnackBar
SnackBar
content:
const
Text
'snack'
),
duration:
const
Duration
seconds:
), | https://docs.flutter.dev/release/breaking-changes/scaffold-messenger/index.html |
a13d627ebb98-3 | Duration
seconds:
),
action:
SnackBarAction
label:
'ACTION'
onPressed:
()
},
),
));
},
child:
const
Text
'SHOW SNACK'
),
),
);
When presenting a SnackBar during a transition,
the SnackBar completes a Hero animation,
moving smoothly to the next page.
The method debugCheckHasScaffoldMessenger is available to assert
that a given context has a ScaffoldMessenger ancestor.
Trying to present a SnackBar without a ScaffoldMessenger ancestor
present results in an assertion such as the following:
Migration guide | https://docs.flutter.dev/release/breaking-changes/scaffold-messenger/index.html |
a13d627ebb98-4 | Migration guide
Code before migration:
// The ScaffoldState of the current context was used for managing SnackBars.
Scaffold
of
context
showSnackBar
mySnackBar
);
Scaffold
of
context
hideCurrentSnackBar
mySnackBar
);
Scaffold
of
context
removeCurrentSnackBar
mySnackBar
);
// If a Scaffold.key is specified, the ScaffoldState can be directly
// accessed without first obtaining it from a BuildContext via
// Scaffold.of. From the key, use the GlobalKey.currentState | https://docs.flutter.dev/release/breaking-changes/scaffold-messenger/index.html |
a13d627ebb98-5 | // Scaffold.of. From the key, use the GlobalKey.currentState
// getter. This was previously used to manage SnackBars.
final
GlobalKey
ScaffoldState
scaffoldKey
GlobalKey
ScaffoldState
>();
Scaffold
key:
scaffoldKey
body:
...,
);
scaffoldKey
currentState
showSnackBar
mySnackBar
);
scaffoldKey
currentState
hideCurrentSnackBar
mySnackBar
);
scaffoldKey
currentState | https://docs.flutter.dev/release/breaking-changes/scaffold-messenger/index.html |
a13d627ebb98-6 | );
scaffoldKey
currentState
removeCurrentSnackBar
mySnackBar
);
Code after migration:
// The ScaffoldMessengerState of the current context is used for managing SnackBars.
ScaffoldMessenger
of
context
showSnackBar
mySnackBar
);
ScaffoldMessenger
of
context
hideCurrentSnackBar
mySnackBar
);
ScaffoldMessenger
of
context
removeCurrentSnackBar
mySnackBar
); | https://docs.flutter.dev/release/breaking-changes/scaffold-messenger/index.html |
a13d627ebb98-7 | mySnackBar
);
// If a ScaffoldMessenger.key is specified, the ScaffoldMessengerState can be directly
// accessed without first obtaining it from a BuildContext via
// ScaffoldMessenger.of. From the key, use the GlobalKey.currentState
// getter. This is used to manage SnackBars.
final
GlobalKey
ScaffoldMessengerState
scaffoldMessengerKey
GlobalKey
ScaffoldMessengerState
>();
ScaffoldMessenger
key:
scaffoldMessengerKey
child:
...
scaffoldMessengerKey
currentState
showSnackBar | https://docs.flutter.dev/release/breaking-changes/scaffold-messenger/index.html |
a13d627ebb98-8 | currentState
showSnackBar
mySnackBar
);
scaffoldMessengerKey
currentState
hideCurrentSnackBar
mySnackBar
);
scaffoldMessengerKey
currentState
removeCurrentSnackBar
mySnackBar
);
// The root ScaffoldMessenger can also be accessed by providing a key to
// MaterialApp.scaffoldMessengerKey. This way, the ScaffoldMessengerState can be directly accessed
// without first obtaining it from a BuildContext via ScaffoldMessenger.of. From the key, use
// the GlobalKey.currentState getter.
final
GlobalKey | https://docs.flutter.dev/release/breaking-changes/scaffold-messenger/index.html |
a13d627ebb98-9 | final
GlobalKey
ScaffoldMessengerState
rootScaffoldMessengerKey
GlobalKey
ScaffoldMessengerState
>();
MaterialApp
scaffoldMessengerKey:
rootScaffoldMessengerKey
home:
...
rootScaffoldMessengerKey
currentState
showSnackBar
mySnackBar
);
rootScaffoldMessengerKey
currentState
hideCurrentSnackBar
mySnackBar
);
rootScaffoldMessengerKey
currentState
removeCurrentSnackBar
mySnackBar | https://docs.flutter.dev/release/breaking-changes/scaffold-messenger/index.html |
a13d627ebb98-10 | removeCurrentSnackBar
mySnackBar
);
Timeline
Landed in version: 1.23.0-13.0.pre
In stable release: 2.0.0
References
API documentation:
Scaffold
ScaffoldMessenger
SnackBar
MaterialApp
Relevant issues:
Issue #57218
Issue #62921
Relevant PRs:
ScaffoldMessenger
ScaffoldMessenger Migration | https://docs.flutter.dev/release/breaking-changes/scaffold-messenger/index.html |
058950370af5-0 | Scribble Text Input Client
Summary
Context
Description of change
Migration guide
Timeline
References
Summary
Adds three methods, showToolbar, insertTextPlaceholder, and
removeTextPlaceholder to the TextInputClient interface to allow the iOS 14
Scribble feature to insert and remove text placeholders and show the toolbar.
Context
As of iOS 14, iPads support the Scribble feature when using the Apple Pencil.
This feature allows users to use the pencil to interact with text fields to
add, delete, select, and modify text.
Description of change | https://docs.flutter.dev/release/breaking-changes/scribble-text-input-client/index.html |
058950370af5-1 | Description of change
In native text widgets, the text toolbar is shown when a user uses the pencil
to select text on an iPad running iOS 14 or higher.
To replicate this behavior, the platform sends a textInput channel message
called TextInputClient.showToolbar.
This notifies the Dart code that the toolbar should be shown.
When a user holds the pencil down, a visual gap in the text is shown to allow
the user extra space to write.
To replicate this behavior, the platform sends textInput channel messages
called TextInputClient.insertTextPlaceholder and
TextInputClient.removeTextPlaceholder.
Multiline text inputs should have placeholders that provide vertical space,
while single line inputs should provide horizontal space.
Migration guide
If you previously implemented TextEditingClient, you must override
showToolbar, insertTextPlaceholder, and removeTextPlaceholder to either
support these Scribble features or provide an empty implementation. | https://docs.flutter.dev/release/breaking-changes/scribble-text-input-client/index.html |
058950370af5-2 | To migrate, implement showToolbar, insertTextPlaceholder, and
removeTextPlaceholder.
Code before migration:
class
MyCustomTextInputClient
implements
TextInputClient
...
Code after migration:
class
MyCustomTextInputClient
implements
TextInputClient
...
@override
void
showToolbar
()
...
@override
void
insertTextPlaceholder
Size
size
...
@override
void
removeTextPlaceholder
()
...
Timeline | https://docs.flutter.dev/release/breaking-changes/scribble-text-input-client/index.html |
058950370af5-3 | ()
...
Timeline
Landed in version: 2.9.0-1.0.pre
In stable release: 2.10
References
API documentation:
TextInputClient
Relevant issues:
Issue 61278
Relevant PRs:
24224: Support Scribble Handwriting (engine)
75472: Support Scribble Handwriting
97437: Re-land Support Scribble Handwriting | https://docs.flutter.dev/release/breaking-changes/scribble-text-input-client/index.html |
bc1d47e9b1d1-0 | Scrollable AlertDialog (No longer deprecated)
Summary
Context
Description of change
Migration guide
Timeline
References
Summary
An AlertDialog now scrolls automatically when it overflows.
Context
Before this change,
when an AlertDialog widget’s contents were too tall,
the display overflowed, causing the contents to be clipped.
This resulted in the following issues:
There was no way to view the portion of the content that was clipped.
Most alert dialogs have buttons beneath the content to prompt users for
actions. If the content overflowed, obscuring the buttons,
users might be unaware of their existence.
Description of change
The previous approach listed the title and content
widgets consecutively in a Column widget.
Column
mainAxisSize:
MainAxisSize
min | https://docs.flutter.dev/release/breaking-changes/scrollable-alert-dialog/index.html |
bc1d47e9b1d1-1 | mainAxisSize:
MainAxisSize
min
crossAxisAlignment:
CrossAxisAlignment
stretch
children:
Widget
>[
if
title
!=
null
Padding
padding:
titlePadding
??
EdgeInsets
fromLTRB
24.0
24.0
24.0
content
==
null
20.0
0.0
),
child:
DefaultTextStyle
style:
titleTextStyle
??
dialogTheme | https://docs.flutter.dev/release/breaking-changes/scrollable-alert-dialog/index.html |
bc1d47e9b1d1-2 | titleTextStyle
??
dialogTheme
titleTextStyle
??
theme
textTheme
title
child:
Semantics
child:
title
namesRoute:
true
container:
true
),
),
),
if
content
!=
null
Flexible
child:
Padding
padding:
contentPadding
child:
DefaultTextStyle
style:
contentTextStyle
??
dialogTheme
contentTextStyle
??
theme | https://docs.flutter.dev/release/breaking-changes/scrollable-alert-dialog/index.html |
bc1d47e9b1d1-3 | contentTextStyle
??
theme
textTheme
subhead
child:
content
),
),
),
// ...
],
);
The new approach wraps both widgets in a
SingleChildScrollView above the button bar,
making both widgets part of the same scrollable
and exposing the button bar at the bottom of the dialog.
Column
mainAxisSize:
MainAxisSize
min
crossAxisAlignment:
CrossAxisAlignment
stretch
children:
Widget
>[
if
title
!=
null
||
content
!=
null | https://docs.flutter.dev/release/breaking-changes/scrollable-alert-dialog/index.html |
bc1d47e9b1d1-4 | ||
content
!=
null
SingleChildScrollView
child:
Column
mainAxisSize:
MainAxisSize
min
crossAxisAlignment:
CrossAxisAlignment
stretch
children:
Widget
>[
if
title
!=
null
titleWidget
if
content
!=
null
contentWidget
],
),
),
// ...
],
),
Migration guide
You might see the following issues as a result of this change: | https://docs.flutter.dev/release/breaking-changes/scrollable-alert-dialog/index.html |
bc1d47e9b1d1-5 | You might see the following issues as a result of this change:
Manual testing of the Talkback and VoiceOver features
show that they still exhibit the same (correct)
behavior as before.
This change might have caused diffs in (previously passing)
golden tests since the SingleChildScrollView now nests both the
title and content widgets.
Some Flutter projects have taken to creating semantics tests
by taking goldens of semantics nodes used in Flutter’s debug build.
Any semantics golden updates that reflect the scrolling
container addition are expected and these diffs should be safe to accept.
Sample resulting Semantics tree:
If the dialog was already overflowing,
this change corrects the problem.
This layout change is expected.
A nested SingleChildScrollView in AlertDialog.content
should work properly if left in the code,
but should be removed if unintended, since
it might cause confusion.
Code before migration:
AlertDialog | https://docs.flutter.dev/release/breaking-changes/scrollable-alert-dialog/index.html |
bc1d47e9b1d1-6 | Code before migration:
AlertDialog
title:
Text
'Very, very large title that is also scrollable'
textScaleFactor:
),
content:
SingleChildScrollView
// won't be scrollable
child:
Text
'Scrollable content'
textScaleFactor:
),
),
actions:
Widget
>[
TextButton
child:
Text
'Button 1'
),
onPressed:
()
{}),
TextButton
child:
Text
'Button 2'
), | https://docs.flutter.dev/release/breaking-changes/scrollable-alert-dialog/index.html |
bc1d47e9b1d1-7 | Text
'Button 2'
),
onPressed:
()
{}),
],
Code after migration:
AlertDialog
title:
Text
'Very, very large title'
textScaleFactor:
),
content:
Text
'Very, very large content'
textScaleFactor:
),
actions:
Widget
>[
TextButton
child:
Text
'Button 1'
),
onPressed:
()
{}),
TextButton
child:
Text | https://docs.flutter.dev/release/breaking-changes/scrollable-alert-dialog/index.html |
bc1d47e9b1d1-8 | TextButton
child:
Text
'Button 2'
),
onPressed:
()
{}),
],
Timeline
Landed in version: 1.16.3
In stable release: 1.17
References
Design doc:
Scrollable AlertDialog
API documentation:
AlertDialog
Relevant issue:
Overflow exceptions with maximum accessibility font size
Relevant PRs:
Update to AlertDialog.scrollable
Original attempt to implement scrollable AlertDialog
Revert of original attempt to implement scrollable AlertDialog | https://docs.flutter.dev/release/breaking-changes/scrollable-alert-dialog/index.html |
6ecb20c3b35d-0 | Reversing the dependency between the scheduler and services layer
Summary
Context
Description of change
Migration guide
Timeline
References
Summary
The services layer now depends on the scheduler layer.
Previously, the opposite was true. This may affect you
if you have defined custom bindings overriding
Flutter’s SchedulerBinding or ServicesBinding.
Context
Prior to this change, the scheduler layer was dependent
on the services layer. This change reverses the dependency
chain and allows the services layer to make use of the
scheduling primitives in the scheduler layer. For example,
services in the services layer can now schedule tasks by using
SchedulerBinding.scheduleTask.
Description of change
The change only affects users who are defining their own
custom bindings based on Flutter’s SchedulerBinding
and ServicesBinding.
Migration guide | https://docs.flutter.dev/release/breaking-changes/services-scheduler-dependency-reversed/index.html |
6ecb20c3b35d-1 | Migration guide
Prior to this change, the ServiceBinding had to be defined before the
SchedulerBinding. With this change, it is the other way around:
Code before migration:
class
FooBinding
extends
BindingBase
with
ServicesBinding
SchedulerBinding
// ...
Code after migration:
class
FooBinding
extends
BindingBase
with
SchedulerBinding
ServicesBinding
// ...
Timeline
Landed in version: 1.18.0
In stable release: 1.20
References
API documentation:
ServicesBinding
SchedulerBinding
Relevant PRs: | https://docs.flutter.dev/release/breaking-changes/services-scheduler-dependency-reversed/index.html |
6ecb20c3b35d-2 | SchedulerBinding
Relevant PRs:
Reverse dependency between services and scheduler
Revert bindings dependency workaround | https://docs.flutter.dev/release/breaking-changes/services-scheduler-dependency-reversed/index.html |
94f5cc8ed489-0 | Migrate `of` to non-nullable return values, and add `maybeOf`
Summary
Context
Description of change
Migration guide
Timeline
References
Summary
This migration guide describes conversion of code that uses various static of
functions to retrieve information from a context that used to return nullable
values, but now return non-nullable values.
Context
Flutter has a common pattern of allowing lookup of some types of widgets
(typically InheritedWidgets, but also others) using static member
functions that are typically called of.
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
Scrollable.of(context) and then still requiring an ! operator or ? and a
fallback value after that call felt awkward, and was not idiomatic for
non-nullable Dart code. | https://docs.flutter.dev/release/breaking-changes/supplemental-maybeOf-migration/index.html |
94f5cc8ed489-1 | A lot of this migration was performed when we eliminated nullOk parameters in
a previous migration, but some of methods were missed in that migration,
and some were subsequently added with nullable return types, counter to our
common pattern.
In this migration, the affected of accessors were split into two calls: one
that returned a non-nullable value and threw an exception when the sought-after
value was not present (still called of), and one that returned a nullable
value that didn’t throw an exception, and returned null if the value was not
present (a new method called maybeOf).
Description of change
The change modified these static of APIs to return non-nullable values. If a
value is not found, they will also now assert in debug mode, and throw an
exception in release mode.
AutofillGroup.of
DefaultTabController.of
DefaultTextHeightBehavior.of
Form.of
HeroControllerScope.of
Material.of | https://docs.flutter.dev/release/breaking-changes/supplemental-maybeOf-migration/index.html |
94f5cc8ed489-2 | HeroControllerScope.of
Material.of
Overlay.of
PageStorage.of
PrimaryScrollController.of
RenderAbstractViewport.of
RestorationScope.of
Scrollable.of
ScrollNotificationObserver.of
This change also introduced new static maybeOf APIs alongside the above functions,
which return a nullable version of the same value, and simply return null if the
value is not found, without throwing any exceptions.
AutofillGroup.maybeOf
DefaultTabController.maybeOf
DefaultTextHeightBehavior.maybeOf
Form.maybeOf
HeroControllerScope.maybeOf
Material.maybeOf
Overlay.maybeOf
PageStorage.maybeOf
PrimaryScrollController.maybeOf
RenderAbstractViewport.maybeOf
RestorationScope.maybeOf | https://docs.flutter.dev/release/breaking-changes/supplemental-maybeOf-migration/index.html |
94f5cc8ed489-3 | RenderAbstractViewport.maybeOf
RestorationScope.maybeOf
Scrollable.maybeOf
ScrollNotificationObserver.maybeOf
Migration guide
To modify your code to use the new form of the APIs, first convert all
instances of the original static of functions (where its nullability is
important) to use the maybeOf form instead.
Code before migration:
ScrollController
controller
Scrollable
of
context
);
Code after migration:
ScrollController
controller
Scrollable
maybeOf
context
);
Then, for instances where the code calls the of API followed by an exclamation
point, just remove the exclamation point: it can no longer return a nullable
value.
Code before migration:
ScrollController | https://docs.flutter.dev/release/breaking-changes/supplemental-maybeOf-migration/index.html |
94f5cc8ed489-4 | Code before migration:
ScrollController
controller
Scrollable
of
context
Code after migration:
ScrollController
controller
Scrollable
of
context
);
The following can also be helpful:
unnecessary_non_null_assertion (linter message) identifies
places where an ! operator should be removed
unnecessary_null_checks (analysis option) identifies places
where the ? operator isn’t needed
unnecessary_null_in_if_null_operators identifies places
where a ?? operator isn’t needed
unnecessary_nullable_for_final_variable_declarations (analysis option)
finds unnecessary question mark operators on final and const variables
Timeline
In stable release: 3.7
References | https://docs.flutter.dev/release/breaking-changes/supplemental-maybeOf-migration/index.html |
94f5cc8ed489-5 | In stable release: 3.7
References
API documentation:
Material.of
Relevant PRs:
Add maybeOf for all the cases when of returns nullable
Add Overlay.maybeOf, make Overlay.of return a non-nullable instance | https://docs.flutter.dev/release/breaking-changes/supplemental-maybeOf-migration/index.html |
155931d7e7bd-0 | Adding 'linux' and 'windows' to TargetPlatform enum
Summary
Context
Description of change
Migration guide
Timeline
References
Summary
Two new values were added to the TargetPlatform enum
that could require additional cases in switch statements that
switch on a TargetPlatform and don’t include a default: case.
Context
Prior to this change, the TargetPlatform enum only contained four values,
and was defined like this:
enum
TargetPlatform
android
fuchsia
iOS
macOS
A switch statement only needed to handle these cases,
and desktop applications that wanted to run on Linux or
Windows usually had a test like this in their
main() method:
// Sets a platform override for desktop to avoid exceptions. See | https://docs.flutter.dev/release/breaking-changes/target-platform-linux-windows/index.html |
155931d7e7bd-1 | // Sets a platform override for desktop to avoid exceptions. See
// https://docs.flutter.dev/desktop#target-platform-override for more info.
void
_enablePlatformOverrideForDesktop
()
if
kIsWeb
&&
Platform
isWindows
||
Platform
isLinux
))
debugDefaultTargetPlatformOverride
TargetPlatform
fuchsia
void
main
()
_enablePlatformOverrideForDesktop
();
runApp
MyApp
());
Description of change
The TargetPlatform enum is now defined as:
enum
TargetPlatform
android | https://docs.flutter.dev/release/breaking-changes/target-platform-linux-windows/index.html |
155931d7e7bd-2 | enum
TargetPlatform
android
fuchsia
iOS
linux
// new value
macOS
windows
// new value
And the platform test setting
debugDefaultTargetPlatformOverride in main()
is no longer required on Linux and Windows.
This can cause the Dart analyzer to give the
missing_enum_constant_in_switch warning for
switch statements that don’t include a default case.
Writing a switch without a default: case is the
recommended way to handle enums, since the analyzer
can then help you find any cases that aren’t handled.
Migration guide
In order to migrate to the new enum, and avoid the analyzer’s
missing_enum_constant_in_switch error, which looks like:
or
Modify your code as follows:
Code before migration: | https://docs.flutter.dev/release/breaking-changes/target-platform-linux-windows/index.html |
155931d7e7bd-3 | Modify your code as follows:
Code before migration:
void
dance
TargetPlatform
platform
switch
platform
case
TargetPlatform
android
// Do Android dance.
break
case
TargetPlatform
fuchsia
// Do Fuchsia dance.
break
case
TargetPlatform
iOS
// Do iOS dance.
break
case
TargetPlatform
macOS
// Do macOS dance.
break
Code after migration:
void
dance
TargetPlatform
platform
switch
platform | https://docs.flutter.dev/release/breaking-changes/target-platform-linux-windows/index.html |
155931d7e7bd-4 | platform
switch
platform
case
TargetPlatform
android
// Do Android dance.
break
case
TargetPlatform
fuchsia
// Do Fuchsia dance.
break
case
TargetPlatform
iOS
// Do iOS dance.
break
case
TargetPlatform
linux
// new case
// Do Linux dance.
break
case
TargetPlatform
macOS
// Do macOS dance.
break
case
TargetPlatform
windows
// new case
// Do Windows dance.
break | https://docs.flutter.dev/release/breaking-changes/target-platform-linux-windows/index.html |
155931d7e7bd-5 | // new case
// Do Windows dance.
break
Having default: cases in such switch statements isn’t
recommended, because then the analyzer can’t help you find
all the cases that need to be handled.
Also, any tests like the one referenced above that set the
debugDefaultTargetPlatformOverride are no longer needed
for Linux and Windows applications.
Timeline
Landed in version: 1.15.4
In stable release: 1.17
References
API documentation:
TargetPlatform
Relevant issues:
Issue #31366
Relevant PR:
Add Windows, and Linux as TargetPlatforms | https://docs.flutter.dev/release/breaking-changes/target-platform-linux-windows/index.html |
cf1de2a67a55-0 | Replace with title of breaking change
Summary
Context
Description of change
Migration guide
Timeline
References
Summary
Context
Description of change
Migration guide
Code before migration:
// Example of code before the change.
Code after migration:
// Example of code after the change.
Timeline
Landed in version: xxx
In stable release: not yet
Reverted in version: xxx (OPTIONAL, delete if not used)
References | https://docs.flutter.dev/release/breaking-changes/template/index.html |
e9c10f6e56be-0 | TestTextInput state reset
Summary
Context
Description of change
Migration guide
Timeline
References
Summary
The state of a TestTextInput instance,
a stub for the system’s onscreen keyboard,
is now reset between tests.
Context
The Flutter test framework uses a class called TestTextInput
to track and manipulate editing state in a widgets test.
Individual tests can make calls that modify the internal
state of this object, sometimes indirectly (such as
by setting their own handlers on SystemChannels.textInput).
Subsequent tests might then check the state of
WidgetTester.testTextInput and get unexpected values.
Description of change
The state of WidgetTester.testTextInput
is now reset before running a testWidgets test.
Migration guide | https://docs.flutter.dev/release/breaking-changes/test-text-input/index.html |
e9c10f6e56be-1 | Migration guide
Tests that relied on dirty state from a previously run
test must be updated. For example, the following test,
from packages/flutter/test/material/text_field_test.dart
in the 'Controller can update server' test,
previously passed because of a combination of dirty state
from previous tests and a failure to actually set state
in cases where it should have been set.
Code before migration:
In a widgetsTest, before actually changing text on a
text editing widget, this call might have succeeded:
expect
tester
testTextInput
editingState
'text'
],
isEmpty
);
Code after migration:
Either remove the call entirely, or consider using the
following to assert that the state hasn’t been modified yet:
expect
tester
testTextInput | https://docs.flutter.dev/release/breaking-changes/test-text-input/index.html |
e9c10f6e56be-2 | expect
tester
testTextInput
editingState
isNull
);
Timeline
Landed in version: 1.16.3
In stable release: 1.17
References
API documentation:
TestTextInput
WidgetTester
Relevant issue:
Randomize test order to avoid global state
Relevant PR:
Reset state between tests | https://docs.flutter.dev/release/breaking-changes/test-text-input/index.html |
d96f15b9f5cd-0 | TestWidgetsFlutterBinding.clock change
Summary
Context
Migration guide
Option #1: Create a package:quiver Clock from a package:clock Clock
Option #2: Change the api to accept a package:clock Clock
Option #3: Change the API to accept a DateTime function()
Timeline
References
Summary
The TestWidgetsFlutterBinding.clock now comes from
package:clock and not package:quiver.
Context
The flutter_test package is removing its dependency on
the heavier weight quiver package in favor of a dependency
on two more targeted and lighter weight packages,
clock and fake_async.
This can affect user code which grabs the clock from a
TestWidgetsFlutterBinding and passes that to an API
that expects a Clock from package:quiver,
for example some code like this:
testWidgets | https://docs.flutter.dev/release/breaking-changes/test-widgets-flutter-binding-clock/index.html |
d96f15b9f5cd-1 | testWidgets
'some test'
WidgetTester
tester
someApiThatWantsAQuiverClock
tester
binding
clock
);
});
Migration guide
The error you might see after this change looks something like this:
Option #1: Create a package:quiver Clock from a package:clock Clock
The easiest migration is to create a package:quiver clock from the
package:clock clock, which can be done by passing the .now function
tearoff to the Clock constructor:
Code before migration:
testWidgets
'some test'
WidgetTester
tester
someApiThatWantsAQuiverClock
tester
binding
clock | https://docs.flutter.dev/release/breaking-changes/test-widgets-flutter-binding-clock/index.html |
d96f15b9f5cd-2 | tester
binding
clock
);
});
Code after migration:
testWidgets
'some test'
WidgetTester
tester
someApiThatWantsAQuiverClock
Clock
tester
binding
clock
now
));
});
Option #2: Change the api to accept a package:clock Clock
If you own the api you are calling,
you may want to change it to accept a Clock
from package:clock.
This is a judgement call based on how many places are
calling this API with something other than a clock
retrieved from a TestWidgetsFlutterBinding. | https://docs.flutter.dev/release/breaking-changes/test-widgets-flutter-binding-clock/index.html |
d96f15b9f5cd-3 | If you go this route, your call sites that are passing
tester.binding.clock won’t need to be modified,
but other call sites will.
Option #3: Change the API to accept a DateTime function()
If you only use the Clock for its now function,
and you control the API, then you can also change it
to accept that function directly instead of a Clock.
This makes it easily callable with either type of Clock,
by passing a tearoff of the now method from either type of clock:
Calling code before migration:
testWidgets
'some test'
WidgetTester
tester
someApiThatWantsAQuiverClock
tester
binding
clock
);
});
Calling code after migration:
testWidgets
'some test' | https://docs.flutter.dev/release/breaking-changes/test-widgets-flutter-binding-clock/index.html |
d96f15b9f5cd-4 | testWidgets
'some test'
WidgetTester
tester
modifiedApiThatTakesANowFunction
tester
binding
clock
now
);
});
Timeline
Landed in version: 1.18.0
In stable release: 1.20
References
API documentation:
TestWidgetsFlutterBinding
Relevant PRs:
PR 54125: remove flutter_test quiver dep,
use fake_async and clock instead | https://docs.flutter.dev/release/breaking-changes/test-widgets-flutter-binding-clock/index.html |
06b3dacc7006-0 | TextField requires a MaterialLocalizations widget
Summary
Context
Migration guide
Timeline
References
Summary
Instances of TextField must have a MaterialLocalizations present in the widget tree.
Trying to instantiate a TextField without the proper localizations results in an assertion such
as the following:
Context
If the TextField descends from a MaterialApp, the
DefaultMaterialLocalizations is already instantiated
and won’t require any changes to your existing code.
If the TextField doesn’t descend from MaterialApp,
you can use a Localizations widget to
provide your own localizations.
Migration guide
If you see an assertion error, make sure that locale information is available to the TextField,
either through an ancestor MaterialApp (that automatically provides Localizations), or by
creating your own Localizations widget.
Code before migration:
import | https://docs.flutter.dev/release/breaking-changes/text-field-material-localizations/index.html |
06b3dacc7006-1 | Code before migration:
import
'package:flutter/material.dart'
void
main
()
runApp
Foo
());
class
Foo
extends
StatelessWidget
@override
Widget
build
BuildContext
context
return
MediaQuery
data:
const
MediaQueryData
(),
child:
Directionality
textDirection:
TextDirection
ltr
child:
Material
child:
TextField
(),
),
), | https://docs.flutter.dev/release/breaking-changes/text-field-material-localizations/index.html |
06b3dacc7006-2 | (),
),
),
);
Code after migration (Providing localizations using the MaterialApp):
import
'package:flutter/material.dart'
void
main
()
runApp
Foo
());
class
Foo
extends
StatelessWidget
@override
Widget
build
BuildContext
context
return
MaterialApp
home:
Material
child:
TextField
(),
),
);
Code after migration (Providing localizations via the Localizations widget):
import | https://docs.flutter.dev/release/breaking-changes/text-field-material-localizations/index.html |
06b3dacc7006-3 | import
'package:flutter/material.dart'
void
main
()
runApp
Foo
());
class
Foo
extends
StatelessWidget
@override
Widget
build
BuildContext
context
return
Localizations
locale:
const
Locale
'en'
'US'
),
delegates:
const
LocalizationsDelegate
dynamic
>>[
DefaultWidgetsLocalizations
delegate
DefaultMaterialLocalizations
delegate
],
child: | https://docs.flutter.dev/release/breaking-changes/text-field-material-localizations/index.html |
06b3dacc7006-4 | delegate
],
child:
MediaQuery
data:
const
MediaQueryData
(),
child:
Directionality
textDirection:
TextDirection
ltr
child:
Material
child:
TextField
(),
),
),
),
);
Timeline
Landed in version: 1.20.0-1.0.pre
In stable release: 1.20
References
API documentation:
TextField
Localizations
MaterialLocalizations
DefaultMaterialLocalizations
MaterialApp
Internationalizing Flutter apps | https://docs.flutter.dev/release/breaking-changes/text-field-material-localizations/index.html |
06b3dacc7006-5 | MaterialApp
Internationalizing Flutter apps
Relevant PR:
PR 58831: Assert debugCheckHasMaterialLocalizations on TextField | https://docs.flutter.dev/release/breaking-changes/text-field-material-localizations/index.html |
3399f493b80b-0 | TextInputClient currentTextEditingValue
Summary
Context
Description of change
Migration guide
Timeline
References
Summary
Add a field, currentTextEditingValue, to the TextInputClient
interface to get the current value of an editable text field
from a platform client.
Context
The TextInputClient class is used by the Flutter framework to
communicate with platform code about the current state of text
input widgets like EditableText.
The platform side can lose its state when an Android app
moves to the background. As of this change,
the app can ask the framework for the last known state.
In order to obtain this information,
the TextEditingValue was surfaced for the TextInputClient.
Description of change | https://docs.flutter.dev/release/breaking-changes/text-input-client-current-value/index.html |
3399f493b80b-1 | Description of change
On some supported platforms, the application can be moved into
the background where it is expected to consume fewer resources.
For example, a backgrounded application on Android should avoid consuming
unnecessary memory and has no need to retain references to views.
Before this change, the Android-specific platform code could
lose state information about editable text fields when
the app moved back to the foreground.
This is seen, for example,
when text entered in a TextField widget is lost to
the Java code, but is still remembered in the Dart code.
As of this change,
the platform side now sends a textInput channel
message called TextInput.requestExistingState.
This notifies the Dart code that, when the app wakes up,
it should re-establish any text input connections
and notify the platform of its most
recently known editing state.
Migration guide
If you previously implemented or extended TextEditingClient,
you must now add the appropriate override for currentTextEditingValue. | https://docs.flutter.dev/release/breaking-changes/text-input-client-current-value/index.html |
3399f493b80b-2 | This value may be null.
If you want to migrate before this change lands,
you can add a class to your class
similar to the following:
abstract
class
_TemporaryTextEditingClient
TextEditingValue
get
currentTextEditingValue
This allows you to add the new member with an
@override annotation before the change lands
in the framework. Later, you can remove the
temporary interface definition.
Code before migration:
class
_MyCustomTextWidgetState
extends
State
MyCustomWidget
implements
TextEditingClient
...
@override
void
updateEditingValue
TextEditingValue
value
...
@override | https://docs.flutter.dev/release/breaking-changes/text-input-client-current-value/index.html |
3399f493b80b-3 | value
...
@override
void
performAction
TextInputAction
action
...
@override
void
updateFloatingCursor
RawFloatingCursorPoint
point
...
Code after migration:
class
_MyCustomTextWidgetState
extends
State
MyCustomWidget
implements
TextEditingClient
...
@override
TextEditingValue
get
currentTextEditingValue
widget
textEditingController
value
@override
void
updateEditingValue
TextEditingValue | https://docs.flutter.dev/release/breaking-changes/text-input-client-current-value/index.html |
3399f493b80b-4 | void
updateEditingValue
TextEditingValue
value
...
@override
void
performAction
TextInputAction
action
...
@override
void
updateFloatingCursor
RawFloatingCursorPoint
point
...
Timeline
Landed in version: 1.16.3
In stable release: 1.17
References
API documentation:
TextInput
TextInputClient
EditableText
SystemChannels.textInput
Relevant issue:
Issue 47137
Relevant PR:
Fix requestExistingInputState response | https://docs.flutter.dev/release/breaking-changes/text-input-client-current-value/index.html |
755388d97e71-0 | TextSelectionTheme migration
Summary
Context
Migration guide
Timeline
References
Summary
The ThemeData properties that controlled the look of
selected text in Material widgets have been moved into
their own TextSelectionTheme. These properties include
cursorColor, textSelectionColor, and
textSelectionHandleColor. The defaults for these
properties have also been changed to match the Material
Design specification.
Context
As part of the larger Material Theme Updates,
we have introduced a new Text Selection Theme
used to specify the properties of selected text in
TextField and SelectableText widgets.
These replace several top-level properties of ThemeData
and update their default values to match the Material
Design specification. This document describes how
applications can migrate to this new API.
Migration guide | https://docs.flutter.dev/release/breaking-changes/text-selection-theme/index.html |
755388d97e71-1 | Migration guide
If you are currently using the following properties of
ThemeData, you need to update them to use the new
equivalent properties on ThemeData.textSelectionTheme:
ThemeData.cursorColor
TextSelectionThemeData.cursorColor
ThemeData.textSelectionColor
TextSelectionThemeData.selectionColor
ThemeData.textSelectionHandleColor
TextSelectionThemeData.selectionHandleColor
Code before migration:
ThemeData
cursorColor:
Colors
red
textSelectionColor:
Colors
green
textSelectionHandleColor:
Colors
blue
Code after migration:
ThemeData
textSelectionTheme:
TextSelectionThemeData
cursorColor:
Colors | https://docs.flutter.dev/release/breaking-changes/text-selection-theme/index.html |
Subsets and Splits