Async/await instead of then
Do
void getActiveUserCount() async { try { var users = await getActiveUsers(); debugPrint(users.length.toString()); } catch (error) { debugPrint(error.toString()); } }
Don't
void getActiveUserCount() { getActiveUsers().then((user) { debugPrint(users.length.toString()); }).catchError((error) { debugPrint(error.toString()); } }
Conclusion: There's no meaningful difference between the two versions of your code. Both achieve the same result. But await can often save you a bunch of lines of code making your code simpler to read, test and maintain.