Last active
April 28, 2021 21:41
-
-
Save sendbird-community/4b7d33383edee670e43cf167ba65469c to your computer and use it in GitHub Desktop.
Flutter | Get application users
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Future<List<User>> getUsers() async { | |
try { | |
final query = ApplicationUserListQuery(); | |
List<User> users = await query.loadNext(); | |
return users; | |
} catch (e) { | |
print('getUsers: ERROR: $e'); | |
return []; | |
} | |
} | |
@override | |
void initState() { | |
super.initState(); | |
getUsers().then((users) { | |
setState(() { | |
_availableUsers.clear(); | |
_availableUsers.addAll(users); | |
}); | |
}).catchError((e) { | |
print('initState: ERROR: $e'); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment