为什么我无法在 Flutter 中更改 AppBar 中 CircleAvatar 或其他圆形小部件的高度?
Why I can't change the height of CircleAvatar or other circular widgets in AppBar in Flutter?
我试图在操作列表的 AppBar
内放置一个 CircleAvatar
,但 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
包装在 Row
中:
actions: [
Row(
children: <Widget>[
Container(
height: 60,
width: 60,
child: CircleAvatar(
backgroundImage:
NetworkImage("https://picsum.photos/500/300"),
maxRadius: 15,
minRadius: 15,
),
),
],
),
],
结果:
我试图在操作列表的 AppBar
内放置一个 CircleAvatar
,但 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
包装在 Row
中:
actions: [
Row(
children: <Widget>[
Container(
height: 60,
width: 60,
child: CircleAvatar(
backgroundImage:
NetworkImage("https://picsum.photos/500/300"),
maxRadius: 15,
minRadius: 15,
),
),
],
),
],
结果: