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

【Flutter】TextFieldのカウンターを消す方法

Last updated at Posted at 2023-08-29

TextFieldmaxLengthを指定した際に、デフォルトでフォームの右下に入力した文字数のカウンターが表示されます。
これいらないんだよね。。ってときの対処法を教えます。

結論

TextFielddecorationプロパティに、InputDecoration(counterText: '')を渡すだけ!!超簡単!!

@override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Sample'),
      ),
      body: const Padding(
        padding: EdgeInsets.symmetric(horizontal: 30.0),
        child: Center(
          child: TextField(
            maxLength: 10,
            decoration: InputDecoration(
              hintText: 'TextField',
              counterText: '', // ここを追加!!
            ),
          ),
        ),
      ),
    );
  }

動作

counterTextをつけていないとき

スクリーンショット 2023-08-23 18.13.09.png

counterTextをつけたとき

スクリーンショット 2023-08-23 18.12.50.png
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?