zwe*_*bar 8 icons center dart flutter
我想将相机图标居中,但我做不到。我尝试使用图像而不是图标,但这仍然不起作用。我认为它不起作用,因为不可能在 CircleAvatar 上放置图标,但必须有办法做到这一点。这是我的代码:
return SizedBox(
height: 115,
width: 115,
child: Stack(
clipBehavior: Clip.none,
fit: StackFit.expand,
children: [
CircleAvatar(
backgroundImage: AssetImage("assets/images/Profile Image.png"),
),
Positioned(
right: -16,
bottom: 0,
child: SizedBox(
height: 46,
width: 46,
child: FlatButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50),
side: BorderSide(color: Colors.white),
),
color: Color(0xFFF5F6F9),
onPressed: () {},
// TODO: Icon not centered.
child: Center(child: Icon(Icons.camera_alt_outlined)),
)))
],
),
);
Run Code Online (Sandbox Code Playgroud)
zwe*_*bar 13
Widget build(BuildContext context) {
return SizedBox(
height: 115,
width: 115,
child: Stack(
clipBehavior: Clip.none,
fit: StackFit.expand,
children: [
CircleAvatar(
backgroundImage: AssetImage("assets/images/Profile Image.png"),
),
Positioned(
bottom: 0,
right: -25,
child: RawMaterialButton(
onPressed: () {},
elevation: 2.0,
fillColor: Color(0xFFF5F6F9),
child: Icon(Icons.camera_alt_outlined, color: Colors.blue,),
padding: EdgeInsets.all(15.0),
shape: CircleBorder(),
)),
],
),
);
}
Run Code Online (Sandbox Code Playgroud)
我删除了 SizedBox 并使用 RawMaterialButton 代替。
不使用 CircleAvatar,而是使用这样的容器:
Container(
height: 46,
width: 46,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.green,
),
child: Icon(Icons.camera, color: Colors.white,),
alignment: Alignment.center,
),
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
29074 次 |
| 最近记录: |