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
16dda865
Unverified
Commit
16dda865
authored
Mar 22, 2022
by
xubaolin
Committed by
GitHub
Mar 22, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a ModalbottomSheet bug (#99970)
parent
32c021bd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
6 deletions
+57
-6
scaffold.dart
packages/flutter/lib/src/material/scaffold.dart
+13
-6
bottom_sheet_test.dart
packages/flutter/test/material/bottom_sheet_test.dart
+44
-0
No files found.
packages/flutter/lib/src/material/scaffold.dart
View file @
16dda865
...
...
@@ -2357,6 +2357,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
late
_StandardBottomSheet
bottomSheet
;
bool
removedEntry
=
false
;
bool
doingDispose
=
false
;
void
_removeCurrentBottomSheet
()
{
removedEntry
=
true
;
if
(
_currentBottomSheet
==
null
)
{
...
...
@@ -2380,11 +2381,19 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
final
LocalHistoryEntry
?
entry
=
isPersistent
?
null
:
LocalHistoryEntry
(
onRemove:
()
{
if
(!
removedEntry
&&
_currentBottomSheet
?.
_widget
==
bottomSheet
)
{
if
(!
removedEntry
&&
_currentBottomSheet
?.
_widget
==
bottomSheet
&&
!
doingDispose
)
{
_removeCurrentBottomSheet
();
}
});
void
_removeEntryIfNeeded
()
{
if
(!
isPersistent
&&
!
removedEntry
)
{
assert
(
entry
!=
null
);
entry
!.
remove
();
removedEntry
=
true
;
}
}
bottomSheet
=
_StandardBottomSheet
(
key:
bottomSheetKey
,
animationController:
animationController
,
...
...
@@ -2394,11 +2403,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
return
;
}
assert
(
_currentBottomSheet
!.
_widget
==
bottomSheet
);
if
(!
isPersistent
&&
!
removedEntry
)
{
assert
(
entry
!=
null
);
entry
!.
remove
();
removedEntry
=
true
;
}
_removeEntryIfNeeded
();
},
onDismissed:
()
{
if
(
_dismissedBottomSheets
.
contains
(
bottomSheet
))
{
...
...
@@ -2408,6 +2413,8 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
}
},
onDispose:
()
{
doingDispose
=
true
;
_removeEntryIfNeeded
();
if
(
shouldDisposeAnimationController
)
{
animationController
.
dispose
();
}
...
...
packages/flutter/test/material/bottom_sheet_test.dart
View file @
16dda865
...
...
@@ -1149,6 +1149,50 @@ void main() {
expect
(
tester
.
takeException
(),
isNull
);
});
// Regression test for https://github.com/flutter/flutter/issues/99627
testWidgets
(
'The old route entry should be removed when a new sheet popup'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
<
ScaffoldState
>
scaffoldKey
=
GlobalKey
();
PersistentBottomSheetController
<
void
>?
sheetController
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
key:
scaffoldKey
,
body:
const
Center
(
child:
Text
(
'body'
)),
),
));
final
ModalRoute
<
dynamic
>
route
=
ModalRoute
.
of
(
scaffoldKey
.
currentContext
!)!;
expect
(
route
.
canPop
,
false
);
scaffoldKey
.
currentState
!.
showBottomSheet
<
void
>((
_
)
{
return
Builder
(
builder:
(
BuildContext
context
)
{
return
Container
(
height:
200.0
);
},
);
});
await
tester
.
pump
();
expect
(
find
.
byType
(
BottomSheet
),
findsOneWidget
);
expect
(
route
.
canPop
,
true
);
// Trigger the second sheet will remove the first sheet from tree.
sheetController
=
scaffoldKey
.
currentState
!.
showBottomSheet
<
void
>((
_
)
{
return
Builder
(
builder:
(
BuildContext
context
)
{
return
Container
(
height:
200.0
);
},
);
});
await
tester
.
pump
();
expect
(
find
.
byType
(
BottomSheet
),
findsOneWidget
);
expect
(
route
.
canPop
,
true
);
sheetController
.
close
();
expect
(
route
.
canPop
,
false
);
});
// Regression test for https://github.com/flutter/flutter/issues/87708
testWidgets
(
'The framework does not dispose of the transitionAnimationController provided by user.'
,
(
WidgetTester
tester
)
async
{
const
Key
tapTarget
=
Key
(
'tap-target'
);
...
...
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