どうも、ちょげ(@chogetarou)です。
MaterialButtonに枠線をつける方法を紹介します。
方法

MaterialButtonに枠線をつけるには、引数「shape」を使います。
まず、MaterialButtonの引数「shape」に、形状を指定します。
形状は、ShapeBoderクラスで指定します。
そして、 ShapeBorderクラスの引数「side」にBoderSideクラスを指定します。
MaterialButton(
shape: RoundedRectangleBorder(
side: BorderSide(・・・),
),
onPressed: () {},
child: Text('Button'),
),
引数「shape」に指定した形状の枠線がMaterialButtonに付与されます。
使用例

@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: Center(
child: MaterialButton(
shape: CircleBorder(
side: BorderSide(
color: Colors.red,
width: 2,
),
),
padding: const EdgeInsets.all(40.0),
onPressed: () {},
child: Text('Button'),
),
),
),
);
}
コメント