How do I create a Flatbutton in flutter with 2 color? not gradient, 2 solid color side by side

223 Views Asked by At

How do I create a Flatbutton in flutter with 2 colors? not gradient, 2 solid color side by side. enter image description here

2

There are 2 best solutions below

0
On

Try this code. You can tweak it to meet your needs

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return FlatButton(
      onPressed: () {},
      child: Container(
        height: 50,
        width: 100,
        child: Stack(
          children: [
            Row(
              children: [
                Expanded(child: Container(color: Colors.red)),
                Expanded(child: Container(color: Colors.blue)),
              ],
            ),
            Center(child: Text('PRESS ME')),
          ],
        ),
      ),
    );
  }
}
1
On

might be a shorter answer using gradient and stops

          decoration: BoxDecoration(
            gradient: LinearGradient(
              colors:  [Colors.red, Theme.of(context).buttonColor] 
              stops: [0.5, 0.5]
            ),
            borderRadius: BorderRadius.circular(10.0),
          ),