Skip to content
Back

how to get username

  • 0
  • Self Hosted
  • Flutter
BOB
2 Dec, 2023, 17:19

how can i get username of the user as a string in flutter

TL;DR
The user wants to know how to get the username in Flutter. They are advised to call `toMap()` on the returned `User` object from `account.get()` and then parse the data to retrieve the username. An example code is provided to demonstrate this.
Drake
3 Dec, 2023, 00:41

account.get() will get the current user. Then, get the name field:

https://appwrite.io/docs/references/cloud/client-web/account#get

BOB
3 Dec, 2023, 03:22

thanks

BOB
3 Dec, 2023, 06:25

sry im a noob

BOB
3 Dec, 2023, 06:27

can u give me a example code

BOB
3 Dec, 2023, 06:27

im only getting user as output

Vedsaga
3 Dec, 2023, 13:02

it return user-object.. inside that you will see many details...

but, what do you mean by username? do you mean unique identitifer?

BOB
3 Dec, 2023, 17:41

yes

jaydenclerk
4 Dec, 2023, 13:53

Do you have a profiles collection?

Ernest
4 Dec, 2023, 15:41

Just to give you an idea you'd call toMap() on the returned User object from account.get() then parse the data however you want. A simple example demonstrating what I mean:

TypeScript
final userAccount = await account.get();
final userAccountMap = userAccount.toMap();
final id = userAccountMap["\$id"];
final name = userAccountMap["name"];
final email = userAccountMap["email"];
BOB
6 Dec, 2023, 19:39

thank you ur so help

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more