'my documents are not being uploaded to firebase
so i'm creating a todo list app, and it was working fine and all until i upgraded all the packages in my pubspec.yaml, which led to some nasty errors i found a way to fix it but that was when i started experiencing a problem, when i write tasks to my firestore database it doesn't add, and my stream builder doesn't see it but if i add the task manually, my stream builder still wont see it, i need help
how i solved my error in my pubspec
dependency_overrides:
firebase_messaging_platform_interface: 3.1.6
firebase_crashlytics_platform_interface: 3.1.13
cloud_firestore_platform_interface: 5.4.13
firebase_auth_platform_interface: 6.1.11
firebase_storage_platform_interface: 4.0.14
cloud_functions_platform_interface: 5.0.21
firebase_analytics_platform_interface: 3.0.5
firebase_remote_config_platform_interface: 1.0.5
firebase_dynamic_links_platform_interface: 0.2.0+5
firebase_performance_platform_interface: 0.1.0+5
firebase_app_installations_platform_interface: 0.1.0+6
how i add tasks to firebase
FirebaseFirestore.instance.collection('tasks').add(
{
'name': textcontrol,
'description': descriptionControl,
'completed': false,
'DOC': newDate,
'created': DateTime.now(),
'time': newTime.format(context).toString(),
},
);
my stream builder
StreamBuilder<QuerySnapshot>(
builder: (context, snapshot) {
if (!snapshot.hasData)
return Container(
height: constraints.maxHeight * 0.7,
child: Center(
child: Text('press the + icon to add a task'),
),
);
return Expanded(child: _buildList(snapshot.data));
},
stream: FirebaseFirestore.instance
.collection('tasks')
.where('completed', isEqualTo: false)
.snapshots(),
),
Solution 1:[1]
When you upload something on the firebase database you have to create a doc within the collection with a unique id and then set your Map, so your code must look like this:
FirebaseFirestore.instance.collection('tasks').doc(doc_name_you_want).set(
{
'name': textcontrol,
'description': descriptionControl,
'completed': false,
'DOC': newDate,
'created': DateTime.now(),
'time': newTime.format(context).toString(),
},
);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jordan Kotiadis |
