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
caadc255
Unverified
Commit
caadc255
authored
Jun 30, 2022
by
xubaolin
Committed by
GitHub
Jun 30, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reland "fix a Scaffold extendBodyBehindAppBar update bug" (#106534)
parent
9e823869
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
1 deletion
+37
-1
scaffold.dart
packages/flutter/lib/src/material/scaffold.dart
+3
-1
scaffold_test.dart
packages/flutter/test/material/scaffold_test.dart
+34
-0
No files found.
packages/flutter/lib/src/material/scaffold.dart
View file @
caadc255
...
...
@@ -1958,6 +1958,8 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
final
GlobalKey
<
DrawerControllerState
>
_drawerKey
=
GlobalKey
<
DrawerControllerState
>();
final
GlobalKey
<
DrawerControllerState
>
_endDrawerKey
=
GlobalKey
<
DrawerControllerState
>();
final
GlobalKey
_bodyKey
=
GlobalKey
();
/// Whether this scaffold has a non-null [Scaffold.appBar].
bool
get
hasAppBar
=>
widget
.
appBar
!=
null
;
/// Whether this scaffold has a non-null [Scaffold.drawer].
...
...
@@ -2653,7 +2655,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
widget
.
body
==
null
?
null
:
_BodyBuilder
(
extendBody:
widget
.
extendBody
,
extendBodyBehindAppBar:
widget
.
extendBodyBehindAppBar
,
body:
widget
.
body
!
,
body:
KeyedSubtree
(
key:
_bodyKey
,
child:
widget
.
body
!)
,
),
_ScaffoldSlot
.
body
,
removeLeftPadding:
false
,
...
...
packages/flutter/test/material/scaffold_test.dart
View file @
caadc255
...
...
@@ -12,6 +12,39 @@ import 'package:flutter_test/flutter_test.dart';
import
'../widgets/semantics_tester.dart'
;
void
main
(
)
{
// Regression test for https://github.com/flutter/flutter/issues/103741
testWidgets
(
'extendBodyBehindAppBar change should not cause the body widget lose state'
,
(
WidgetTester
tester
)
async
{
final
ScrollController
controller
=
ScrollController
();
Widget
buildFrame
({
required
bool
extendBodyBehindAppBar
})
{
return
MediaQuery
(
data:
const
MediaQueryData
(),
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Scaffold
(
extendBodyBehindAppBar:
extendBodyBehindAppBar
,
resizeToAvoidBottomInset:
false
,
body:
SingleChildScrollView
(
controller:
controller
,
child:
const
FlutterLogo
(
size:
1107
,
),
),
),
),
);
}
await
tester
.
pumpWidget
(
buildFrame
(
extendBodyBehindAppBar:
true
));
expect
(
controller
.
position
.
pixels
,
0.0
);
controller
.
jumpTo
(
100.0
);
await
tester
.
pump
();
expect
(
controller
.
position
.
pixels
,
100.0
);
await
tester
.
pumpWidget
(
buildFrame
(
extendBodyBehindAppBar:
false
));
expect
(
controller
.
position
.
pixels
,
100.0
);
});
testWidgets
(
'Scaffold drawer callback test'
,
(
WidgetTester
tester
)
async
{
bool
isDrawerOpen
=
false
;
bool
isEndDrawerOpen
=
false
;
...
...
@@ -2402,6 +2435,7 @@ void main() {
' ancestor was:
\n
'
' Builder
\n
'
' The ancestors of this widget were:
\n
'
' KeyedSubtree-[GlobalKey#00000]
\n
'
' _BodyBuilder
\n
'
' MediaQuery
\n
'
' LayoutId-[<_ScaffoldSlot.body>]
\n
'
...
...
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