LoginSignup
20
5

More than 3 years have passed since last update.

【Flutter】TextFieldに初期値を持たせる方法 【Dart】

Last updated at Posted at 2021-01-04

開発時に少し躓いたので共有します

class InitTextField extends StatelessWidget {
  InitTextField(this.title);

  final String title;

  @override
  Widget build(BuildContext context) {
    return TextField(
      controller: TextEditingController(text: title),  //ここに初期値
    );
  }
}

躓いたところ

以下のやり方でも初期値は設定可能だったが状態更新した時に
再レンダリングされなかった。上記の方法だと解決した

TextFormField(initialValue: title)
20
5
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
20
5