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),
),
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')),
],
),
),
);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.