「Flutter/UI」の版間の差分
ナビゲーションに移動
検索に移動
| 41行目: | 41行目: | ||
==画面右下にボタンを表示== | ==画面右下にボタンを表示== | ||
floatingActionButtonをScaffoldの項目に追加 | floatingActionButtonをScaffoldの項目に追加 | ||
return Scaffold( | |||
appBar: AppBar( | appBar: AppBar( | ||
title: Text(widget.title), | title: Text(widget.title), | ||
| 62行目: | 62行目: | ||
child: Icon(Icons.add), | child: Icon(Icons.add), | ||
), | ), | ||
); | |||
==入力フォーム== | ==入力フォーム== | ||
2019年5月5日 (日) 16:27時点における版
body内に複数行textを表示
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'hello',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.display1,
),
RaisedButton(
child: Text('Back to MyPage 1'),
onPressed: () {
Navigator.pop(context);
},
),
],
),
),
body内にボタンを表示
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'hello',
),
RaisedButton(
child: Text('button1'),
onPressed: () {
// ボタン処理
},
),
],
),
),
画面右下にボタンを表示
floatingActionButtonをScaffoldの項目に追加
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'hello',
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed:() {
// ボタン処理
},
tooltip: 'Increment',
child: Icon(Icons.add),
),
);
入力フォーム
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 txt = new TextEditingController();
txt.text = "hoge";
// 略
child: TextField(
controller: txt,
keyboardType: TextInputType.multiline,
),