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
e2d12060
Unverified
Commit
e2d12060
authored
Apr 14, 2022
by
chunhtai
Committed by
GitHub
Apr 14, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Backbutton is not displayed when there is a endDrawer (#101869)
parent
c165b749
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
11 deletions
+55
-11
app_bar.dart
packages/flutter/lib/src/material/app_bar.dart
+3
-3
scaffold.dart
packages/flutter/lib/src/material/scaffold.dart
+14
-7
navigator.dart
packages/flutter/lib/src/widgets/navigator.dart
+0
-1
app_bar_test.dart
packages/flutter/test/material/app_bar_test.dart
+38
-0
No files found.
packages/flutter/lib/src/material/app_bar.dart
View file @
e2d12060
...
...
@@ -823,9 +823,9 @@ class _AppBarState extends State<AppBar> {
final
bool
hasDrawer
=
scaffold
?.
hasDrawer
??
false
;
final
bool
hasEndDrawer
=
scaffold
?.
hasEndDrawer
??
false
;
final
bool
canPop
=
parentRoute
?.
canPop
??
false
;
final
bool
useCloseButton
=
parentRoute
is
PageRoute
<
dynamic
>
&&
parentRoute
.
fullscreenDialog
;
final
bool
requiresAppBarDismiss
=
scaffold
?.
requiresAppBarDismiss
??
false
;
final
bool
hasActiveRouteBelow
=
parentRoute
?.
hasActiveRouteBelow
??
false
;
final
double
toolbarHeight
=
widget
.
toolbarHeight
??
appBarTheme
.
toolbarHeight
??
kToolbarHeight
;
final
bool
backwardsCompatibility
=
widget
.
backwardsCompatibility
??
appBarTheme
.
backwardsCompatibility
??
false
;
...
...
@@ -896,7 +896,7 @@ class _AppBarState extends State<AppBar> {
tooltip:
MaterialLocalizations
.
of
(
context
).
openAppDrawerTooltip
,
);
}
else
{
if
(
!
hasEndDrawer
&&
canPop
)
if
(
hasActiveRouteBelow
||
requiresAppBarDismiss
)
leading
=
useCloseButton
?
const
CloseButton
()
:
const
BackButton
();
}
}
...
...
packages/flutter/lib/src/material/scaffold.dart
View file @
e2d12060
...
...
@@ -1917,13 +1917,20 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
/// Whether this scaffold has a non-null [Scaffold.appBar].
bool
get
hasAppBar
=>
widget
.
appBar
!=
null
;
/// Whether this scaffold has a non-null [Scaffold.drawer].
bool
get
hasDrawer
=>
widget
.
drawer
!=
null
;
/// Whether this scaffold has a non-null [Scaffold.endDrawer].
bool
get
hasEndDrawer
=>
widget
.
endDrawer
!=
null
;
/// Whether this scaffold has a non-null [Scaffold.floatingActionButton].
bool
get
hasFloatingActionButton
=>
widget
.
floatingActionButton
!=
null
;
/// Whether this scaffold requires [Scaffold.appBar] to automatically add
/// dismiss button.
bool
get
requiresAppBarDismiss
=>
_persistentSheetHistoryEntry
!=
null
;
double
?
_appBarMaxHeight
;
/// The max height the [Scaffold.appBar] uses.
///
...
...
@@ -2051,28 +2058,28 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
PersistentBottomSheetController
<
dynamic
>?
_currentBottomSheet
;
final
GlobalKey
_currentBottomSheetKey
=
GlobalKey
();
LocalHistoryEntry
?
_persistentSheetHistoryEntry
;
void
_maybeBuildPersistentBottomSheet
()
{
if
(
widget
.
bottomSheet
!=
null
&&
_currentBottomSheet
==
null
)
{
// The new _currentBottomSheet is not a local history entry so a "back" button
// will not be added to the Scaffold's appbar and the bottom sheet will not
// support drag or swipe to dismiss.
final
AnimationController
animationController
=
BottomSheet
.
createAnimationController
(
this
)..
value
=
1.0
;
LocalHistoryEntry
?
persistentSheetHistoryEntry
;
bool
_persistentBottomSheetExtentChanged
(
DraggableScrollableNotification
notification
)
{
if
(
notification
.
extent
>
notification
.
initialExtent
)
{
if
(
persistentSheetHistoryEntry
==
null
)
{
persistentSheetHistoryEntry
=
LocalHistoryEntry
(
onRemove:
()
{
if
(
_
persistentSheetHistoryEntry
==
null
)
{
_
persistentSheetHistoryEntry
=
LocalHistoryEntry
(
onRemove:
()
{
if
(
notification
.
extent
>
notification
.
initialExtent
)
{
DraggableScrollableActuator
.
reset
(
notification
.
context
);
}
showBodyScrim
(
false
,
0.0
);
_floatingActionButtonVisibilityValue
=
1.0
;
persistentSheetHistoryEntry
=
null
;
_
persistentSheetHistoryEntry
=
null
;
});
ModalRoute
.
of
(
context
)!.
addLocalHistoryEntry
(
persistentSheetHistoryEntry
!);
ModalRoute
.
of
(
context
)!.
addLocalHistoryEntry
(
_
persistentSheetHistoryEntry
!);
}
}
else
if
(
persistentSheetHistoryEntry
!=
null
)
{
ModalRoute
.
of
(
context
)!.
removeLocalHistoryEntry
(
persistentSheetHistoryEntry
!);
}
else
if
(
_
persistentSheetHistoryEntry
!=
null
)
{
ModalRoute
.
of
(
context
)!.
removeLocalHistoryEntry
(
_
persistentSheetHistoryEntry
!);
}
return
false
;
}
...
...
packages/flutter/lib/src/widgets/navigator.dart
View file @
e2d12060
...
...
@@ -486,7 +486,6 @@ abstract class Route<T> {
}
/// Whether there is at least one active route underneath this route.
@protected
bool
get
hasActiveRouteBelow
{
if
(
_navigator
==
null
)
return
false
;
...
...
packages/flutter/test/material/app_bar_test.dart
View file @
e2d12060
...
...
@@ -2873,6 +2873,44 @@ void main() {
expect
(
tester
.
getSize
(
findAppBarMaterial
()).
height
,
kToolbarHeight
);
});
// Regression test for https://github.com/flutter/flutter/issues/80256
testWidgets
(
'The second page should have a back button even it has a end drawer'
,
(
WidgetTester
tester
)
async
{
final
Page
<
void
>
page1
=
MaterialPage
<
void
>(
key:
const
ValueKey
<
String
>(
'1'
),
child:
Scaffold
(
key:
const
ValueKey
<
String
>(
'1'
),
appBar:
AppBar
(),
endDrawer:
const
Drawer
(),
)
);
final
Page
<
void
>
page2
=
MaterialPage
<
void
>(
key:
const
ValueKey
<
String
>(
'2'
),
child:
Scaffold
(
key:
const
ValueKey
<
String
>(
'2'
),
appBar:
AppBar
(),
endDrawer:
const
Drawer
(),
)
);
final
List
<
Page
<
void
>>
pages
=
<
Page
<
void
>>[
page1
,
page2
];
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Navigator
(
pages:
pages
,
onPopPage:
(
Route
<
Object
?>
route
,
Object
?
result
)
=>
false
,
),
),
);
// The page2 should have a back button.
expect
(
find
.
descendant
(
of:
find
.
byKey
(
const
ValueKey
<
String
>(
'2'
)),
matching:
find
.
byType
(
BackButton
),
),
findsOneWidget
);
});
testWidgets
(
'backgroundColor with FlexibleSpace - reverse'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
_buildAppBar
(
...
...
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