@@ -267,8 +267,8 @@ class FeedState extends AppState {
267
267
268
268
/// Fetch `Retweet` model from firebase realtime kDatabase.
269
269
/// Retweet itself is a type of `Tweet`
270
- Future <FeedModel > fetchTweet (String postID) async {
271
- late FeedModel _tweetDetail;
270
+ Future <FeedModel ? > fetchTweet (String postID) async {
271
+ FeedModel ? _tweetDetail;
272
272
273
273
/// If tweet is availabe in feedlist then no need to fetch it from firebase
274
274
if (feedlist! .any ((x) => x.key == postID)) {
@@ -284,8 +284,8 @@ class FeedState extends AppState {
284
284
if (snapshot.value != null ) {
285
285
var map = snapshot.value as Map <dynamic , dynamic >;
286
286
_tweetDetail = FeedModel .fromJson (map);
287
- _tweetDetail.key = snapshot.key! ;
288
- print (_tweetDetail.description);
287
+ _tweetDetail! .key = snapshot.key! ;
288
+ print (_tweetDetail! .description);
289
289
}
290
290
},
291
291
);
@@ -408,7 +408,7 @@ class FeedState extends AppState {
408
408
}
409
409
410
410
/// [update] tweet
411
- updateTweet (FeedModel model) async {
411
+ Future < void > updateTweet (FeedModel model) async {
412
412
await kDatabase.child ('tweet' ).child (model.key! ).set (model.toJson ());
413
413
}
414
414
@@ -454,7 +454,7 @@ class FeedState extends AppState {
454
454
455
455
/// Add [new comment tweet] to any tweet
456
456
/// Comment is a Tweet itself
457
- Future addcommentToPost (FeedModel replyTweet) async {
457
+ Future < String ?> addcommentToPost (FeedModel replyTweet) async {
458
458
try {
459
459
isBusy = true ;
460
460
notifyListeners ();
@@ -466,7 +466,8 @@ class FeedState extends AppState {
466
466
DatabaseReference ref = kDatabase.child ('tweet' ).push ();
467
467
await ref.set (json);
468
468
tweet.replyTweetKeyList! .add (ref.key);
469
- updateTweet (tweet);
469
+ await updateTweet (tweet);
470
+ return ref.key;
470
471
}
471
472
} catch (error) {
472
473
cprint (error, errorIn: 'addcommentToPost' );
0 commit comments