Search code examples
flutterflutter-dependenciesoverlay

I have an error in the in the overlay.dart file when compliling the flutter project


when building my flutter project that was compiling perfectly without any problem before but since yesterday i got that problem enter image description here ans i did all what i could do by upgrading the packages and the flutter itself, but the problem isn't solved

so if anyone face the same problem or have a solution for this problem i would be very thankful


Solution

  • The reason you get the error is Overlay.of(context) could be null. Nullable object should access its field with ?..

    Replace Overlay.of(context).context.findRenderObject() with Overlay.of(context)?.context?.findRenderObject() will do the fix.