Map<int, List<int>> favoritePlaces;
な変数
がある。
intのキー指定してnullなら初期化してaddできるようにしたいが・・。
if (favoritePlaces[location]?.contains(index) ?? false) { favoritePlaces[location].remove(index); } else { // なければList<int>初期化 if (favoritePlaces[location] == null) { print(favoritePlaces.runtimeType); favoritePlaces[location] = <int>[]; } favoritePlaces[location].add(index); }
CastMap<String, dynamic, int, List
════════ Exception caught by gesture ═══════════════════════════════════════════════════════════════ The following _CastError was thrown while handling a gesture: type 'int' is not a subtype of type 'String' in type cast