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
a5863932
Unverified
Commit
a5863932
authored
Oct 25, 2021
by
Markus Aksli
Committed by
GitHub
Oct 25, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ignore `Scaffold` drawer callbacks when value doesn't change (#92329)
parent
d2cea643
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
8 deletions
+46
-8
scaffold.dart
packages/flutter/lib/src/material/scaffold.dart
+12
-8
scaffold_test.dart
packages/flutter/test/material/scaffold_test.dart
+34
-0
No files found.
packages/flutter/lib/src/material/scaffold.dart
View file @
a5863932
...
...
@@ -1960,17 +1960,21 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
bool
get
isEndDrawerOpen
=>
_endDrawerOpened
.
value
;
void
_drawerOpenedCallback
(
bool
isOpened
)
{
setState
(()
{
_drawerOpened
.
value
=
isOpened
;
});
widget
.
onDrawerChanged
?.
call
(
isOpened
);
if
(
_drawerOpened
.
value
!=
isOpened
)
{
setState
(()
{
_drawerOpened
.
value
=
isOpened
;
});
widget
.
onDrawerChanged
?.
call
(
isOpened
);
}
}
void
_endDrawerOpenedCallback
(
bool
isOpened
)
{
setState
(()
{
_endDrawerOpened
.
value
=
isOpened
;
});
widget
.
onEndDrawerChanged
?.
call
(
isOpened
);
if
(
_endDrawerOpened
.
value
!=
isOpened
)
{
setState
(()
{
_endDrawerOpened
.
value
=
isOpened
;
});
widget
.
onEndDrawerChanged
?.
call
(
isOpened
);
}
}
/// Opens the [Drawer] (if any).
...
...
packages/flutter/test/material/scaffold_test.dart
View file @
a5863932
...
...
@@ -50,6 +50,40 @@ void main() {
expect
(
false
,
isEndDrawerOpen
);
});
testWidgets
(
'Scaffold drawer callback test - only call when changed'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/87914
bool
onDrawerChangedCalled
=
false
;
bool
onEndDrawerChangedCalled
=
false
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
drawer:
Container
(
color:
Colors
.
blue
,
),
onDrawerChanged:
(
bool
isOpen
)
{
onDrawerChangedCalled
=
true
;
},
endDrawer:
Container
(
color:
Colors
.
green
,
),
onEndDrawerChanged:
(
bool
isOpen
)
{
onEndDrawerChangedCalled
=
true
;
},
body:
Container
(),
),
));
await
tester
.
flingFrom
(
Offset
.
zero
,
const
Offset
(
10.0
,
0.0
),
10.0
);
expect
(
false
,
onDrawerChangedCalled
);
await
tester
.
pumpAndSettle
();
final
double
width
=
tester
.
getSize
(
find
.
byType
(
MaterialApp
)).
width
;
await
tester
.
flingFrom
(
Offset
(
width
-
1
,
0.0
),
const
Offset
(-
10.0
,
0.0
),
10.0
);
await
tester
.
pumpAndSettle
();
expect
(
false
,
onEndDrawerChangedCalled
);
});
testWidgets
(
'Scaffold control test'
,
(
WidgetTester
tester
)
async
{
final
Key
bodyKey
=
UniqueKey
();
Widget
boilerplate
(
Widget
child
)
{
...
...
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