
Account account = Account(db()); // assuming db() is an instance of Client?
const user = account.get('[USER-ID]');
const user_name = user.name;


Ah I'm sorry

I've been so used to the web sdk i forgot you're on flutter lol

https://appwrite.io/docs/client/account?sdk=flutter-default#accountGet Just have a look at this!

ok. so i have to use this?
Future result = account.get();
result.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});```
but how can i get the username?

result.name

i dont think so, because this is an unresolved reference, but something like that (this example doesnt work)
Future result = account.get();
result.then((response) {
return response["name"];
}).catchError((error) {
print(error.response);
});```

what version of appwrite are you using?

and what's your sdk version?

dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
appwrite: ^8.1.0```

and what's the appwrite version?

cloud or self hosted?

atm cloud, but in production it should be the second

can you try using async-await instead of then?

same error

what's the exact error?

can you show your full code snippet?

nvm no error,
so i have this, but this just prints instance of response
dynamic user() {
Account account = Account(db());
Future result = account.get();
result.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}```

ah i have fixed it

but thank you anyway!

Can you share how did you fix it?

When im home yes

[SOLVED] How can i get a Username?

Future<String> name() async {
try {
var getUser = await account().get();
return getUser.name;
} catch(error) {
return error.toString();
}
}```
Recommended threads
- Flutter OAuth2 Google does not return to...
When the flow starts, the browser opens, I select an account, and it keeps showing: """ Page not found The page you're looking for doesn't exist. `general_rout...
- Redirect URL sends HTTP instead of HTTPS...
I am not sure since when this issue is present, but my Google and Apple redirect URI are no longer pointing to the HTTPS redirect URI when I try to use OAuth. ...
- Failing to run document operations on sd...
Could someone point me in the right direction I'm going in cirlces. I have a problem with sdks and my self-hosted server in production (for ~3 years) I have bee...
