google-cloud-firestore

Sort chat-list by the most recent message with firebase

放肆的年华 提交于 2020-12-10 08:34:05
问题 I don't know why I got stuck in a problem that the chatList is not sorting by the last message time or by the most recent message. I have tried storing timestamp in the database and orderChildBy timestamp but it still not working. not working means the list get not sort after every message and keep showing the list as the sorted after first message. Look at the image how chats are disordered! This is the way I created chatList in the firebaseDatabase in ChatActiviy on sendMessage: val timeAgo

how to read data from firestore flutter

无人久伴 提交于 2020-12-10 06:59:38
问题 i want to read data from firestore in a listtile i dont want to use streambuilder i want to access the documents field individually i try this but not working class ProductList extends StatelessWidget { Stream<DocumentSnapshot> snapshot = Firestore.instance.collection("listofprods").document('ac1').snapshots(); @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar(), body: Padding( padding: const EdgeInsets.all(8.0), child: Column( mainAxisAlignment

1MB exceed firestore

十年热恋 提交于 2020-12-08 02:21:52
问题 I'm storing trip history (array-map) on firestore. the app is crash (Flutter app) when trying to store a large array map (array length may be more than 10,000). and also there are more than 30 fields on the same doc. this is my map(list of map). Map<String, dynamic> toMap() => { "latitude": latitude, "longitude": longitude, "accuracy": accuracy, "altitude": altitude, "speed": speed, "speed_accuracy": speedAccuracy, "heading": heading, "time": time, }; Is there any solution to store this kind

1MB exceed firestore

﹥>﹥吖頭↗ 提交于 2020-12-08 02:20:51
问题 I'm storing trip history (array-map) on firestore. the app is crash (Flutter app) when trying to store a large array map (array length may be more than 10,000). and also there are more than 30 fields on the same doc. this is my map(list of map). Map<String, dynamic> toMap() => { "latitude": latitude, "longitude": longitude, "accuracy": accuracy, "altitude": altitude, "speed": speed, "speed_accuracy": speedAccuracy, "heading": heading, "time": time, }; Is there any solution to store this kind

Firebase Cloud Firestore - Initializing a Collection [duplicate]

我的未来我决定 提交于 2020-12-07 09:00:33
问题 This question already has an answer here : How to create a Collection in Firestore with node.js code (1 answer) Closed 2 years ago . I'm developing an chat app in Swift and when the user creates a chatroom for the first time, it obviously doesn't exist yet in Firebase. Only until the first message gets created does everything build out. When my app first loads, in the viewDidLoad(), I'm setting a reference to the chat at this path (keep in mind it doesn't exist): reference = db.collection(

Firebase Cloud Firestore - Initializing a Collection [duplicate]

筅森魡賤 提交于 2020-12-07 08:56:50
问题 This question already has an answer here : How to create a Collection in Firestore with node.js code (1 answer) Closed 2 years ago . I'm developing an chat app in Swift and when the user creates a chatroom for the first time, it obviously doesn't exist yet in Firebase. Only until the first message gets created does everything build out. When my app first loads, in the viewDidLoad(), I'm setting a reference to the chat at this path (keep in mind it doesn't exist): reference = db.collection(

How to use async code inside map() (Flutter, Firestore)

*爱你&永不变心* 提交于 2020-12-06 16:08:23
问题 I am working on a group chat app with Flutter and the Firestore Plugin. Getting the data from the database and converting the snapshot into a List of Messages works totally fine. But now I want to convert the uid from the database into the username (the uids and their usernames are saved in the db). This is my code: final CollectionReference messagesCollection = Firestore.instance.collection('messages'); final CollectionReference usersCollection = Firestore.instance.collection('users');

How to use async code inside map() (Flutter, Firestore)

狂风中的少年 提交于 2020-12-06 16:04:58
问题 I am working on a group chat app with Flutter and the Firestore Plugin. Getting the data from the database and converting the snapshot into a List of Messages works totally fine. But now I want to convert the uid from the database into the username (the uids and their usernames are saved in the db). This is my code: final CollectionReference messagesCollection = Firestore.instance.collection('messages'); final CollectionReference usersCollection = Firestore.instance.collection('users');

How to properly call FirebaseFirestore.instance.clearPersistence() in Flutter?

蓝咒 提交于 2020-12-06 06:50:26
问题 I'm facing the same problem as this guy question But his accepted answer didn't helped me. The problem: When an user signs out, and another different user signs in, all data shown on my app is from the previous signed out user due to firebase caching system. I searched about this issue and found a solution that consists in calling this method: FirebaseFirestore.instance.clearPersistence(); But everytime and everywhere I place this line of code, throws an exception saying I cannot call this

how to update multiple documents from cloud function in firestore database?

邮差的信 提交于 2020-12-05 12:37:08
问题 I am new to firebase cloud functions and I want to update username field of some documents from posts collection when the users collection changes it username field of a particular document. I use the following code to do that: exports.updateProfileUsername = functions.firestore .document('users/{userId}') .onUpdate((change, context) => { const {userId} = context.params; var newUsername = change.after.data().username; var previousUsername = change.before.data().username; if (newUsername