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
da3b2a2f
Unverified
Commit
da3b2a2f
authored
Jul 18, 2022
by
Markus Aksli
Committed by
GitHub
Jul 18, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix `Scaffold` `setState` during locked framework due to open drawer (#107173)
parent
2f0a2525
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
83 additions
and
2 deletions
+83
-2
scaffold.dart
packages/flutter/lib/src/material/scaffold.dart
+2
-2
drawer_test.dart
packages/flutter/test/material/drawer_test.dart
+81
-0
No files found.
packages/flutter/lib/src/material/scaffold.dart
View file @
da3b2a2f
...
...
@@ -2029,7 +2029,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
bool
get
isEndDrawerOpen
=>
_endDrawerOpened
.
value
;
void
_drawerOpenedCallback
(
bool
isOpened
)
{
if
(
_drawerOpened
.
value
!=
isOpened
)
{
if
(
_drawerOpened
.
value
!=
isOpened
&&
_drawerKey
.
currentState
!=
null
)
{
setState
(()
{
_drawerOpened
.
value
=
isOpened
;
});
...
...
@@ -2038,7 +2038,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
}
void
_endDrawerOpenedCallback
(
bool
isOpened
)
{
if
(
_endDrawerOpened
.
value
!=
isOpened
)
{
if
(
_endDrawerOpened
.
value
!=
isOpened
&&
_endDrawerKey
.
currentState
!=
null
)
{
setState
(()
{
_endDrawerOpened
.
value
=
isOpened
;
});
...
...
packages/flutter/test/material/drawer_test.dart
View file @
da3b2a2f
...
...
@@ -422,6 +422,87 @@ void main() {
expect
(
find
.
text
(
'Drawer'
),
findsNothing
);
});
testWidgets
(
'Disposing drawer does not crash if drawer is open and framework is locked'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/34978
addTearDown
(
tester
.
binding
.
window
.
clearPhysicalSizeTestValue
);
tester
.
binding
.
window
.
physicalSizeTestValue
=
const
Size
(
1800.0
,
2400.0
);
await
tester
.
pumpWidget
(
MaterialApp
(
home:
OrientationBuilder
(
builder:
(
BuildContext
context
,
Orientation
orientation
)
{
switch
(
orientation
)
{
case
Orientation
.
portrait
:
return
Scaffold
(
drawer:
const
Text
(
'drawer'
),
body:
Container
(),
);
case
Orientation
.
landscape
:
return
Scaffold
(
appBar:
AppBar
(),
body:
Container
(),
);
}
},
),
),
);
expect
(
find
.
text
(
'drawer'
),
findsNothing
);
// Using a global key is a workaround for this issue.
final
ScaffoldState
portraitScaffoldState
=
tester
.
firstState
(
find
.
byType
(
Scaffold
));
portraitScaffoldState
.
openDrawer
();
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'drawer'
),
findsOneWidget
);
// Change the orientation and cause the drawer controller to be disposed
// while the framework is locked.
tester
.
binding
.
window
.
physicalSizeTestValue
=
const
Size
(
2400.0
,
1800.0
);
await
tester
.
pumpAndSettle
();
expect
(
find
.
byType
(
BackButton
),
findsNothing
);
});
testWidgets
(
'Disposing endDrawer does not crash if endDrawer is open and framework is locked'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/34978
addTearDown
(
tester
.
binding
.
window
.
clearPhysicalSizeTestValue
);
tester
.
binding
.
window
.
physicalSizeTestValue
=
const
Size
(
1800.0
,
2400.0
);
await
tester
.
pumpWidget
(
MaterialApp
(
home:
OrientationBuilder
(
builder:
(
BuildContext
context
,
Orientation
orientation
)
{
switch
(
orientation
)
{
case
Orientation
.
portrait
:
return
Scaffold
(
endDrawer:
const
Text
(
'endDrawer'
),
body:
Container
(),
);
case
Orientation
.
landscape
:
return
Scaffold
(
appBar:
AppBar
(),
body:
Container
(),
);
}
},
),
),
);
expect
(
find
.
text
(
'endDrawer'
),
findsNothing
);
// Using a global key is a workaround for this issue.
final
ScaffoldState
portraitScaffoldState
=
tester
.
firstState
(
find
.
byType
(
Scaffold
));
portraitScaffoldState
.
openEndDrawer
();
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'endDrawer'
),
findsOneWidget
);
// Change the orientation and cause the drawer controller to be disposed
// while the framework is locked.
tester
.
binding
.
window
.
physicalSizeTestValue
=
const
Size
(
2400.0
,
1800.0
);
await
tester
.
pumpAndSettle
();
expect
(
find
.
byType
(
BackButton
),
findsNothing
);
});
testWidgets
(
'ScaffoldState close end drawer'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
<
ScaffoldState
>
scaffoldKey
=
GlobalKey
<
ScaffoldState
>();
...
...
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