@@ -43,18 +43,18 @@ class ChatWidget {
43
43
44
44
static Widget userListbuildItem (
45
45
BuildContext context, String currentUserId, DocumentSnapshot document) {
46
- print ('firebase ' + document[ 'userId' ] );
46
+ print ('firebase ' + document. get ( 'userId' ) );
47
47
print (currentUserId);
48
- if (document[ 'userId' ] == currentUserId) {
48
+ if (document. get ( 'userId' ) == currentUserId) {
49
49
return Container ();
50
50
} else {
51
51
return Container (
52
52
child: FlatButton (
53
53
child: Row (
54
54
children: < Widget > [
55
55
Material (
56
- child: document[ 'photoUrl' ] != null
57
- ? widgetShowImages (document[ 'photoUrl' ] , 50 )
56
+ child: document. get ( 'photoUrl' ) != null
57
+ ? widgetShowImages (document. get ( 'photoUrl' ) , 50 )
58
58
: Icon (
59
59
Icons .account_circle,
60
60
size: 50.0 ,
@@ -69,7 +69,7 @@ class ChatWidget {
69
69
children: < Widget > [
70
70
Container (
71
71
child: Text (
72
- 'Nickname: ${document [ 'nickname' ] }' ,
72
+ 'Nickname: ${document . get ( 'nickname' ) }' ,
73
73
style: TextStyle (color: primaryColor),
74
74
),
75
75
alignment: Alignment .centerLeft,
@@ -89,7 +89,7 @@ class ChatWidget {
89
89
),
90
90
child: new DecoratedBox (
91
91
decoration: new BoxDecoration (
92
- color: document[ 'online' ] == 'online'
92
+ color: document. get ( 'online' ) == 'online'
93
93
? Colors .greenAccent
94
94
: Colors .transparent),
95
95
),
@@ -103,8 +103,8 @@ class ChatWidget {
103
103
builder: (context) => Chat (
104
104
currentUserId: currentUserId,
105
105
peerId: document.documentID,
106
- peerName: document[ 'nickname' ] ,
107
- peerAvatar: document[ 'photoUrl' ] ,
106
+ peerName: document. get ( 'nickname' ) ,
107
+ peerAvatar: document. get ( 'photoUrl' ) ,
108
108
)));
109
109
},
110
110
color: viewBg,
@@ -193,13 +193,13 @@ class ChatWidget {
193
193
194
194
static Widget widgetChatBuildItem (BuildContext context, var listMessage,
195
195
String id, int index, DocumentSnapshot document, String peerAvatar) {
196
- if (document[ 'idFrom' ] == id) {
196
+ if (document. get ( 'idFrom' ) == id) {
197
197
return Row (
198
198
children: < Widget > [
199
- document[ 'type' ] == 0
200
- ? chatText (document[ 'content' ] , id, listMessage, index, true )
199
+ document. get ( 'type' ) == 0
200
+ ? chatText (document. get ( 'content' ) , id, listMessage, index, true )
201
201
: chatImage (
202
- context, id, listMessage, document[ 'content' ] , index, true )
202
+ context, id, listMessage, document. get ( 'content' ) , index, true )
203
203
],
204
204
mainAxisAlignment: MainAxisAlignment .end,
205
205
);
@@ -218,10 +218,10 @@ class ChatWidget {
218
218
clipBehavior: Clip .hardEdge,
219
219
)
220
220
: Container (width: 35.0 ),
221
- document[ 'type' ] == 0
221
+ document. get ( 'type' ) == 0
222
222
? chatText (
223
- document[ 'content' ] , id, listMessage, index, false )
224
- : chatImage (context, id, listMessage, document[ 'content' ] ,
223
+ document. get ( 'content' ) , id, listMessage, index, false )
224
+ : chatImage (context, id, listMessage, document. get ( 'content' ) ,
225
225
index, false )
226
226
],
227
227
),
@@ -232,7 +232,7 @@ class ChatWidget {
232
232
child: Text (
233
233
DateFormat ('dd MMM kk:mm' ).format (
234
234
DateTime .fromMillisecondsSinceEpoch (
235
- int .parse (document[ 'timestamp' ] ))),
235
+ int .parse (document. get ( 'timestamp' ) ))),
236
236
style: TextStyle (
237
237
color: greyColor,
238
238
fontSize: 12.0 ,
@@ -257,9 +257,9 @@ class ChatWidget {
257
257
child: CircularProgressIndicator (
258
258
valueColor: AlwaysStoppedAnimation <Color >(themeColor)))
259
259
: StreamBuilder (
260
- stream: Firestore .instance
260
+ stream: FirebaseFirestore .instance
261
261
.collection ('messages' )
262
- .document (groupChatId)
262
+ .doc (groupChatId)
263
263
.collection (groupChatId)
264
264
.orderBy ('timestamp' , descending: true )
265
265
.limit (20 )
0 commit comments