Home > Software engineering >  The named parameter 'color' isn't defined. flutter
The named parameter 'color' isn't defined. flutter

Time:10-20

body: Center(
       child: TextButton(
         onPressed: _handleSignIn,
         child: Text('Google Sign in'),
         color: Colors.amber,
       ),
     ),
   );

CodePudding user response:

You cant have color directly like that.

You can use style property like

child: TextButton(
  onPressed: () {},
  child: Text(
    'Google Sign in',
    style: TextStyle(
      color: Colors.green,
    ),
  ),
  style: ButtonStyle(
    textStyle: MaterialStateProperty.all(
      TextStyle(color: Colors.amber),
    ),
    backgroundColor: MaterialStateProperty.all(Colors.amber),
  ),
),

Find more about ButtonStyle

  • Related