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
375bb776
Commit
375bb776
authored
Feb 21, 2016
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2067 from abarth/status_callback
Animation status callbacks should be re-entrant
parents
4ec96084
6722e3d5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
4 deletions
+45
-4
animation_controller.dart
packages/flutter/lib/src/animation/animation_controller.dart
+5
-4
animation_controller_test.dart
...ges/flutter/test/animation/animation_controller_test.dart
+40
-0
No files found.
packages/flutter/lib/src/animation/animation_controller.dart
View file @
375bb776
...
...
@@ -163,10 +163,11 @@ class AnimationController extends Animation<double>
AnimationStatus
_lastStatus
=
AnimationStatus
.
dismissed
;
void
_checkStatusChanged
()
{
AnimationStatus
currentStatus
=
status
;
if
(
currentStatus
!=
_lastStatus
)
notifyStatusListeners
(
status
);
_lastStatus
=
currentStatus
;
AnimationStatus
newStatus
=
status
;
AnimationStatus
oldStatus
=
_lastStatus
;
_lastStatus
=
newStatus
;
if
(
oldStatus
!=
newStatus
)
notifyStatusListeners
(
newStatus
);
}
/// Drives the animation from its current value to target.
...
...
packages/flutter/test/animation/animation_controller_test.dart
0 → 100644
View file @
375bb776
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/animation.dart'
;
import
'package:flutter/scheduler.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:test/test.dart'
;
void
main
(
)
{
test
(
"Can set value during status callback"
,
()
{
WidgetFlutterBinding
.
ensureInitialized
();
AnimationController
controller
=
new
AnimationController
(
duration:
const
Duration
(
milliseconds:
100
)
);
bool
didComplete
=
false
;
bool
didDismiss
=
false
;
controller
.
addStatusListener
((
AnimationStatus
status
)
{
if
(
status
==
AnimationStatus
.
completed
)
{
didComplete
=
true
;
controller
.
value
=
0.0
;
controller
.
forward
();
}
else
if
(
status
==
AnimationStatus
.
dismissed
)
{
didDismiss
=
true
;
controller
.
value
=
0.0
;
controller
.
forward
();
}
});
controller
.
forward
();
expect
(
didComplete
,
isFalse
);
expect
(
didDismiss
,
isFalse
);
Scheduler
.
instance
.
handleBeginFrame
(
const
Duration
(
seconds:
1
));
expect
(
didComplete
,
isFalse
);
expect
(
didDismiss
,
isFalse
);
Scheduler
.
instance
.
handleBeginFrame
(
const
Duration
(
seconds:
2
));
expect
(
didComplete
,
isTrue
);
expect
(
didDismiss
,
isTrue
);
});
}
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