["haha", "hehe"], "huhuh3" => ["hihihi" -6ren">
gpt4 book ai didi

dart - 什么是php关联数组的dart等效项,以及如何将其存储在Firestore中?

转载 作者:行者123 更新时间:2023-12-03 03:21:49 25 4
gpt4 key购买 nike

我与php associative arrays关系稳定:)

例如

$assocArr = [
"title1" => ["haha", "hehe"],
"huhuh3" => ["hihihi" , huhuhu"]
];

Dart中的等效物是什么?理想情况下,基于类,以便我们可以使用Android Studio等IDE的优势。此外,我们如何将此类存储在Firestore中?

最佳答案

我没有使用PHP关联数组的经验,但是从您的示例来看,您似乎想要的是 Map :

void main() {
Map<String, List<String>> assocArr = {
'title1': ['haha', 'hehe'],
'huhuh3': ['hihihi', 'huhuhu']
};
print(assocArr); // {title1: [haha, hehe], huhuh3: [hihihi, huhuhu]}
print(assocArr['title1']); // [haha, hehe]
}

关于dart - 什么是php关联数组的dart等效项,以及如何将其存储在Firestore中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62359186/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com