Flutter web: Values retrieved from Firestore map are truncated when added to List

Lorence Cramwinckel

In my Flutter Web application I am retrieving values from the map timeslots in Firestore.
This is what the data looks like:

enter image description here

But, instead of retrieving the whole list of values, I get a truncated list like this:

[Mo-Washing-(09:00-10:00, 10:00-11:00, 11:00-12:00, ..., 20:00-21:00, 21:00-22:00)]

Below I have included the 2 functions responsible for retrieving the data and adding it to the list object

static List object = [];
static Map<String, dynamic> timeDetails = {};
static Map<String, dynamic> userDetails = {};

  checkExists(docuID) async {
    return await firestore()
        .collection('environments')
        .doc(docuID)
        .get()
        .then((val) {
      userDetails.addAll(val.data());
    }).whenComplete(() async {
        fs.DocumentSnapshot snapShot = await firestore()
            .collection('environments')
            .doc(docuID)
            .collection('Washing')
            .doc('monday')
            .get();
        if (snapShot == null || !snapShot.exists) {
          print('does not exist');
        } else {
          await getData(docuID, 'Washing');
        }
      setState(() {});
    });
  }

   getData(docuID, machineName) async {
    return await firestore()
        .collection('environments')
        .doc(docuID)
        .collection(machineName)
        .doc('monday')
        .get()
        .then((val) {
      timeDetails.addAll(val.data());
    }).whenComplete(() {
      object.add('Mo-$machineName-${timeDetails['timeslots'].values}');
      print(object);
      setState(() {});
    });
  }

This also happens in debugPrint. Would anyone know why this is happening and how I could solve it? Any help on this would be appreciated!

Lorence Cramwinckel

Neither the workaround as mentioned on Github nor debugPrint worked for me, but I managed to solve this by adding .toList() to my getData function:

   getData(docuID, machineName) async {
    return await firestore()
        .collection('environments')
        .doc(docuID)
        .collection(machineName)
        .doc('monday')
        .get()
        .then((val) {
      timeDetails.addAll(val.data());
    }).whenComplete(() {
      //toList() is added here to .add
      object.add('Mo-$machineName-${timeDetails['timeslots'].values.toList()}');
      print(object);
      setState(() {});
    });
  }

Output:

[Mo-Washing-[09:00-10:00, 10:00-11:00, 11:00-12:00, 12:00-13:00, 13:00-14:00, 14:00-15:00, 15:00-16:00, 16:00-17:00, 17:00-18:00, 18:00-19:00, 19:00-20:00, 20:00-21:00, 21:00-22:00]

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Values not retrieved from database when triggered with the same value twice

I want to change the status of JOIN button to "JOINED" when string is matched from the list of strings retrieved from firestore?

How to retrieve values from a Map within a List Flutter?

Firestore - how to add/subtract from a map of values

How to search for values from a list in the document - Firestore

Firestore: Some values from my flutter app are not uploaded to Firestore database

Retrieve list<string> from Firestore into flutter page

use StreamBuilder to fetch Firestore document which contains list of map in flutter

How to get values from Firestore in Flutter

firestore map key-value pairs randomly change order when retrieved from the database

Flutter: generate a List of Widgets with data from Firestore

Cannot save values from Firestore ​in a List

Data on Firestore console differs from the retrieved when consulting the database

How to Convert String Values From Map<String, List<String>> to type Double? Flutter

Problem with loading data from firestore into a list with flutter

Flutter/Dart casting from Firestore into map

Flutter | how to retrieve a list of objects from firestore?

Flutter retrieve data from firestore as a list

Flutter | How to get a List of Objects from Firestore?

Return List<User> from Firestore Flutter

Auto refreshing list of items in flutter application retrieved from MySQL database

Values are not added to a List when using Append

How to display a list of map in firestore and shows them in flutter

How to list values ​from documents in Flutter Firestore?

add a map inside map and retrieve it from Firestore - Flutter

How to get data from firestore to List on flutter?

Access keys and values from map inside a List in Flutter

Data from Sybase image column truncated at 32 KiB when retrieved via pyodbc

How to dump the values I'm getting from firestore to list in flutter?