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
f7cf0d97
Commit
f7cf0d97
authored
Apr 15, 2016
by
Hans Muller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the progress indicator demo (#3367)
parent
efbcb0aa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
17 deletions
+92
-17
progress_indicator_demo.dart
...es/material_gallery/lib/demo/progress_indicator_demo.dart
+22
-17
progress_indicator_test.dart
packages/flutter/test/material/progress_indicator_test.dart
+70
-0
No files found.
examples/material_gallery/lib/demo/progress_indicator_demo.dart
View file @
f7cf0d97
...
...
@@ -10,43 +10,48 @@ class ProgressIndicatorDemo extends StatefulWidget {
}
class
_ProgressIndicatorDemoState
extends
State
<
ProgressIndicatorDemo
>
{
AnimationController
_controller
;
Animation
<
double
>
_animation
;
@override
void
initState
()
{
super
.
initState
();
controller
=
new
AnimationController
(
_
controller
=
new
AnimationController
(
duration:
const
Duration
(
milliseconds:
1500
)
)..
forward
();
animation
=
new
CurvedAnimation
(
parent:
controller
,
_
animation
=
new
CurvedAnimation
(
parent:
_
controller
,
curve:
new
Interval
(
0.0
,
0.9
,
curve:
Curves
.
ease
),
reverseCurve:
Curves
.
ease
)..
addStatusListener
((
AnimationStatus
status
)
{
if
(
status
==
AnimationStatus
.
dismissed
)
controller
.
forward
();
_
controller
.
forward
();
else
if
(
status
==
AnimationStatus
.
completed
)
controller
.
reverse
();
_
controller
.
reverse
();
});
}
Animation
<
double
>
animation
;
AnimationController
controller
;
@override
void
dispose
()
{
_controller
.
stop
();
super
.
dispose
();
}
void
_handleTap
()
{
setState
(()
{
// valueAnimation.isAnimating is part of our build state
if
(
controller
.
isAnimating
)
{
controller
.
stop
();
if
(
_
controller
.
isAnimating
)
{
_
controller
.
stop
();
}
else
{
switch
(
controller
.
status
)
{
switch
(
_
controller
.
status
)
{
case
AnimationStatus
.
dismissed
:
case
AnimationStatus
.
forward
:
controller
.
forward
();
_
controller
.
forward
();
break
;
case
AnimationStatus
.
reverse
:
case
AnimationStatus
.
completed
:
controller
.
reverse
();
_
controller
.
reverse
();
break
;
}
}
...
...
@@ -61,19 +66,19 @@ class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> {
),
new
LinearProgressIndicator
(),
new
LinearProgressIndicator
(),
new
LinearProgressIndicator
(
value:
animation
.
value
),
new
LinearProgressIndicator
(
value:
_
animation
.
value
),
new
CircularProgressIndicator
(),
new
SizedBox
(
width:
20.0
,
height:
20.0
,
child:
new
CircularProgressIndicator
(
value:
animation
.
value
)
child:
new
CircularProgressIndicator
(
value:
_
animation
.
value
)
),
new
SizedBox
(
width:
50.0
,
height:
30.0
,
child:
new
CircularProgressIndicator
(
value:
animation
.
value
)
child:
new
CircularProgressIndicator
(
value:
_
animation
.
value
)
),
new
Text
(
'
${(
animation.value * 100.0).toStringAsFixed(1)}
%
${
controller.isAnimating ? "" : " (paused)" }
'
)
new
Text
(
'
${(
_animation.value * 100.0).toStringAsFixed(1)}
%
${ _
controller.isAnimating ? "" : " (paused)" }
'
)
];
return
new
Column
(
children:
indicators
...
...
@@ -95,7 +100,7 @@ class _ProgressIndicatorDemoState extends State<ProgressIndicatorDemo> {
child:
new
Container
(
padding:
const
EdgeInsets
.
symmetric
(
vertical:
12.0
,
horizontal:
8.0
),
child:
new
AnimatedBuilder
(
animation:
animation
,
animation:
_
animation
,
builder:
_buildIndicators
)
)
...
...
packages/flutter/test/
widget
/progress_indicator_test.dart
→
packages/flutter/test/
material
/progress_indicator_test.dart
View file @
f7cf0d97
...
...
@@ -8,14 +8,61 @@ import 'package:flutter/material.dart';
import
'package:test/test.dart'
;
void
main
(
)
{
// The "can be constructed" tests that follow are primarily to ensure that any
// animations started by the progress indicators are stopped at dispose() time.
test
(
'LinearProgressIndicator(value: 0.0) can be constructed'
,
()
{
testWidgets
((
WidgetTester
tester
)
{
tester
.
pumpWidget
(
new
Center
(
child:
new
SizedBox
(
width:
200.0
,
child:
new
LinearProgressIndicator
(
value:
0.0
)
)
)
);
});
});
test
(
'LinearProgressIndicator(value: null) can be constructed'
,
()
{
testWidgets
((
WidgetTester
tester
)
{
tester
.
pumpWidget
(
new
Center
(
child:
new
SizedBox
(
width:
200.0
,
child:
new
LinearProgressIndicator
(
value:
null
)
)
)
);
});
});
test
(
'CircularProgressIndicator(value: 0.0) can be constructed'
,
()
{
testWidgets
((
WidgetTester
tester
)
{
tester
.
pumpWidget
(
new
Center
(
child:
new
CircularProgressIndicator
(
value:
0.0
)
)
);
});
});
test
(
'CircularProgressIndicator(value: null) can be constructed'
,
()
{
testWidgets
((
WidgetTester
tester
)
{
tester
.
pumpWidget
(
new
Center
(
child:
new
CircularProgressIndicator
(
value:
null
)
)
);
});
});
test
(
'LinearProgressIndicator changes when its value changes'
,
()
{
testElementTree
((
ElementTreeTester
tester
)
{
tester
.
pumpWidget
(
new
Block
(
children:
<
Widget
>[
new
LinearProgressIndicator
(
value:
0.0
)]));
List
<
Layer
>
layers1
=
tester
.
layers
;
tester
.
pumpWidget
(
new
Block
(
children:
<
Widget
>[
new
LinearProgressIndicator
(
value:
0.5
)]));
List
<
Layer
>
layers2
=
tester
.
layers
;
expect
(
layers1
,
isNot
(
equals
(
layers2
)));
});
...
...
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