Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
4e2b6480
Unverified
Commit
4e2b6480
authored
Aug 19, 2022
by
xubaolin
Committed by
GitHub
Aug 19, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Dismissible]Fix a state lose issue (#108971)
parent
4293ce9a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
1 deletion
+32
-1
dismissible.dart
packages/flutter/lib/src/widgets/dismissible.dart
+3
-1
debug_test.dart
packages/flutter/test/material/debug_test.dart
+1
-0
dismissible_test.dart
packages/flutter/test/widgets/dismissible_test.dart
+28
-0
No files found.
packages/flutter/lib/src/widgets/dismissible.dart
View file @
4e2b6480
...
...
@@ -323,6 +323,8 @@ class _DismissibleState extends State<Dismissible> with TickerProviderStateMixin
Size
?
_sizePriorToCollapse
;
bool
_dismissThresholdReached
=
false
;
final
GlobalKey
_contentKey
=
GlobalKey
();
@override
bool
get
wantKeepAlive
=>
(
_moveController
?.
isAnimating
??
false
)
||
(
_resizeController
?.
isAnimating
??
false
);
...
...
@@ -668,7 +670,7 @@ class _DismissibleState extends State<Dismissible> with TickerProviderStateMixin
Widget
content
=
SlideTransition
(
position:
_moveAnimation
,
child:
widget
.
child
,
child:
KeyedSubtree
(
key:
_contentKey
,
child:
widget
.
child
)
,
);
if
(
background
!=
null
)
{
...
...
packages/flutter/test/material/debug_test.dart
View file @
4e2b6480
...
...
@@ -329,6 +329,7 @@ void main() {
' PhysicalModel
\n
'
' AnimatedPhysicalModel
\n
'
' Material
\n
'
' KeyedSubtree-[GlobalKey#00000]
\n
'
' FractionalTranslation
\n
'
' SlideTransition
\n
'
' Listener
\n
'
...
...
packages/flutter/test/widgets/dismissible_test.dart
View file @
4e2b6480
...
...
@@ -1150,4 +1150,32 @@ void main() {
expect
(
reportedDismissUpdatePreviousReached
,
false
);
expect
(
reportedDismissUpdateProgress
,
0.0
);
});
testWidgets
(
'Change direction does not lose child state'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/108961
Widget
buildFrame
(
DismissDirection
direction
)
{
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Dismissible
(
dragStartBehavior:
DragStartBehavior
.
down
,
direction:
direction
,
key:
const
Key
(
'Dismissible'
),
resizeDuration:
null
,
child:
const
SizedBox
(
width:
100.0
,
height:
100.0
,
child:
Text
(
'I Love Flutter!'
),
),
),
);
}
await
tester
.
pumpWidget
(
buildFrame
(
DismissDirection
.
horizontal
));
final
RenderBox
textRenderObjectBegin
=
tester
.
renderObject
(
find
.
text
(
'I Love Flutter!'
));
await
tester
.
pumpWidget
(
buildFrame
(
DismissDirection
.
none
));
final
RenderBox
textRenderObjectEnd
=
tester
.
renderObject
(
find
.
text
(
'I Love Flutter!'
));
expect
(
identical
(
textRenderObjectBegin
,
textRenderObjectEnd
),
true
);
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment