どうも、ちょげ(@chogetarou)です。
MaterialButtonのパディングを削除する方法を紹介します。
方法

MaterialButtonのパディングを削除するには、引数を使います。
まず、MaterialButtonの引数「padding」にEdgeInsets.zeroを指定します。
そして、MaterialButtonの引数「minWidth」と引数「height」に0を指定します。
MaterialButton(
padding: EdgeInsets.zero,
minWidth: 0,
height: 0,
onPressed: () {},
child: Text('Button'),
),
MaterialButtonのパディングとサイズを0にすることで、MaterialButtonのパディングを削除することが出来ます。
使用例

@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: Center(
child: MaterialButton(
padding: EdgeInsets.zero,
minWidth: 0,
height: 0,
color: Colors.blue,
textColor: Colors.white,
onPressed: () {},
child: Text('Button'),
),
),
),
);
}
コメント