Why im getting this error: Im using this the exact way in other classes and it works just in that case it gives this error:
======== Exception caught by widgets library =======================================================
The following NoSuchMethodError was thrown building Wrapper(dirty, dependencies: [_InheritedProviderScope<Userr>]):
The getter 'emailVerified' was called on null.
Receiver: null
Tried calling: emailVerified
The relevant error-causing widget was:
Wrapper file:///Users/name/StudioProjects/project/lib/main.dart:47:36
When the exception was thrown, this was the stack:
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
#1 Wrapper.build (package:projectandroidstudiodenya/wrapper.dart:23:42)
#2 StatelessElement.build (package:flutter/src/widgets/framework.dart:4661:28)
#3 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4587:15)
#4 Element.rebuild (package:flutter/src/widgets/framework.dart:4281:5)
...
====================================================================================================
This is my Wrapper class```
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:projectandroidstudiodenya/authenticate/resetpassword.dart';
import 'package:projectandroidstudiodenya/seitenleiste/homepage.dart';
import 'package:provider/provider.dart';
import 'authenticate/authenticate.dart';
import 'models/user.dart';
class Wrapper extends StatelessWidget {
static const route='/Wrapper';
@override
Widget build(BuildContext context) {
//Auth.auth().currentUser.isEmailVerified;
//final user = Provider.of<UserCredential>(context);
final user = Provider.of<Userr>(context);
if(FirebaseAuth.instance.currentUser.emailVerified){
return Homepage();
}else if( FirebaseAuth.instance.currentUser != null) {
return Authenticate();
}else if(FirebaseAuth.instance.currentUser ==null){
return Resedpasswort();
}
//return Home or Authenticate widget
}
}
I tried FirebaseAuth.instance.currentUser.emailVerified.=null and also ==null. Same error Please help and also user.emailverfiyed is not working. I need to use this this way I think. So as I said in other classes this works .
The issue here is that the currentUser
is null not emailVerified
.
Try this:
class Wrapper extends StatelessWidget {
static const route='/Wrapper';
@override
Widget build(BuildContext context) {
//Auth.auth().currentUser.isEmailVerified;
//final user = Provider.of<UserCredential>(context);
final user = Provider.of<User>(context);
if( FirebaseAuth.instance.currentUser == null) {
return Authenticate();
else if(FirebaseAuth.instance.currentUser.emailVerified){
return Homepage();
}
else if(FirebaseAuth.instance.currentUser != null){
return ResetPassword();
}
else
//return Home or Authenticate widget
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.