Skip to main content
deleted 4 characters in body
Source Link
Munsif Ali
  • 7.8k
  • 7
  • 33
  • 65

Convert the then chain to async-await for better readability and context safety.
Add a StatefulWidget and use if (!mounted) return; before using context.

Example:

final profile = await apiService.checkOTP(_emailController.text, s);
if (profile != null) {
if (!mounted) return;
Navigator.push(context, MaterialPageRoute(...));
}

final profile = await apiService.checkOTP(_emailController.text, s);
if (profile != null) {
  if (!mounted) return;
  Navigator.push(context, MaterialPageRoute(...));
}

Convert the then chain to async-await for better readability and context safety.
Add a StatefulWidget and use if (!mounted) return; before using context.

Example:

final profile = await apiService.checkOTP(_emailController.text, s);
if (profile != null) {
if (!mounted) return;
Navigator.push(context, MaterialPageRoute(...));
}

Convert the then chain to async-await for better readability and context safety.
Add a StatefulWidget and use if (!mounted) return; before using context.

Example:

final profile = await apiService.checkOTP(_emailController.text, s);
if (profile != null) {
  if (!mounted) return;
  Navigator.push(context, MaterialPageRoute(...));
}
Source Link

Convert the then chain to async-await for better readability and context safety.
Add a StatefulWidget and use if (!mounted) return; before using context.

Example:

final profile = await apiService.checkOTP(_emailController.text, s);
if (profile != null) {
if (!mounted) return;
Navigator.push(context, MaterialPageRoute(...));
}