3
Help us understand the problem. What are the problem?

More than 1 year has passed since last update.

posted at

updated at

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

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

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

  final String title;

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

躓いたところ

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

TextFormField(initialValue: title)
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Sign upLogin
3
Help us understand the problem. What are the problem?