79100354

Date: 2024-10-18 02:40:50
Score: 1
Natty:
Report link

This is the native and correct way to create a gradient background for the ElevatedButton using backgroundBuilder!

Code Sample:

 ElevatedButton(
  style: ElevatedButton.styleFrom(
    backgroundBuilder: (context, state, child) {
      return Container(
        decoration: const BoxDecoration(
          gradient: LinearGradient(
            colors: [Colors.purple, Colors.blue],
            begin: Alignment.topLeft,
            end: Alignment.bottomRight,
          ),
        ),
        child: const Icon(Icons.apple),
      );
    },
  ),
  child: const Icon(Icons.apple),
  onPressed: () {},
)

Button

Good coding! 🩵

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Inaldo Manso