5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Flutterでmaxlinesの大きさだけTextFieldの高さが大きくなってしまう問題について

Posted at

Flutterでは maxLines の高さを大きくしたら最初からその高さ分大きくなってしまいます。

例えば下記のようなコードを書いた時に


TextField(
  keyboardType: TextInputType.multiline,
  maxLines: 2,
  decoration: InputDecoration(
     hintText: "Comment ✍️",
     focusedBorder: _inputBorder,
     enabledBorder: _inputBorder,
   ),
),

mojikyo45_640-2.gif

こんな感じになってしまいます。

minLinesも設定する

この問題は minLines も設定することで解決できます。


TextField(
  keyboardType: TextInputType.multiline,
  maxLines: 2,
  minLines: 1,
  decoration: InputDecoration(
     hintText: "Comment ✍️",
     focusedBorder: _inputBorder,
     enabledBorder: _inputBorder,
   ),
),

mojikyo45_640-2.gif

以上です。

5
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?