gpt4 book ai didi

flutter - 在 flutter 中使用 UserAccountsDrawerHeader 时,如何将头像图像对齐?

转载 作者:行者123 更新时间:2023-12-04 03:47:51 25 4
gpt4 key购买 nike

当我想在 flutter endDrawer 中使用 UserAccountsDrawerHeader 时,如何设置所有头像图像以及 accountEmail 和 accountName 在抽屉的 中心 中对齐,在我的代码中,每件事都在左侧对齐?
这是我的代码:

endDrawer: Drawer(
child: BackdropFilter(
filter: ImageFilter.blur(
sigmaX: 1.8,
sigmaY: 1.8,
),
child: Column(
children: <Widget>[
Center( child:
UserAccountsDrawerHeader(
accountEmail: Text(
user.email ?? "user Email",
style: TextStyle(
color: Theme
.of(context)
.colorScheme
.onPrimary),
),
accountName: Text(
user.fullName ?? user.username ?? "user Name",
style: TextStyle(
color: Theme
.of(context)
.colorScheme
.onPrimary),
),
currentAccountPicture: GestureDetector(
onTap: () {},
child: Container(
child: InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ProfileScreen(
user: user,
),
),
);
},

我使用中心小部件,但它不起作用。

最佳答案

mam_65 尝试将它们包装在 Row 中:

...    
child: UserAccountsDrawerHeader(
accountEmail: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
user.email ?? "user Email",
style: TextStyle(
color: Theme.of(context).colorScheme.onPrimary),
),
],
),
accountName: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
user.fullName ?? user.username ?? "user Name",
style: TextStyle(
color: Theme.of(context).colorScheme.onPrimary),
),
],
),
...
注意: 无法将 currentAccountPicture 居中,因为它包含在带有 Row(最多 3 个小部件)的 otherAccountsPictures 中。为此,您必须自己自定义 Drawer

关于flutter - 在 flutter 中使用 UserAccountsDrawerHeader 时,如何将头像图像对齐?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64858443/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com