「Flutter/UI」の版間の差分

提供: 初心者エンジニアの簡易メモ
ナビゲーションに移動 検索に移動
編集の要約なし
 
(同じ利用者による、間の26版が非表示)
1行目: 1行目:
==body内に複数行textを表示==
[[flutter/UI/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内にボタンを表示==
[[flutter/UI/Button]]
body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'hello',
            ),
            RaisedButton(
              child: Text('button1'),
              onPressed: () {
                // ボタン処理
              },
            ),
          ],
        ),
),


==画面右下にボタンを表示==
[[flutter/UI/Container]]
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),
      ),
);


==入力フォーム==
[[flutter/UI/TextField]]
TextFormField(
              decoration: InputDecoration(
                  labelText: 'Enter your username'
              ),
),


==複数行入力フォーム==
[[flutter/UI/ListView]] [dir]
Container(
 
              margin: EdgeInsets.all(8.0),
[[flutter/UI/PageView]]
              // hack textfield height
 
              padding: EdgeInsets.only(bottom: 40.0),
[[flutter/UI/ListTile]]
              child: TextField(
 
                keyboardType: TextInputType.multiline,
[[flutter/UI/SwitchListTile]]
                maxLines: 6,
 
                decoration: InputDecoration(
[[flutter/UI/BottomNavigationBar]]
                  hintText: "テキストを作成",
 
                  border: OutlineInputBorder(),
[[flutter/UI/DropdownButton]]
                ),
 
                autofocus: true,
[[flutter/UI/Scaffold]]
                onChanged: (text) {
 
                  // value = text;
[[flutter/UI/CircleAvatar]]
                },
 
              ),
[[flutter/UI/Draggable]]
),
 
==入力フォームにデフォルトで文字入力==
[[flutter/UI/Cupertino]] [dir]
TextEditingController txt = new TextEditingController();
 
txt.text = "hoge";
[[flutter/UI/余白]]
//
 
child: TextField(
[[flutter/UI/ダークモード]]
                controller: txt,
 
                keyboardType: TextInputType.multiline,
[[flutter/UI/横縦並び・比率]]
),
 
[[flutter/UI/別widget切出]]
 
[[flutter/UI/その他]]

2020年1月20日 (月) 14:14時点における最新版