Home > Net >  TextButton the named parameter 'child' isn't defined
TextButton the named parameter 'child' isn't defined

Time:11-28

I got errors when updating my flutter version to 3.3.8. All of textbutton class has these errors. Actually, I just need to use elevatedButton but Im curious what is the correct syntax if we want to use textbutton?

enter image description here

CodePudding user response:

The style inside your style: TextButton.styleform needed a ButtonStyle as a type. you can't put a TextButton widget insedo of Textbutton too

this is a simple TextButton that you can refer

TextButton(
    child: Text('Text'),
    style: ButtonStyle(backgroundColor: MaterialStateProperty.all(Colors.red)),
    onPressed: () {
         // action on pressed
    },
),

CodePudding user response:

Try below code:

TextButton(
          onPressed: () =>handleSignUp(),
          style: TextButton.styleFrom(
            backgroundColor: Colors.green,
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(12),
            ),
          ),
          child: const Text('DAFTAR'),
        ),
  • Related