when I use setState () the text appears in the debug console..
setState() callback argument returned a Future. The setState() method on _LoginActivityState#9cd91 was called with a closure or method that returned a Future. Maybe it is marked as "async". Instead of performing asynchronous work inside a call to setState(), first execute the work (without updating the widget state), and then synchronously update the state inside a call to setState().
Future<void> login() async {
final formState = formKey.currentState;
if (formState.validate()) {
formState.save();
try {
final response = await UserController.login({
"username": username,
"password": password,
});
if (response != null && response["success"]) {
setState(() async {
accessToken = response['token'];
//print(token);
if (accessToken != null) {
await Http.setAccessToken("Bearer $accessToken");
}
print('$accessToken');
final getMe = await AiframeworkController.getProfile();
print('data: $getMe');
if (getMe != null && getMe['is_verified'] == true) {
return Navigator.pushReplacement(
context, MaterialPageRoute(builder: (context) => MainActivity()));
} else {
return Center(
child: CircularProgressIndicator(),
);
}
});
}
} catch (e) {
print(e.message);
}
}
}