回答編集履歴
1
追記
answer
CHANGED
@@ -8,4 +8,46 @@
|
|
8
8
|
2. SameCupertinoSegmentedControlModelの変数の持ち方を工夫する(値の保持をMapやListにするなど)
|
9
9
|
3. SameCupertinoSegmentedControlModelと同じようなクラス(別名)を設問ごとに作ってMultiProviderで流す
|
10
10
|
|
11
|
-
あたりが選択肢になるかと思います。
|
11
|
+
あたりが選択肢になるかと思います。
|
12
|
+
|
13
|
+
以下は 1. の場合の例です。
|
14
|
+
|
15
|
+
```dart
|
16
|
+
// MultiProviderを削除
|
17
|
+
class TabbedAppBarSample extends StatelessWidget {
|
18
|
+
@override
|
19
|
+
Widget build(BuildContext context) {
|
20
|
+
return MaterialApp(
|
21
|
+
home: DefaultTabController(
|
22
|
+
length: 2,
|
23
|
+
child: Scaffold( // 以下省略
|
24
|
+
```
|
25
|
+
|
26
|
+
```dart
|
27
|
+
// Providerを追加
|
28
|
+
class CarPage extends StatelessWidget {
|
29
|
+
@override
|
30
|
+
Widget build(BuildContext context) {
|
31
|
+
return Scaffold(
|
32
|
+
body: Column(
|
33
|
+
children: [
|
34
|
+
ChangeNotifierProvider(
|
35
|
+
create: (context) => SameCupertinoSegmentedControlModel(),
|
36
|
+
child: SameCupertinoSegmentedControl(
|
37
|
+
title: 'タイトル1',
|
38
|
+
value: {0: Text('value1'), 1: Text('value2')},
|
39
|
+
),
|
40
|
+
),
|
41
|
+
ChangeNotifierProvider(
|
42
|
+
create: (context) => SameCupertinoSegmentedControlModel(),
|
43
|
+
child: SameCupertinoSegmentedControl(
|
44
|
+
title: 'タイトル2',
|
45
|
+
value: {0: Text('value3'), 1: Text('value4')},
|
46
|
+
),
|
47
|
+
),
|
48
|
+
],
|
49
|
+
),
|
50
|
+
);
|
51
|
+
}
|
52
|
+
}
|
53
|
+
```
|