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
21899ce6
Commit
21899ce6
authored
Sep 29, 2017
by
Ian Hickson
Committed by
Todd Volkert
Sep 29, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Honor more of the Theme for CircleAvatar with backgroundColor (#12333)
parent
f40d09e1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
6 deletions
+40
-6
circle_avatar.dart
packages/flutter/lib/src/material/circle_avatar.dart
+15
-4
circle_avatar_test.dart
packages/flutter/test/material/circle_avatar_test.dart
+25
-2
No files found.
packages/flutter/lib/src/material/circle_avatar.dart
View file @
21899ce6
...
...
@@ -5,9 +5,10 @@
import
'package:flutter/services.dart'
;
import
'package:flutter/widgets.dart'
;
import
'colors.dart'
;
import
'constants.dart'
;
import
'theme.dart'
;
import
't
ypography
.dart'
;
import
't
heme_data
.dart'
;
// Examples can assume:
// String userAvatarUrl;
...
...
@@ -91,9 +92,19 @@ class CircleAvatar extends StatelessWidget {
@override
Widget
build
(
BuildContext
context
)
{
final
ThemeData
theme
=
Theme
.
of
(
context
);
final
TextStyle
textStyle
=
backgroundColor
!=
null
?
new
Typography
(
platform:
theme
.
platform
).
white
.
title
:
theme
.
primaryTextTheme
.
title
;
TextStyle
textStyle
=
theme
.
primaryTextTheme
.
title
;
if
(
foregroundColor
!=
null
)
{
textStyle
=
textStyle
.
copyWith
(
color:
foregroundColor
);
}
else
if
(
backgroundColor
!=
null
)
{
switch
(
ThemeData
.
estimateBrightnessForColor
(
backgroundColor
))
{
case
Brightness
.
dark
:
textStyle
=
textStyle
.
copyWith
(
color:
Colors
.
white
);
break
;
case
Brightness
.
light
:
textStyle
=
textStyle
.
copyWith
(
color:
Colors
.
black
);
break
;
}
}
return
new
AnimatedContainer
(
width:
radius
*
2.0
,
height:
radius
*
2.0
,
...
...
packages/flutter/test/material/circle_avatar_test.dart
View file @
21899ce6
...
...
@@ -7,8 +7,8 @@ import 'package:flutter/rendering.dart';
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
testWidgets
(
'CircleAvatar with background color'
,
(
WidgetTester
tester
)
async
{
final
Color
backgroundColor
=
Colors
.
blue
.
shade
4
00
;
testWidgets
(
'CircleAvatar with
dark
background color'
,
(
WidgetTester
tester
)
async
{
final
Color
backgroundColor
=
Colors
.
blue
.
shade
9
00
;
await
tester
.
pumpWidget
(
wrap
(
child:
new
CircleAvatar
(
...
...
@@ -30,6 +30,29 @@ void main() {
expect
(
paragraph
.
text
.
style
.
color
,
equals
(
Colors
.
white
));
});
testWidgets
(
'CircleAvatar with light background color'
,
(
WidgetTester
tester
)
async
{
final
Color
backgroundColor
=
Colors
.
blue
.
shade100
;
await
tester
.
pumpWidget
(
wrap
(
child:
new
CircleAvatar
(
backgroundColor:
backgroundColor
,
radius:
50.0
,
child:
const
Text
(
'Z'
),
),
),
);
final
RenderConstrainedBox
box
=
tester
.
renderObject
(
find
.
byType
(
CircleAvatar
));
expect
(
box
.
size
.
width
,
equals
(
100.0
));
expect
(
box
.
size
.
height
,
equals
(
100.0
));
final
RenderDecoratedBox
child
=
box
.
child
;
final
BoxDecoration
decoration
=
child
.
decoration
;
expect
(
decoration
.
color
,
equals
(
backgroundColor
));
final
RenderParagraph
paragraph
=
tester
.
renderObject
(
find
.
text
(
'Z'
));
expect
(
paragraph
.
text
.
style
.
color
,
equals
(
Colors
.
black
));
});
testWidgets
(
'CircleAvatar with foreground color'
,
(
WidgetTester
tester
)
async
{
final
Color
foregroundColor
=
Colors
.
red
.
shade100
;
await
tester
.
pumpWidget
(
...
...
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