我试过以下代码片段:
new Container(
height: 80.0,
width: 80.0,
decoration: new BoxDecoration
shape: BoxShape.circle,
border: Border.all(color: const Color(0x33A6A6A6)),
// image: new Image.asset(_image.)
),
child: new Image.file(_image),
));
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
您可以尝试半径为50 的BoxDecoration类:
new Container(
height: 80.0,
width: 80.0,
decoration: new BoxDecoration(
color: const Color(0xff7c94b6),
borderRadius: BorderRadius.all(const Radius.circular(50.0)),
border: Border.all(color: const Color(0xFF28324E)),
),
child: new Image.file(_image)
),
Run Code Online (Sandbox Code Playgroud)
在CircleAvatar类:
new CircleAvatar(
backgroundColor: Colors.brown.shade800,
child: new Image.file(_image),
),
Run Code Online (Sandbox Code Playgroud)
或者更具体地说,你的代码(在BoxDecoration之后缺少,并且有很多).
所以使用BoxShape类:
new Container(
height: 80.0,
width: 80.0,
decoration: new BoxDecoration(
shape: BoxShape.circle,
border: Border.all(color: const Color(0x33A6A6A6)),
// image: new Image.asset(_image.)
),
child: new Image.file(_image),
),
Run Code Online (Sandbox Code Playgroud)
在这里,您可以这样做来设置占位符图像并从相机/图库中选取图像
GestureDetector(
onTap: () => onProfileClick(context), // choose image on click of profile
child: Container(
width: 150,
height: 150,
decoration: BoxDecoration(
shape: BoxShape.circle,
image: DecorationImage(
image: profilePhoto == null //profilePhoto which is File object
? AssetImage(
"assets/images/profile_placeholder.png")
: FileImage(profilePhoto), // picked file
fit: BoxFit.fill)),
),
),
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3392 次 |
| 最近记录: |