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
3aa26cb1
Commit
3aa26cb1
authored
Jul 21, 2016
by
Dragoș Tiselice
Committed by
GitHub
Jul 21, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4971 from flutter/circle-avatar-background-image
Added backgroundImage to CircleAvatar.
parents
2e1a89cf
83f37246
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
3 deletions
+38
-3
circle_avatar.dart
packages/flutter/lib/src/material/circle_avatar.dart
+12
-3
circle_avatar_test.dart
packages/flutter/test/material/circle_avatar_test.dart
+26
-0
No files found.
packages/flutter/lib/src/material/circle_avatar.dart
View file @
3aa26cb1
...
...
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/services.dart'
;
import
'package:flutter/widgets.dart'
;
import
'constants.dart'
;
...
...
@@ -24,7 +25,8 @@ class CircleAvatar extends StatelessWidget {
Key
key
,
this
.
child
,
this
.
backgroundColor
,
this
.
radius
:
40.0
this
.
backgroundImage
,
this
.
radius
:
20.0
})
:
super
(
key:
key
);
/// The widget below this widget in the tree.
...
...
@@ -34,6 +36,10 @@ class CircleAvatar extends StatelessWidget {
/// color will cause the avatar to animate to the new color.
final
Color
backgroundColor
;
/// The background image of the circle. Changing the background
/// image will cause the avatar to animate to the new image.
final
ImageProvider
backgroundImage
;
/// The size of the avatar. Changing the radius will cause the
/// avatar to animate to the new size.
final
double
radius
;
...
...
@@ -44,11 +50,14 @@ class CircleAvatar extends StatelessWidget {
final
Color
color
=
backgroundColor
??
theme
.
primaryColor
;
return
new
AnimatedContainer
(
width:
radius
,
height:
radius
,
width:
radius
*
2.0
,
height:
radius
*
2.0
,
duration:
kThemeChangeDuration
,
decoration:
new
BoxDecoration
(
backgroundColor:
color
,
backgroundImage:
backgroundImage
!=
null
?
new
BackgroundImage
(
image:
backgroundImage
)
:
null
,
shape:
BoxShape
.
circle
),
child:
new
Center
(
...
...
packages/flutter/test/material/circle_avatar_test.dart
0 → 100644
View file @
3aa26cb1
// 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/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
testWidgets
(
'CircleAvatar test'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
new
Center
(
child:
new
CircleAvatar
(
backgroundColor:
Colors
.
blue
[
400
],
radius:
50.0
,
child:
new
Text
(
'Z'
)
)
)
);
RenderBox
box
=
tester
.
renderObject
(
find
.
byType
(
CircleAvatar
));
expect
(
box
.
size
.
width
,
equals
(
100.0
));
expect
(
box
.
size
.
height
,
equals
(
100.0
));
expect
(
find
.
text
(
'Z'
),
findsOneWidget
);
});
}
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