如何在firebaseAnimateList上添加新帖子.?帮我吧,每当我添加新帖子时,它都会出现在帖子的底部



我希望当有人添加新帖子时,它应该出现在帖子的顶部。

我也使用了listview的反向,但它不起作用。

await Future.value(uploadTask);
var newUrl = await ref.getDownloadURL();
final User? user = _auth.currentUser;
postRef.child('Post List').child(date.toString()).set({
'pId': date.toString(),
'pImage': newUrl.toString(),
'pTime': date.toString(),
'pTitle': titleController.text.toString(),
'pDescription': descriptionController.text.toString(),
'uEmail': user!.email.toString(),
'uid': user.uid.toString(),
}).then((value){
toastMessage('Post Published');
setState(() {
showSpinner = false;
});
} ).onError((error, stackTrace) {
toastMessage(error.toString());
setState(() {
showSpinner = false;
});
});
}catch (e) {
setState(() {
showSpinner = false;
});

Expanded(child: FirebaseAnimatedList(
query: dbRef.child('Post List'),
scrollDirection: Axis.vertical,
itemBuilder: (BuildContext context, DataSnapshot snapshot, Animation<double> animation, int index) {
return  Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
FadeInImage.assetNetwork(image: snapshot.value['pImage'], placeholder: 'assets/x.png',),
SizedBox(height: 5.0),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Text(snapshot.value['pTitle'], style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold),),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Text(snapshot.value['pDescription'], style: TextStyle(fontSize: 15, fontWeight: FontWeight.normal), ),
),
SizedBox(height: 20),
],
),
);
}

"反向:真";添加到firebaseanimatedlist

相关内容

  • 没有找到相关文章

最新更新