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
fad7c367
Unverified
Commit
fad7c367
authored
Mar 13, 2021
by
Darren Austin
Committed by
GitHub
Mar 13, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed ProgressIndicator accentColor dependency. (#77976)
parent
f5cb666f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
98 additions
and
12 deletions
+98
-12
progress_indicator.dart
packages/flutter/lib/src/material/progress_indicator.dart
+19
-7
progress_indicator_test.dart
packages/flutter/test/material/progress_indicator_test.dart
+79
-5
No files found.
packages/flutter/lib/src/material/progress_indicator.dart
View file @
fad7c367
...
@@ -43,6 +43,7 @@ abstract class ProgressIndicator extends StatefulWidget {
...
@@ -43,6 +43,7 @@ abstract class ProgressIndicator extends StatefulWidget {
Key
?
key
,
Key
?
key
,
this
.
value
,
this
.
value
,
this
.
backgroundColor
,
this
.
backgroundColor
,
this
.
color
,
this
.
valueColor
,
this
.
valueColor
,
this
.
semanticsLabel
,
this
.
semanticsLabel
,
this
.
semanticsValue
,
this
.
semanticsValue
,
...
@@ -62,18 +63,25 @@ abstract class ProgressIndicator extends StatefulWidget {
...
@@ -62,18 +63,25 @@ abstract class ProgressIndicator extends StatefulWidget {
/// The progress indicator's background color.
/// The progress indicator's background color.
///
///
/// The current theme's [
ThemeData.backgroundColor
] by default.
/// The current theme's [
ColorScheme.background
] by default.
///
///
/// This property is ignored if used in an adaptive constructor inside an iOS
/// This property is ignored if used in an adaptive constructor inside an iOS
/// environment.
/// environment.
final
Color
?
backgroundColor
;
final
Color
?
backgroundColor
;
/// The progress indicator's color as an animated value.
/// The progress indicator's color.
///
/// This is only used if [valueColor] is null. If [color] is also null,
/// then it defaults to the current theme's [ColorScheme.primary] by default.
///
///
/// To specify a constant color use: `AlwaysStoppedAnimation<Color>(color)`.
/// This property is ignored if used in an adaptive constructor inside an iOS
/// environment.
final
Color
?
color
;
/// The progress indicator's color as an animated value.
///
///
/// If null, the progress indicator is rendered with
the current theme'
s
/// If null, the progress indicator is rendered with
[color], or if that i
s
///
[ThemeData.accentColor
].
///
also null then with the current theme's [ColorScheme.primary
].
///
///
/// This property is ignored if used in an adaptive constructor inside an iOS
/// This property is ignored if used in an adaptive constructor inside an iOS
/// environment.
/// environment.
...
@@ -108,8 +116,8 @@ abstract class ProgressIndicator extends StatefulWidget {
...
@@ -108,8 +116,8 @@ abstract class ProgressIndicator extends StatefulWidget {
/// {@endtemplate}
/// {@endtemplate}
final
String
?
semanticsValue
;
final
String
?
semanticsValue
;
Color
_getBackgroundColor
(
BuildContext
context
)
=>
backgroundColor
??
Theme
.
of
(
context
).
backgroundColor
;
Color
_getBackgroundColor
(
BuildContext
context
)
=>
backgroundColor
??
Theme
.
of
(
context
).
colorScheme
.
background
;
Color
_getValueColor
(
BuildContext
context
)
=>
valueColor
?.
value
??
Theme
.
of
(
context
).
accentColor
;
Color
_getValueColor
(
BuildContext
context
)
=>
valueColor
?.
value
??
color
??
Theme
.
of
(
context
).
colorScheme
.
primary
;
@override
@override
void
debugFillProperties
(
DiagnosticPropertiesBuilder
properties
)
{
void
debugFillProperties
(
DiagnosticPropertiesBuilder
properties
)
{
...
@@ -305,6 +313,7 @@ class LinearProgressIndicator extends ProgressIndicator {
...
@@ -305,6 +313,7 @@ class LinearProgressIndicator extends ProgressIndicator {
Key
?
key
,
Key
?
key
,
double
?
value
,
double
?
value
,
Color
?
backgroundColor
,
Color
?
backgroundColor
,
Color
?
color
,
Animation
<
Color
?>?
valueColor
,
Animation
<
Color
?>?
valueColor
,
this
.
minHeight
,
this
.
minHeight
,
String
?
semanticsLabel
,
String
?
semanticsLabel
,
...
@@ -314,6 +323,7 @@ class LinearProgressIndicator extends ProgressIndicator {
...
@@ -314,6 +323,7 @@ class LinearProgressIndicator extends ProgressIndicator {
key:
key
,
key:
key
,
value:
value
,
value:
value
,
backgroundColor:
backgroundColor
,
backgroundColor:
backgroundColor
,
color:
color
,
valueColor:
valueColor
,
valueColor:
valueColor
,
semanticsLabel:
semanticsLabel
,
semanticsLabel:
semanticsLabel
,
semanticsValue:
semanticsValue
,
semanticsValue:
semanticsValue
,
...
@@ -544,6 +554,7 @@ class CircularProgressIndicator extends ProgressIndicator {
...
@@ -544,6 +554,7 @@ class CircularProgressIndicator extends ProgressIndicator {
Key
?
key
,
Key
?
key
,
double
?
value
,
double
?
value
,
Color
?
backgroundColor
,
Color
?
backgroundColor
,
Color
?
color
,
Animation
<
Color
?>?
valueColor
,
Animation
<
Color
?>?
valueColor
,
this
.
strokeWidth
=
4.0
,
this
.
strokeWidth
=
4.0
,
String
?
semanticsLabel
,
String
?
semanticsLabel
,
...
@@ -553,6 +564,7 @@ class CircularProgressIndicator extends ProgressIndicator {
...
@@ -553,6 +564,7 @@ class CircularProgressIndicator extends ProgressIndicator {
key:
key
,
key:
key
,
value:
value
,
value:
value
,
backgroundColor:
backgroundColor
,
backgroundColor:
backgroundColor
,
color:
color
,
valueColor:
valueColor
,
valueColor:
valueColor
,
semanticsLabel:
semanticsLabel
,
semanticsLabel:
semanticsLabel
,
semanticsValue:
semanticsValue
,
semanticsValue:
semanticsValue
,
...
...
packages/flutter/test/material/progress_indicator_test.dart
View file @
fad7c367
...
@@ -172,6 +172,7 @@ void main() {
...
@@ -172,6 +172,7 @@ void main() {
});
});
testWidgets
(
'LinearProgressIndicator with colors'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'LinearProgressIndicator with colors'
,
(
WidgetTester
tester
)
async
{
// With valueColor & color provided
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
const
Directionality
(
const
Directionality
(
textDirection:
TextDirection
.
ltr
,
textDirection:
TextDirection
.
ltr
,
...
@@ -180,20 +181,76 @@ void main() {
...
@@ -180,20 +181,76 @@ void main() {
width:
200.0
,
width:
200.0
,
child:
LinearProgressIndicator
(
child:
LinearProgressIndicator
(
value:
0.25
,
value:
0.25
,
valueColor:
AlwaysStoppedAnimation
<
Color
>(
Colors
.
white
),
backgroundColor:
Colors
.
black
,
backgroundColor:
Colors
.
black
,
color:
Colors
.
blue
,
valueColor:
AlwaysStoppedAnimation
<
Color
>(
Colors
.
white
),
),
),
),
),
),
),
),
),
);
);
// Should use valueColor
expect
(
expect
(
find
.
byType
(
LinearProgressIndicator
),
find
.
byType
(
LinearProgressIndicator
),
paints
paints
..
rect
(
rect:
const
Rect
.
fromLTRB
(
0.0
,
0.0
,
200.0
,
4.0
))
..
rect
(
rect:
const
Rect
.
fromLTRB
(
0.0
,
0.0
,
200.0
,
4.0
))
..
rect
(
rect:
const
Rect
.
fromLTRB
(
0.0
,
0.0
,
50.0
,
4.0
),
color:
Colors
.
white
),
..
rect
(
rect:
const
Rect
.
fromLTRB
(
0.0
,
0.0
,
50.0
,
4.0
),
color:
Colors
.
white
),
);
);
// With just color provided
await
tester
.
pumpWidget
(
const
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Center
(
child:
SizedBox
(
width:
200.0
,
child:
LinearProgressIndicator
(
value:
0.25
,
backgroundColor:
Colors
.
black
,
color:
Colors
.
white12
,
),
),
),
),
);
// Should use color
expect
(
find
.
byType
(
LinearProgressIndicator
),
paints
..
rect
(
rect:
const
Rect
.
fromLTRB
(
0.0
,
0.0
,
200.0
,
4.0
))
..
rect
(
rect:
const
Rect
.
fromLTRB
(
0.0
,
0.0
,
50.0
,
4.0
),
color:
Colors
.
white12
),
);
// With no color provided
const
Color
primaryColor
=
Color
(
0xff008800
);
final
ThemeData
theme
=
ThemeData
(
colorScheme:
ColorScheme
.
fromSwatch
().
copyWith
(
primary:
primaryColor
));
await
tester
.
pumpWidget
(
Theme
(
data:
theme
,
child:
const
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Center
(
child:
SizedBox
(
width:
200.0
,
child:
LinearProgressIndicator
(
value:
0.25
,
backgroundColor:
Colors
.
black
,
),
),
),
),
),
);
// Should use the theme's primary color
expect
(
find
.
byType
(
LinearProgressIndicator
),
paints
..
rect
(
rect:
const
Rect
.
fromLTRB
(
0.0
,
0.0
,
200.0
,
4.0
))
..
rect
(
rect:
const
Rect
.
fromLTRB
(
0.0
,
0.0
,
50.0
,
4.0
),
color:
primaryColor
),
);
});
});
testWidgets
(
'LinearProgressIndicator with animation with null colors'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'LinearProgressIndicator with animation with null colors'
,
(
WidgetTester
tester
)
async
{
...
@@ -275,22 +332,39 @@ void main() {
...
@@ -275,22 +332,39 @@ void main() {
expect
(
find
.
byType
(
CircularProgressIndicator
),
paints
..
arc
(
strokeWidth:
16.0
));
expect
(
find
.
byType
(
CircularProgressIndicator
),
paints
..
arc
(
strokeWidth:
16.0
));
});
});
testWidgets
(
'CircularProgressIndicator paint
background color
'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'CircularProgressIndicator paint
colors
'
,
(
WidgetTester
tester
)
async
{
const
Color
green
=
Color
(
0xFF00FF00
);
const
Color
green
=
Color
(
0xFF00FF00
);
const
Color
blue
=
Color
(
0xFF0000FF
);
const
Color
blue
=
Color
(
0xFF0000FF
);
const
Color
red
=
Color
(
0xFFFF0000
);
// With valueColor & color provided
await
tester
.
pumpWidget
(
const
CircularProgressIndicator
(
await
tester
.
pumpWidget
(
const
CircularProgressIndicator
(
color:
red
,
valueColor:
AlwaysStoppedAnimation
<
Color
>(
blue
),
valueColor:
AlwaysStoppedAnimation
<
Color
>(
blue
),
));
));
expect
(
find
.
byType
(
CircularProgressIndicator
),
paintsExactlyCountTimes
(
#drawArc
,
1
));
expect
(
find
.
byType
(
CircularProgressIndicator
),
paintsExactlyCountTimes
(
#drawArc
,
1
));
expect
(
find
.
byType
(
CircularProgressIndicator
),
paints
..
arc
(
color:
blue
));
expect
(
find
.
byType
(
CircularProgressIndicator
),
paints
..
arc
(
color:
blue
));
// With just color provided
await
tester
.
pumpWidget
(
const
CircularProgressIndicator
(
await
tester
.
pumpWidget
(
const
CircularProgressIndicator
(
backgroundColor:
green
,
color:
red
,
valueColor:
AlwaysStoppedAnimation
<
Color
>(
blue
),
));
));
expect
(
find
.
byType
(
CircularProgressIndicator
),
paintsExactlyCountTimes
(
#drawArc
,
1
));
expect
(
find
.
byType
(
CircularProgressIndicator
),
paints
..
arc
(
color:
red
));
// With no color provided
await
tester
.
pumpWidget
(
Theme
(
data:
ThemeData
(
colorScheme:
ColorScheme
.
fromSwatch
().
copyWith
(
primary:
green
)),
child:
const
CircularProgressIndicator
(),
));
expect
(
find
.
byType
(
CircularProgressIndicator
),
paintsExactlyCountTimes
(
#drawArc
,
1
));
expect
(
find
.
byType
(
CircularProgressIndicator
),
paints
..
arc
(
color:
green
));
// With background
await
tester
.
pumpWidget
(
const
CircularProgressIndicator
(
backgroundColor:
green
,
color:
blue
,
));
expect
(
find
.
byType
(
CircularProgressIndicator
),
paintsExactlyCountTimes
(
#drawArc
,
2
));
expect
(
find
.
byType
(
CircularProgressIndicator
),
paintsExactlyCountTimes
(
#drawArc
,
2
));
expect
(
find
.
byType
(
CircularProgressIndicator
),
paints
..
arc
(
color:
green
)..
arc
(
color:
blue
));
expect
(
find
.
byType
(
CircularProgressIndicator
),
paints
..
arc
(
color:
green
)..
arc
(
color:
blue
));
});
});
...
...
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