垂直居中appbar中的文本-Flutter



我试图在应用程序栏中居中文本,但它无法垂直居中。我已经尝试了许多来自谷歌和tackoverflow的代码,但似乎不起作用。请提前帮助并感谢

appBar: AppBar(
// centerTitle: true,
backgroundColor: Colors.pink,
bottom: PreferredSize(
preferredSize: Size.fromHeight(200),
child: SizedBox(
height: 200,
),
),
title: Row(mainAxisAlignment: MainAxisAlignment.center ,children: [Text('weoijf')],)
,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(bottom: Radius.circular(100))
),
),

appbar问题

请找到下面的代码,我认为这将帮助你实现你想要的,如果有任何查询,请告诉我

appBar: PreferredSize(
preferredSize: Size.fromHeight(200),
child: AppBar(
// centerTitle: true,
backgroundColor: Colors.pink,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(bottom: Radius.circular(100))
),
flexibleSpace: Container(
alignment: Alignment.center,
child: Text(
'weoijf',
style: TextStyle(
color: Colors.white
),
),
),
),
)

感谢

您不能提供这样的标题,但如果您想在中心显示标题,请使用以下代码:-

appBar: AppBar(
backgroundColor: Colors.pink,
bottom: const PreferredSize(
preferredSize: Size.fromHeight(200),
child: SizedBox(
height: 240,
child: Center(
child: Text(
"weoijf",
style: TextStyle(color: Colors.white),
)),
),
),
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(bottom: Radius.circular(100))),
),

最新更新