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
- Error With iOS Apps
I keep getting the below errors for my flutter app. The clients are registered and have been. This wasn't an issue a few hours ago. AppwriteException: AppwriteE...
- Appwrite Auth & Function don't reveal cl...
When I execute a function or sign in with my Flutter app, Appwrite does not show my real IP: instead, it seems that Appwrite shows Fastly CDN IP address.
- Why does this happen?
`AppwriteException: general_argument_invalid, Invalid `secret` param: Value must be a valid string and at least 1 chars and no longer than 256 chars (400)` the...