0

When I input TextButton inside either in Row or any Widget it's show error

The method 'TextButton' isn't defined for the type '_LoginScreenState'. Try correcting the name to the name of an existing method, or defining a method named 'TextButton'.dartundefined_method such this :

Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text('don \'t registered ? '),
            TextButton(child: Text('Register'),
          ],
        ) //Row

Did flutter update it to another widget?

3 Answers 3

1

I think you are missing the function onPressed. See below

Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text('don \'t registered ? '),
            TextButton(
              onPressed: () {},
              child: Text('Register'),
            )
          ],
        ),
Sign up to request clarification or add additional context in comments.

Comments

1

In your TextButton Widget you forgot the required property for onPressed function please add it, refer my answer below hope it's helpful to you. Refer official documentation here for TextButton

Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children:[
            Text('don \'t registered ? '),
            TextButton(
              child: Text('Register'),
              onPressed: () {
                    print ('Button pressed');// when you pressed on button console gives you the message test it
                   // Call your onPressed function here
                 },
            )
          ],
        ),

Comments

1

You were just missing a closing rounded bracket after "TextButton(child: Text('Register'),"

Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children:[
            Text('don \'t registered ? '),
            TextButton(
              child: Text('Register'),
              onPressed: () {
                    print ('Button pressed');// when you pressed on button console gives you the message test it
                   // Call your onPressed function here
                 },
            )
          ],
        ),

Just add a rounded bracket after it and you're done

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.