我试图将
CircleAvatar
放入操作列表中的 AppBar
内,但 CircleAvatar 会将其高度固定到 AppBar 的高度,从而无法调整其大小并保持其圆形。我已经尝试将其包装在 Container 或 SizedBox 内,但没有成功。
示例:
import 'package:flutter/material.dart';
class HoursScreenEmployee extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.white10,
brightness: Brightness.light,
elevation: 0,
centerTitle: false,
actions: [
CircleAvatar(
backgroundImage: NetworkImage("https://picsum.photos/500/300"),
maxRadius: 15,
minRadius: 15,
),
],
title: Text(
"La Chance 🍻",
style: TextStyle(
fontFamily: "Masiva",
fontSize: 27,
fontWeight: FontWeight.w800,
color: Colors.black,
),
),
),
);
}
}
要更改圆形头像内图像的高度和宽度,请执行以下操作:
CircleAvatar(
radius: 20,
child: CircleAvatar(
radius: 15,
backgroundImage: AssetImage(
ImageAssets.micIcon,
),
),
),