skip to Main Content
 handleSignUp() async {
      if (await authProvider.register(
        name: nameController.text,
        username: usernameController.text,
        email: emailController.text,
        password: passwordController.text,
      )){

please help me for this to solve thanktyouuu

2

Answers


  1. It is possible your register will return null, you can directly use

    if(await method()==true){...}
    

    I will prefer to create a separate variable for this.

    final bool isRegistered  = await authProvider.register(
            name: nameController.text,
            username: usernameController.text,
            email: emailController.text,
            password: passwordController.text,
          ) ?? false; // providing false on null case
    
     if(isRegistered) { ....}
    
    Login or Signup to reply.
  2. if (await authProvider.register(
          name: nameController.text,
          username: usernameController.text,
          email: emailController.text,
          password: passwordController.text,
        ) !=
        null) {
      print('Registered');
    }else{
      print('Something went wrong');
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search