简体   繁体   中英

2D arrays in firebase using Flutter (Dart)

I have created a list of list of String which is a 2D array now I want to upload to firebase database server but do firebase supports 2D array?

List<List<String>> data = [
    ['5', '2', '2', '7'],
    ['8', '8', '9', '7'],
    ['78', '7', '8', '7'],
  ];

how to upload this array and retrieve back in original form in Flutter?

You can use map property in firebase create a map then inside your map area create a array then put your values to the array

在此处输入图像描述

 Firestore.instance.collection('your collection').document(some_docID).setData({
       'map1': {
        'key1': ['value1', 'value3'],
        'key2': ['value2', 'value4'],
      }});

https://medium.com/firebase-tips-tricks/how-to-map-an-array-of-objects-from-cloud-firestore-to-a-list-of-objects-122e579eae10

this medium article shows how to retrieve data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM