🐣

【Flutter】OutlinedButton 外枠があるボタン

2024/03/26に公開

OutlinedButtonについて

OutlinedButtonは線のみで描写されるボタンです。
このように実装されます。

OutlinedButton(
  onPressed: () {
   print('Buttonが押されました');
              },
     child: Text('Button'),
                        ),

buttonというテキストが表示されるOutlinedButtonです。
押すとButtonが押されましたと出力されます。

プロパティを追加したい場合は、

 OutlinedButton(
        onPressed: () {
            print('Buttonが押されました');
                               },
            child: Text('Button'),
+             style: OutlinedButton.styleFrom(
                   ),

こちらを追加して、その中にプロパティを追加していきます。

 OutlinedButton(
        onPressed: () {
            print('Buttonが押されました');
                               },
            child: Text('Button'),
             style: OutlinedButton.styleFrom(
+               backgroundColor: Colors.blue,
                           ),
            ),

このようにボタンの背景色を変更することができます。

必要に応じて更新していきます。

Discussion