Home > Mobile >  The named parameter 'onTap' isn't defined in my code
The named parameter 'onTap' isn't defined in my code

Time:12-07

I currently learning Flutter and I'm very new to it. I wanted to go to another page when tap on this text but my bad it gives me this error.

  return Expanded(
    flex: 1,
    child: Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: <Widget>[
        GestureDetector(
          oneTap: () { // i got error here
            Navigator.push(context, MaterialPageRoute(builder: (context) => SingUpPage()));
          },
          child: Text(
            'Sing up',
            style: GoogleFonts.openSans(
                fontSize: 18,
                fontWeight: FontWeight.w700,
                decoration: TextDecoration.underline),
          ),
        ),
        Text(
          'Forgot Password',
          style: GoogleFonts.openSans(
              fontSize: 18,
              fontWeight: FontWeight.w700,
              decoration: TextDecoration.underline),
        )
      ],
    ),
  );
}

CodePudding user response:

You are making a typo/mistake on oneTap, change it to onTap.

CodePudding user response:

you mean "onTap" not "oneTap"

 onTap: () { // <--- this one
            Navigator.push(context, MaterialPageRoute(builder: (context) => SingUpPage()));
          }

CodePudding user response:

Rename onTap instead of oneTap

onTap: () { // here change needed
            Navigator.push(context, MaterialPageRoute(builder: (context) => SingUpPage()));
          },
  • Related