DEV Community

sidcode
sidcode

Posted on

1

Don't use 'BuildContext's across async gaps.

Don't use 'BuildContext's across async gaps.
Try rewriting the code to not use the 'BuildContext', or guard the use with a 'mounted' check.dartuse_build_context_synchronously

context.mounted
Enter fullscreen mode Exit fullscreen mode

Just wrap the error part with the following. We will process it after confirming the mount.

if (context. mounted) {

if (context.mounted) {
      if (isPrayedToday < 1) {
        _modalSalatFaithWrite.salatWrite(context, _controller);
      } else {
        _getShowModalAlreadyToday(context,
            S.of(context).modal_today_prayer_already);
      }
    }
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay