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
bd50007f
Commit
bd50007f
authored
Mar 15, 2019
by
Edman P. Anjos
Committed by
Hans Muller
Mar 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Paint backgroundColor in CircularProgressIndicator (#28004)
parent
3202d228
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
1 deletion
+32
-1
progress_indicator.dart
packages/flutter/lib/src/material/progress_indicator.dart
+12
-1
progress_indicator_test.dart
packages/flutter/test/material/progress_indicator_test.dart
+20
-0
No files found.
packages/flutter/lib/src/material/progress_indicator.dart
View file @
bd50007f
...
...
@@ -316,6 +316,7 @@ class _LinearProgressIndicatorState extends State<LinearProgressIndicator> with
class
_CircularProgressIndicatorPainter
extends
CustomPainter
{
_CircularProgressIndicatorPainter
({
this
.
backgroundColor
,
this
.
valueColor
,
this
.
value
,
this
.
headValue
,
...
...
@@ -330,6 +331,7 @@ class _CircularProgressIndicatorPainter extends CustomPainter {
?
value
.
clamp
(
0.0
,
1.0
)
*
_sweep
:
math
.
max
(
headValue
*
3
/
2
*
math
.
pi
-
tailValue
*
3
/
2
*
math
.
pi
,
_epsilon
);
final
Color
backgroundColor
;
final
Color
valueColor
;
final
double
value
;
final
double
headValue
;
...
...
@@ -352,6 +354,13 @@ class _CircularProgressIndicatorPainter extends CustomPainter {
..
color
=
valueColor
..
strokeWidth
=
strokeWidth
..
style
=
PaintingStyle
.
stroke
;
if
(
backgroundColor
!=
null
)
{
final
Paint
backgroundPaint
=
Paint
()
..
color
=
backgroundColor
..
strokeWidth
=
strokeWidth
..
style
=
PaintingStyle
.
stroke
;
canvas
.
drawArc
(
Offset
.
zero
&
size
,
0
,
_sweep
,
false
,
backgroundPaint
);
}
if
(
value
==
null
)
// Indeterminate
paint
.
strokeCap
=
StrokeCap
.
square
;
...
...
@@ -361,7 +370,8 @@ class _CircularProgressIndicatorPainter extends CustomPainter {
@override
bool
shouldRepaint
(
_CircularProgressIndicatorPainter
oldPainter
)
{
return
oldPainter
.
valueColor
!=
valueColor
return
oldPainter
.
backgroundColor
!=
backgroundColor
||
oldPainter
.
valueColor
!=
valueColor
||
oldPainter
.
value
!=
value
||
oldPainter
.
headValue
!=
headValue
||
oldPainter
.
tailValue
!=
tailValue
...
...
@@ -478,6 +488,7 @@ class _CircularProgressIndicatorState extends State<CircularProgressIndicator> w
),
child:
CustomPaint
(
painter:
_CircularProgressIndicatorPainter
(
backgroundColor:
widget
.
backgroundColor
,
valueColor:
widget
.
_getValueColor
(
context
),
value:
widget
.
value
,
// may be null
headValue:
headValue
,
// remaining arguments are ignored if widget.value is not null
...
...
packages/flutter/test/material/progress_indicator_test.dart
View file @
bd50007f
...
...
@@ -228,6 +228,26 @@ void main() {
expect
(
find
.
byType
(
CircularProgressIndicator
),
paints
..
arc
(
strokeWidth:
16.0
));
});
testWidgets
(
'CircularProgressIndicator paint background color'
,
(
WidgetTester
tester
)
async
{
const
Color
green
=
Color
(
0xFF00FF00
);
const
Color
blue
=
Color
(
0xFF0000FF
);
await
tester
.
pumpWidget
(
const
CircularProgressIndicator
(
valueColor:
AlwaysStoppedAnimation
<
Color
>(
blue
),
));
expect
(
find
.
byType
(
CircularProgressIndicator
),
paintsExactlyCountTimes
(
#drawArc
,
1
));
expect
(
find
.
byType
(
CircularProgressIndicator
),
paints
..
arc
(
color:
blue
));
await
tester
.
pumpWidget
(
const
CircularProgressIndicator
(
backgroundColor:
green
,
valueColor:
AlwaysStoppedAnimation
<
Color
>(
blue
),
));
expect
(
find
.
byType
(
CircularProgressIndicator
),
paintsExactlyCountTimes
(
#drawArc
,
2
));
expect
(
find
.
byType
(
CircularProgressIndicator
),
paints
..
arc
(
color:
green
)..
arc
(
color:
blue
));
});
testWidgets
(
'Indeterminate RefreshProgressIndicator keeps spinning until end of time (approximate)'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/13782
...
...
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