0
0

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 1 year has passed since last update.

[Flutter]TextFormFieldをタップした時に全選択する方法

Posted at

TextFormFieldの中のOnTapで下記の処理を追加すればOKです。

イメージはこちら。

スクリーンショット 2022-10-31 19.49.14.png

ソースはこちら。(コピペでOKです)

TextEditingController textEditingController = TextEditingController();

TextFormField(

  onTap: () {

    textEditingController.selection = TextSelection(
        baseOffset: 0,
        extentOffset: textEditingController.text.length
    );

  },
  controller: textEditingController,
),

全選択するための情報が当時あまりなくて仕方なくタップしたら値をクリアするみたいな感じで進めてたんですが、相談したらパパパッと修正してもらえたので自信の忘備録も兼ねて投稿です。

どなたかの参考になれば幸いです。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?