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
830bdfa3
Unverified
Commit
830bdfa3
authored
Nov 18, 2020
by
Chinmoy
Committed by
GitHub
Nov 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added none property in a DismissDirection (#68987)
parent
b8887f47
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
12 deletions
+30
-12
leave_behind_demo.dart
.../flutter_gallery/lib/demo/material/leave_behind_demo.dart
+1
-0
dismissible.dart
packages/flutter/lib/src/widgets/dismissible.dart
+16
-12
dismissible_test.dart
packages/flutter/test/widgets/dismissible_test.dart
+13
-0
No files found.
dev/integration_tests/flutter_gallery/lib/demo/material/leave_behind_demo.dart
View file @
830bdfa3
...
...
@@ -237,6 +237,7 @@ class _LeaveBehindListItem extends StatelessWidget {
case
DismissDirection
.
vertical
:
case
DismissDirection
.
up
:
case
DismissDirection
.
down
:
case
DismissDirection
.
none
:
assert
(
false
);
}
return
false
;
...
...
packages/flutter/lib/src/widgets/dismissible.dart
View file @
830bdfa3
...
...
@@ -50,7 +50,10 @@ enum DismissDirection {
up
,
/// The [Dismissible] can be dismissed by dragging down only.
down
down
,
/// The [Dismissible] cannot be dismissed by dragging.
none
}
/// A widget that can be dismissed by dragging in the indicated [direction].
...
...
@@ -305,9 +308,9 @@ class _DismissibleState extends State<Dismissible> with TickerProviderStateMixin
||
widget
.
direction
==
DismissDirection
.
startToEnd
;
}
DismissDirection
?
_extentToDirection
(
double
extent
)
{
DismissDirection
_extentToDirection
(
double
extent
)
{
if
(
extent
==
0.0
)
return
null
;
return
DismissDirection
.
none
;
if
(
_directionIsXAxis
)
{
switch
(
Directionality
.
of
(
context
))
{
case
TextDirection
.
rtl
:
...
...
@@ -319,7 +322,7 @@ class _DismissibleState extends State<Dismissible> with TickerProviderStateMixin
return
extent
>
0
?
DismissDirection
.
down
:
DismissDirection
.
up
;
}
DismissDirection
?
get
_dismissDirection
=>
_extentToDirection
(
_dragExtent
);
DismissDirection
get
_dismissDirection
=>
_extentToDirection
(
_dragExtent
);
bool
get
_isActive
{
return
_dragUnderway
||
_moveController
!.
isAnimating
;
...
...
@@ -391,6 +394,10 @@ class _DismissibleState extends State<Dismissible> with TickerProviderStateMixin
break
;
}
break
;
case
DismissDirection
.
none
:
_dragExtent
=
0
;
break
;
}
if
(
oldDragExtent
.
sign
!=
_dragExtent
.
sign
)
{
setState
(()
{
...
...
@@ -426,7 +433,7 @@ class _DismissibleState extends State<Dismissible> with TickerProviderStateMixin
}
final
double
vx
=
velocity
.
pixelsPerSecond
.
dx
;
final
double
vy
=
velocity
.
pixelsPerSecond
.
dy
;
DismissDirection
?
flingDirection
;
DismissDirection
flingDirection
;
// Verify that the fling is in the generally right direction and fast enough.
if
(
_directionIsXAxis
)
{
if
(
vx
.
abs
()
-
vy
.
abs
()
<
_kMinFlingVelocityDelta
||
vx
.
abs
()
<
_kMinFlingVelocity
)
...
...
@@ -495,8 +502,7 @@ class _DismissibleState extends State<Dismissible> with TickerProviderStateMixin
Future
<
bool
?>
_confirmStartResizeAnimation
()
async
{
if
(
widget
.
confirmDismiss
!=
null
)
{
final
DismissDirection
direction
=
_dismissDirection
!;
assert
(
direction
!=
null
);
final
DismissDirection
direction
=
_dismissDirection
;
return
widget
.
confirmDismiss
!(
direction
);
}
return
true
;
...
...
@@ -509,8 +515,7 @@ class _DismissibleState extends State<Dismissible> with TickerProviderStateMixin
assert
(
_sizePriorToCollapse
==
null
);
if
(
widget
.
resizeDuration
==
null
)
{
if
(
widget
.
onDismissed
!=
null
)
{
final
DismissDirection
direction
=
_dismissDirection
!;
assert
(
direction
!=
null
);
final
DismissDirection
direction
=
_dismissDirection
;
widget
.
onDismissed
!(
direction
);
}
}
else
{
...
...
@@ -537,8 +542,7 @@ class _DismissibleState extends State<Dismissible> with TickerProviderStateMixin
void
_handleResizeProgressChanged
()
{
if
(
_resizeController
!.
isCompleted
)
{
if
(
widget
.
onDismissed
!=
null
)
{
final
DismissDirection
direction
=
_dismissDirection
!;
assert
(
direction
!=
null
);
final
DismissDirection
direction
=
_dismissDirection
;
widget
.
onDismissed
!(
direction
);
}
}
else
{
...
...
@@ -555,7 +559,7 @@ class _DismissibleState extends State<Dismissible> with TickerProviderStateMixin
Widget
?
background
=
widget
.
background
;
if
(
widget
.
secondaryBackground
!=
null
)
{
final
DismissDirection
?
direction
=
_dismissDirection
;
final
DismissDirection
direction
=
_dismissDirection
;
if
(
direction
==
DismissDirection
.
endToStart
||
direction
==
DismissDirection
.
up
)
background
=
widget
.
secondaryBackground
;
}
...
...
packages/flutter/test/widgets/dismissible_test.dart
View file @
830bdfa3
...
...
@@ -861,4 +861,17 @@ void main() {
await
tester
.
tapAt
(
const
Offset
(
10.0
,
10.0
));
expect
(
didReceivePointerDown
,
isTrue
);
});
testWidgets
(
'DismissDirection.none does not trigger dismiss'
,
(
WidgetTester
tester
)
async
{
dismissDirection
=
DismissDirection
.
none
;
await
tester
.
pumpWidget
(
buildTest
());
expect
(
dismissedItems
,
isEmpty
);
await
dismissItem
(
tester
,
0
,
gestureDirection:
AxisDirection
.
left
);
await
dismissItem
(
tester
,
0
,
gestureDirection:
AxisDirection
.
right
);
await
dismissItem
(
tester
,
0
,
gestureDirection:
AxisDirection
.
up
);
await
dismissItem
(
tester
,
0
,
gestureDirection:
AxisDirection
.
down
);
expect
(
find
.
text
(
'0'
),
findsOneWidget
);
});
}
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