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
- [SOLVED] curl error Number: 6 — function...
Hello, I invested a lot of time in this error in a fresh install of appwrite 1.8.1 and lasted until fix, this if for helping anyone that can have the same weird...
- android platform invaild origina
It happened today suddenly. Our app says invalid origin. And appwrite cloud says every time we tried to add the app to it: "param platformId" is not optional.
- Team invite - 500 error - no email
When executing ```dart await _repository.teams.createMembership( teamId: event.listId, roles: ['member'], email: event.email, url: 'xxxx', ); ``` I se...