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

How can align the avatar image in the center, when use UserAccountsDrawerHeader in flutter?

当我想在 flutter endDrawer 中使用 UserAccountsDrawerHeader 时,如何设置所有头像图像和 accountEmail 和 accountName 在抽屉的 center 对齐,在我的代码中,所有东西都对齐离开了?

这是我的代码:

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 居中,因为它包含在 RowotherAccountsPictures 中(最多 3 个小部件)。为此,您必须自己定制 Drawer