ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
[TOC] ## Map k-v 类型 ``` //类型推导为 Map<String, String> var gifts = { // Key: Value 'first': 'partridge', 'second': 'turtledoves', 'fifth': 'golden rings' }; //类型推导为 Map<int, String> var nobleGases = { 2: 'helium', 10: 'neon', 18: 'argon', }; final constantMap = const { 2: 'helium', 10: 'neon', 18: 'argon', }; ``` 基本操作 ``` //赋值 gifts['first'] = 'calling birds'; // Add a key-value pair //取值 assert(gifts['first'] == 'partridge'); ```