teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

根本的な解決の方法を書いていませんでした

2021/12/31 22:34

投稿

children
children

スコア89

answer CHANGED
@@ -1,2 +1,37 @@
1
- widget追加すときは、基本的親のwidgetのchildまたchildrenプロパティの中に入れないといけせん
2
- しかし、このAnimatedContainerはchildプロパティの持っていないScaffoldの中のでchild:を付けったって意味がありません。Scaffoldの中にwidgetを入れたいならbody:プロパティの中に入れてあげないといけません。少しここは基本的なところなので、[このYouTubeチャンネル](https://www.youtube.com/channel/UCReuARgZI-BFjioA8KBpjsw)の動画を見てみて下さい。少し情報が古いですが、わかりやすいですよ。
1
+ FloatingActionButtonの色変えるには FloatingActionButtonのbackgroundColorプロパティで変える必要があり
2
+ (赤場合)
3
+
4
+ ```dart
5
+ Container(
6
+ margin: EdgeInsets.only(bottom: 180.0, right: 130.0),
7
+ width: 100.0,
8
+ height: 100.0,
9
+ child: FloatingActionButton(
10
+ backgroundColor: Colors.red,
11
+ onPressed: _incrementCounter,
12
+ tooltip: 'Increment',
13
+ child: const Icon(Icons.add),
14
+ )),
15
+ ```
16
+ しかし、 FloatingActionButtonの色を変えてもアニメーションされません。
17
+ AnimtedThemeなどを使う必要があると思います。
18
+
19
+ ```dart
20
+ AnimatedTheme(
21
+ duration: Duration(milliseconds: 500),
22
+ data: Theme.of(context).copyWith(
23
+ floatingActionButtonTheme: FloatingActionButtonThemeData(
24
+ backgroundColor: Colors.blue,//ここ変えると色がアニメーションされる。
25
+ ),
26
+ ),
27
+ child: Container(
28
+ margin: EdgeInsets.only(bottom: 180.0, right: 130.0),
29
+ width: 100.0,
30
+ height: 100.0,
31
+ child: FloatingActionButton(
32
+ onPressed: _incrementCounter,
33
+ tooltip: 'Increment',
34
+ child: const Icon(Icons.add),
35
+ )),
36
+ ),
37
+ ```