4
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 入門 -textFieldを開いたときにkeyboardを表示しない-

Posted at

#TextFieldのキーボードを非表示にする
TextFieldを押した際にDialogなどを表示する際にキーボードにfocusがいって面倒だったためキーボードを非表示にする方法を探しました。

#classを作る

disableFocusNode.dart
class AlwaysDisabledFocusNode extends FocusNode {
  @override
  bool get hasFocus => false;
}

#呼び出し元

TextField(
                keyboardType: TextInputType.number,
//classの呼び出し
                focusNode: AlwaysDisabledFocusNode(),
                controller: controller,
                onChanged: (value) {},
                style: TextStyle(
                  fontSize: 20.0,
                  height: 1.0,
                  color: Colors.black,
                ),
                onTap: () {},
              ),

#まとめ
アプリ制作中にTextFieldを開いた際にキーボードを表示させない方法が知りたかったのでリサーチしました。役に立てばいいねください。

#翻訳、参照元
参照コード

4
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
4
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?