Flutter ElevatedButtonのパディングを設定する方法

環境
Windows11 pro 64bit
Flutter 3.3.7

概要

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
ElevatedButton(
style: ElevatedButton.styleFrom(
padding: EdgeInsets(xxx), //パディングを指定
),
),
ElevatedButton( style: ElevatedButton.styleFrom( padding: EdgeInsets(xxx), //パディングを指定 ), ),
ElevatedButton(
  style: ElevatedButton.styleFrom(
    padding: EdgeInsets(xxx), //パディングを指定
  ),
),

ElevatedButton.styleFromの引数「padding」に指定したパディングが、
ElevatedButtonのパディングに設定されます。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: Center(
child: ElevatedButton(
style: ElevatedButton.styleFrom(
padding: EdgeInsets.all(20),
),
onPressed: () {
print("Button Tap Test");
},
child: Text('Button'),
),
),
),
);
}
@override Widget build(BuildContext context) { return SafeArea( child: Scaffold( body: Center( child: ElevatedButton( style: ElevatedButton.styleFrom( padding: EdgeInsets.all(20), ), onPressed: () { print("Button Tap Test"); }, child: Text('Button'), ), ), ), ); }
@override
Widget build(BuildContext context) {
  return SafeArea(
    child: Scaffold(
      body: Center(
        child: ElevatedButton(
          style: ElevatedButton.styleFrom(
            padding: EdgeInsets.all(20),
          ),
          onPressed: () {
            print("Button Tap Test");
          },
          child: Text('Button'),
        ),
      ),
    ),
  );
}

 

Flutter

Posted by arkgame