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
600a3a74
Unverified
Commit
600a3a74
authored
Mar 24, 2020
by
Jussi Lahdenniemi
Committed by
GitHub
Mar 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix to DrawerController: Call the callback when drawer opened/closed with a fling. (#52593)
parent
778c2ce9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
0 deletions
+53
-0
drawer.dart
packages/flutter/lib/src/material/drawer.dart
+4
-0
drawer_test.dart
packages/flutter/test/material/drawer_test.dart
+49
-0
No files found.
packages/flutter/lib/src/material/drawer.dart
View file @
600a3a74
...
...
@@ -436,9 +436,13 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
switch
(
Directionality
.
of
(
context
))
{
case
TextDirection
.
rtl
:
_controller
.
fling
(
velocity:
-
visualVelocity
);
if
(
widget
.
drawerCallback
!=
null
)
widget
.
drawerCallback
(
visualVelocity
<
0.0
);
break
;
case
TextDirection
.
ltr
:
_controller
.
fling
(
velocity:
visualVelocity
);
if
(
widget
.
drawerCallback
!=
null
)
widget
.
drawerCallback
(
visualVelocity
>
0.0
);
break
;
}
}
else
if
(
_controller
.
value
<
0.5
)
{
...
...
packages/flutter/test/material/drawer_test.dart
View file @
600a3a74
...
...
@@ -166,4 +166,53 @@ void main() {
await
tester
.
pumpAndSettle
();
expect
(
find
.
byType
(
Drawer
),
findsNothing
);
});
testWidgets
(
'Open/close drawers by flinging'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
drawer:
Drawer
(
child:
Container
(
child:
const
Text
(
'start drawer'
),
),
),
endDrawer:
Drawer
(
child:
Container
(
child:
const
Text
(
'end drawer'
),
),
),
),
),
);
// In the beginning, drawers are closed
final
ScaffoldState
state
=
tester
.
firstState
(
find
.
byType
(
Scaffold
));
expect
(
state
.
isDrawerOpen
,
equals
(
false
));
expect
(
state
.
isEndDrawerOpen
,
equals
(
false
));
final
Size
size
=
tester
.
getSize
(
find
.
byType
(
Scaffold
));
// A fling from the left opens the start drawer
await
tester
.
flingFrom
(
Offset
(
0
,
size
.
height
/
2
),
const
Offset
(
80
,
0
),
500
);
await
tester
.
pumpAndSettle
();
expect
(
state
.
isDrawerOpen
,
equals
(
true
));
expect
(
state
.
isEndDrawerOpen
,
equals
(
false
));
// Now, a fling from the right closes the drawer
await
tester
.
flingFrom
(
Offset
(
size
.
width
-
1
,
size
.
height
/
2
),
const
Offset
(-
80
,
0
),
500
);
await
tester
.
pumpAndSettle
();
expect
(
state
.
isDrawerOpen
,
equals
(
false
));
expect
(
state
.
isEndDrawerOpen
,
equals
(
false
));
// Another fling from the right opens the end drawer
await
tester
.
flingFrom
(
Offset
(
size
.
width
-
1
,
size
.
height
/
2
),
const
Offset
(-
80
,
0
),
500
);
await
tester
.
pumpAndSettle
();
expect
(
state
.
isDrawerOpen
,
equals
(
false
));
expect
(
state
.
isEndDrawerOpen
,
equals
(
true
));
// And a fling from the left closes it
await
tester
.
flingFrom
(
Offset
(
0
,
size
.
height
/
2
),
const
Offset
(
80
,
0
),
500
);
await
tester
.
pumpAndSettle
();
expect
(
state
.
isDrawerOpen
,
equals
(
false
));
expect
(
state
.
isEndDrawerOpen
,
equals
(
false
));
});
}
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