"_debugCurrentBuildTarget == context is not true" on page reload

2,748

Finally, I got it fixed!!! I'm using cloud_firestore in my app, the userId I was trying to access in my widget tree was not yet available at the time of render. I figured this out by wrapping the root widget return statement in a trycatch block, as soon as I did this, The error stopped since its being handled and I printed the error to the console, then I returned a progress loader in the catch block.

Share:
2,748
AbdulGafar Olamide Ajao
Author by

AbdulGafar Olamide Ajao

A Fullstack (Web, Mobile, Desktop, Backend) developer, with so much love for VueJs and Flutter.

Updated on December 21, 2022

Comments

  • AbdulGafar Olamide Ajao
    AbdulGafar Olamide Ajao over 1 year

    I get the below error whenever I refresh a page in my flutter web project

    _debugCurrentBuildTarget == context is not true
    at Object.throw_ [as throw] (errors.dart:216)
    at Object.assertFailed (errors.dart:26)
    at framework.dart:2611
    at framework.BuildOwner.new.buildScope (framework.dart:2614)
    at RenderObjectToWidgetAdapter.new.attachToRenderTree (binding.dart:1044)
    at binding$5.WidgetsFlutterBinding.new.attachRootWidget (binding.dart:924)
    at binding.dart:906
    at internalCallback (isolate_helper.dart:50)
    
    • Adelina
      Adelina almost 4 years
      Could u show your code, are u using MediaQuery.of(context) somewhere?
    • AbdulGafar Olamide Ajao
      AbdulGafar Olamide Ajao almost 4 years
      I use MediaQuery.of(context) a lot and the issue happens on all pages