Search code examples
flutterdartflutter-layout

The named parameter 'color' isn't defined. flutter


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

Solution

  • 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