Flutter Containerを使ってOutlinedButtonのマージンを設定するサンプル

環境
Windows11 pro 64bit
Flutter 3.3.7

構文
margin: /*EdgeInsetsクラスでマージンを指定*/,
OutlinedButtonをContainerでラップします。
Containerの引数「margin」にマージンを指定します。

使用例

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: Container(
margin: EdgeInsets.symmetric(horizontal: 10.0),
width: double.infinity,
child: OutlinedButton(
onPressed: () {},
child: Text('登録'),
),
),
),
),
);
}
@override Widget build(BuildContext context) { return SafeArea( child: Scaffold( body: Center( child: Container( margin: EdgeInsets.symmetric(horizontal: 10.0), width: double.infinity, child: OutlinedButton( onPressed: () {}, child: Text('登録'), ), ), ), ), ); }
@override
 Widget build(BuildContext context) {
   return SafeArea(
     child: Scaffold(
       body: Center(
         child: Container(
           margin: EdgeInsets.symmetric(horizontal: 10.0),
           width: double.infinity,
           child: OutlinedButton(
             onPressed: () {},
             child: Text('登録'),
           ),
         ),
       ),
     ),
   );
 }

 

Flutter

Posted by arkgame