if i directly call the navigator.pushnamed method I receive a message that says, Don't use 'BuildContext's across async gaps. I don't know how to solve this problem and move to next screen. this is the code
color: Colors.blueAccent,
title: 'Register',
onPressed: () async {
try {
final newUser = await _auth.createUserWithEmailAndPassword(
email: email, password: password);
if (newUser.user != null) {
await Future.delayed(Duration.zero);
Navigator.of(context).pushNamed(ChatScreen.id);
}
} catch (e) {
print(e);
}
},
),
```