「Flutter/UI」の版間の差分
ナビゲーションに移動
検索に移動
編集の要約なし |
編集の要約なし |
||
| 1行目: | 1行目: | ||
[[flutter/UI/Text]] | [[flutter/UI/Text]] | ||
[[flutter/UI/Button]] | |||
==入力フォーム== | ==入力フォーム== | ||
2019年5月6日 (月) 16:25時点における版
入力フォーム
TextFormField(
decoration: InputDecoration(
labelText: 'Enter your username'
),
),
複数行入力フォーム
Container(
margin: EdgeInsets.all(8.0),
// hack textfield height
padding: EdgeInsets.only(bottom: 40.0),
child: TextField(
keyboardType: TextInputType.multiline,
maxLines: 6,
decoration: InputDecoration(
hintText: "テキストを作成",
border: OutlineInputBorder(),
),
autofocus: true,
onChanged: (text) {
// value = text;
},
),
),
入力フォームにデフォルトで文字入力
TextEditingController _controller;
@override
void initState() {
super.initState();
// _controller = new TextEditingController(text: 'hogehoge'); // これでもよい
_controller = new TextEditingController();
_controller.text = "hogehoge";
}
// 略
child: TextField(
controller: _controller,
keyboardType: TextInputType.multiline,
),
参考:https://stackoverflow.com/questions/43214271/how-do-i-supply-an-initial-value-to-a-text-field