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
41fb069c
Unverified
Commit
41fb069c
authored
May 23, 2018
by
Hans Muller
Committed by
GitHub
May 23, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent Switch from looping on and off (#17821)
parent
6c03a3f9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
8 deletions
+55
-8
toggleable.dart
packages/flutter/lib/src/material/toggleable.dart
+14
-8
switch_test.dart
packages/flutter/test/material/switch_test.dart
+41
-0
No files found.
packages/flutter/lib/src/material/toggleable.dart
View file @
41fb069c
...
...
@@ -134,13 +134,20 @@ abstract class RenderToggleable extends RenderConstrainedBox {
_position
..
curve
=
Curves
.
easeIn
..
reverseCurve
=
Curves
.
easeOut
;
switch
(
_positionController
.
status
)
{
case
AnimationStatus
.
forward
:
case
AnimationStatus
.
completed
:
_positionController
.
reverse
();
break
;
default
:
if
(
tristate
)
{
switch
(
_positionController
.
status
)
{
case
AnimationStatus
.
forward
:
case
AnimationStatus
.
completed
:
_positionController
.
reverse
();
break
;
default
:
_positionController
.
forward
();
}
}
else
{
if
(
value
==
true
)
_positionController
.
forward
();
else
_positionController
.
reverse
();
}
}
...
...
@@ -257,8 +264,7 @@ abstract class RenderToggleable extends RenderConstrainedBox {
if
(
isInteractive
&&
!
tristate
)
{
if
(
status
==
AnimationStatus
.
completed
&&
_value
==
false
)
{
onChanged
(
true
);
}
else
if
(
status
==
AnimationStatus
.
dismissed
&&
_value
!=
false
)
{
}
else
if
(
status
==
AnimationStatus
.
dismissed
&&
_value
!=
false
)
{
onChanged
(
false
);
}
}
...
...
packages/flutter/test/material/switch_test.dart
View file @
41fb069c
...
...
@@ -187,4 +187,45 @@ void main() {
..
circle
(
color:
Colors
.
red
[
500
])
);
});
testWidgets
(
'Drag ends after animation completes'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/17773
bool
value
=
false
;
await
tester
.
pumpWidget
(
new
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
new
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setState
)
{
return
new
Material
(
child:
new
Center
(
child:
new
Switch
(
value:
value
,
onChanged:
(
bool
newValue
)
{
setState
(()
{
value
=
newValue
;
});
},
),
),
);
},
),
),
);
expect
(
value
,
isFalse
);
final
Rect
switchRect
=
tester
.
getRect
(
find
.
byType
(
Switch
));
final
TestGesture
gesture
=
await
tester
.
startGesture
(
switchRect
.
centerLeft
);
await
tester
.
pump
();
await
gesture
.
moveBy
(
new
Offset
(
switchRect
.
width
,
0.0
));
await
tester
.
pump
();
await
gesture
.
up
();
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
milliseconds:
200
));
expect
(
value
,
isTrue
);
expect
(
tester
.
hasRunningAnimations
,
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