Style a TextButton as Delete button in Flutter
1 min read

Style a TextButton as Delete button in Flutter

To give the delete button look to a TextButton, give a style makeover to it.

TextButton(
  child: Text('Delete'),
  onPressed: () {
    // Perform the delete operation
  },
  style: TextButton.styleFrom(
    primary: Colors.white, // Set text color
    backgroundColor: Colors.red, // Set background color
    textStyle: TextStyle(
      fontSize: 16, // Set font size
      fontWeight: FontWeight.bold, // Set font weight
    ),
    padding: EdgeInsets.symmetric(horizontal: 16, vertical: 8), // Set padding
    shape: RoundedRectangleBorder(
      borderRadius: BorderRadius.circular(8), // Set border radius
    ),
  ),
),