Reputation: 31
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?
Upvotes: 0
Views: 1652
Reputation: 7148
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
Upvotes: 1
Reputation: 14785
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
},
)
],
),
Upvotes: 1
Reputation: 27
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'),
)
],
),
Upvotes: 1