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
- Current User is Not authorized
recreating same Thread
- Apple OAuth Scopes
Hi Hi, I've configured sign in with apple and this is the response i'm getting from apple once i've signed in. I cant find anywhere I set scopes. I remember se...
- Sign In With Apple OAuth Help
Hi All! I've got a flutter & appwrite app which Im trying to use sign in with apple for. I already have sign in with google working and the function is the sam...