[Flutter]TextFormFieldの左側にボタンを配置するには?

Flutter

どうも、ちょげ(@chogetarou)です。

TextFormFieldの左側にボタンを配置する方法を紹介します。

スポンサーリンク

方法

インターフェース, インターネット, プログラム, ブラウザ, Www

TextFormFieldの左側にボタンを配置するには、InputDecorationを使います。

まず、TextFormFieldの引数「decoration」にInputDecorationを指定します。

そして、InputDecorationの引数「prefixIcon」にボタンを指定します。

TextFormField(
  decoration: InputDecoration(
    prefixIcon: /*ボタン(ElevateButton, Textbutton, IconButton, ・・・)を指定*/,
  ),
),

InputDecorationを使えば、TextFormFieldの左側にボタンを配置することが出来ます。

使用例

以下は、使用例です。

 TextFormField(
  decoration: InputDecoration(
    prefixIcon: ElevatedButton(
      onPressed: () {},
      child: Text('Button'),
    ),
    border: OutlineInputBorder(),
  ),
),

コメント

タイトルとURLをコピーしました