'How to map Firebase array to Kotlin list?

I want to map array from Firebase as a list of string in Kotlin

enter image description here

I have been searching for answer in may threads but they doesn't answer my question

Now I fetch whole collection and I get DocumentSnapshot. When I do

  list = it["myArray"].toString()

I get string:

list = [text1, text2, text3]

How Can I convert it to list?



Solution 1:[1]

You can use split() like,

val newList = list.split(',')

It will split the strings from every occurrence of ',' in it, and will return a list containing all the spliced strings.

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 Kashif Masood