如何在抽屉颤振上显示用户角色
How to display user role on a drawer flutter
我当前在用户登录后在我的抽屉中显示电子邮件和姓名。角色存储在 firestore 上。
我想显示用户角色,例如“免费或 VIP”
但是我找不到适合 UserAccountsDrawerHeader
小部件的 属性 有什么想法吗?
UserAccountsDrawerHeader(
accountName: Text(
_name,
style: TextStyle(
fontFamily: FontFamily.elgantfamily,
fontWeight: FontWeight.bold),
),
accountEmail: Text(
_email,
style:
TextStyle(fontFamily: FontFamily.elgantfamily),
),
accountRole: Text(
_role,
style: TextStyle(
fontFamily: FontFamily.elgantfamily,
fontWeight: FontWeight.bold),
),
),
_getUserNameandEmail() async {
String uid = await GetStorage().read(sharedPrefrenceKey.uuid);
if (uid != null) {
_name = GetStorage().read(sharedPrefrenceKey.name);
_email = GetStorage().read(sharedPrefrenceKey.email);
_role = GetStorage().read(sharedPrefrenceKey.role);
setState(() {});
}
}
如果你真的想使用UserAccountsDrawerHeader
你可以这样做
UserAccountsDrawerHeader(
accountName: Text('User Name'),
accountEmail: Text('Email'),
otherAccountsPictures: [
Text(
'Role',style: TextStyle(
color: Colors.red
),
)
],
)
我当前在用户登录后在我的抽屉中显示电子邮件和姓名。角色存储在 firestore 上。
我想显示用户角色,例如“免费或 VIP”
但是我找不到适合 UserAccountsDrawerHeader
小部件的 属性 有什么想法吗?
UserAccountsDrawerHeader(
accountName: Text(
_name,
style: TextStyle(
fontFamily: FontFamily.elgantfamily,
fontWeight: FontWeight.bold),
),
accountEmail: Text(
_email,
style:
TextStyle(fontFamily: FontFamily.elgantfamily),
),
accountRole: Text(
_role,
style: TextStyle(
fontFamily: FontFamily.elgantfamily,
fontWeight: FontWeight.bold),
),
),
_getUserNameandEmail() async {
String uid = await GetStorage().read(sharedPrefrenceKey.uuid);
if (uid != null) {
_name = GetStorage().read(sharedPrefrenceKey.name);
_email = GetStorage().read(sharedPrefrenceKey.email);
_role = GetStorage().read(sharedPrefrenceKey.role);
setState(() {});
}
}
如果你真的想使用UserAccountsDrawerHeader
你可以这样做
UserAccountsDrawerHeader(
accountName: Text('User Name'),
accountEmail: Text('Email'),
otherAccountsPictures: [
Text(
'Role',style: TextStyle(
color: Colors.red
),
)
],
)