Search code examples
flutterdartwidgetdart-null-safetynull-safety

The following _CastError was thrown building Builder: Null check operator used on a null value


I suddenly encountered this error while doing cloud firestore operations. Even when I undo my actions, I couldn't resolve the error. I don't know exactly what caused it. I look forward to your support in this matter.

main.dart

Debug Console

═══════ Exception caught by widgets library ═══════════════════════════════════
The following _CastError was thrown building Builder:
Null check operator used on a null value

The relevant error-causing widget was
MaterialApp
lib/main.dart:25
When the exception was thrown, this was the stack
#0      new Auth
package:projedersi/auth.dart:7
#1      new _LoginPageState
package:projedersi/loginPage.dart:48
#2      LoginPage.createState
package:projedersi/loginPage.dart:24
#3      new StatefulElement
package:flutter/…/widgets/framework.dart:4964
#4      StatefulWidget.createElement
package:flutter/…/widgets/framework.dart:763
...     Normal element mounting (275 frames)



Solution

  • Somewhere in the main.dart you passed a null param somewhere which should not be null. Please share your main.dart snippet for more help.