質問編集履歴
2
プログラムの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
---
|
16
16
|
|
17
|
-
```
|
17
|
+
```dart
|
18
18
|
|
19
19
|
|
20
20
|
|
@@ -28,9 +28,9 @@
|
|
28
28
|
|
29
29
|
|
30
30
|
|
31
|
-
Future getUid
|
31
|
+
Future getUid(){
|
32
|
-
|
32
|
+
|
33
|
-
final snapshot =
|
33
|
+
final snapshot = FirebaseAuth.instance.currentUser;
|
34
34
|
|
35
35
|
this.Uid = snapshot.uid;
|
36
36
|
|
@@ -44,11 +44,17 @@
|
|
44
44
|
|
45
45
|
final snapshot =
|
46
46
|
|
47
|
-
await FirebaseFirestore
|
47
|
+
await FirebaseFirestore
|
48
|
+
|
48
|
-
|
49
|
+
.instance
|
50
|
+
|
49
|
-
.collection('users')
|
51
|
+
.collection('users')
|
52
|
+
|
50
|
-
|
53
|
+
.doc(Uid)
|
54
|
+
|
51
|
-
.collection('timer')
|
55
|
+
.collection('timer')
|
56
|
+
|
57
|
+
.get();
|
52
58
|
|
53
59
|
final docs = snapshot.docs;
|
54
60
|
|
@@ -60,6 +66,8 @@
|
|
60
66
|
|
61
67
|
notifyListeners();
|
62
68
|
|
69
|
+
|
70
|
+
|
63
71
|
}
|
64
72
|
|
65
73
|
|
@@ -70,11 +78,17 @@
|
|
70
78
|
|
71
79
|
final snapshots =
|
72
80
|
|
73
|
-
await FirebaseFirestore
|
81
|
+
await FirebaseFirestore
|
82
|
+
|
74
|
-
|
83
|
+
.instance
|
84
|
+
|
75
|
-
.collection('users')
|
85
|
+
.collection('users')
|
86
|
+
|
76
|
-
|
87
|
+
.doc(Uid)
|
88
|
+
|
77
|
-
.collection('timer')
|
89
|
+
.collection('timer')
|
90
|
+
|
91
|
+
.snapshots();
|
78
92
|
|
79
93
|
snapshots.listen((snapshot){
|
80
94
|
|
@@ -93,3 +107,113 @@
|
|
93
107
|
}
|
94
108
|
|
95
109
|
```
|
110
|
+
|
111
|
+
```dart
|
112
|
+
|
113
|
+
class TimerList extends StatelessWidget {
|
114
|
+
|
115
|
+
@override
|
116
|
+
|
117
|
+
Widget build(BuildContext context) {
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
return Consumer<TimerModel>(builder: (context, model, child) {
|
122
|
+
|
123
|
+
model.getUid();
|
124
|
+
|
125
|
+
return Scaffold(
|
126
|
+
|
127
|
+
appBar: AppBar(
|
128
|
+
|
129
|
+
title: Text('タイマーリスト'),
|
130
|
+
|
131
|
+
centerTitle: true,
|
132
|
+
|
133
|
+
actions: [
|
134
|
+
|
135
|
+
InkWell(
|
136
|
+
|
137
|
+
onTap: ()async{
|
138
|
+
|
139
|
+
print(model.Uid); ※ここでuidを出力できました。
|
140
|
+
|
141
|
+
},
|
142
|
+
|
143
|
+
child: Icon(Icons.favorite_border,
|
144
|
+
|
145
|
+
),
|
146
|
+
|
147
|
+
)
|
148
|
+
|
149
|
+
],
|
150
|
+
|
151
|
+
),
|
152
|
+
|
153
|
+
body:Consumer<TimerModel>(builder: (context, model, child) {
|
154
|
+
|
155
|
+
final timerList = model.timeList;
|
156
|
+
|
157
|
+
return ListView(
|
158
|
+
|
159
|
+
children: timerList
|
160
|
+
|
161
|
+
.map(
|
162
|
+
|
163
|
+
(timelist) => Card(
|
164
|
+
|
165
|
+
child: Center(
|
166
|
+
|
167
|
+
child:Text(timelist.title,
|
168
|
+
|
169
|
+
),
|
170
|
+
|
171
|
+
),
|
172
|
+
|
173
|
+
),
|
174
|
+
|
175
|
+
).toList(),
|
176
|
+
|
177
|
+
);
|
178
|
+
|
179
|
+
}),
|
180
|
+
|
181
|
+
);
|
182
|
+
|
183
|
+
}
|
184
|
+
|
185
|
+
);
|
186
|
+
|
187
|
+
}
|
188
|
+
|
189
|
+
}
|
190
|
+
|
191
|
+
```
|
192
|
+
|
193
|
+
```dart
|
194
|
+
|
195
|
+
class Time {
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
Time(DocumentSnapshot doc){
|
200
|
+
|
201
|
+
this.time = doc['time'];
|
202
|
+
|
203
|
+
this.title = doc['title'];
|
204
|
+
|
205
|
+
}
|
206
|
+
|
207
|
+
String time;
|
208
|
+
|
209
|
+
String title;
|
210
|
+
|
211
|
+
}
|
212
|
+
|
213
|
+
```
|
214
|
+
|
215
|
+
![イメージ説明](036b10cbf0908826e9101c08855df8d6.jpeg)]
|
216
|
+
|
217
|
+
![イメージ説明](373d4265a892920f2ef52ec9998a74e0.jpeg)
|
218
|
+
|
219
|
+
usersのdocumentIDはuidです。
|
1
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
### 問題点
|
2
2
|
|
3
|
-
サインアップ時にfirebaseでuidをdocumentIDとして保存し、
|
3
|
+
サインアップ時にfirebaseでuidをdocumentIDとして保存し、ログインしたユーザーのuidを用いてデータを取得したい。
|
4
4
|
|
5
5
|
|
6
6
|
|