android-studio - 未处理的异常:NoSuchMethodError:类'_InternalLinkedHashMap' 没有具有匹配参数的实例方法 'cast'
问题描述
我对 Flutter / Dart 还是有点陌生,我从 php json 文件中恢复了数据,但它在 Flutter 中显示错误。
E/flutter ( 7160): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception:
NoSuchMethodError: Class '_InternalLinkedHashMap<String, dynamic>' has no instance method 'cast' with
matching arguments.
E/flutter ( 7160): Receiver: _LinkedHashMap len:1
E/flutter ( 7160): Tried calling: cast<Map<String, dynamic>>()
E/flutter ( 7160): Found: cast<RK, RV>() => Map<RK, RV>
E/flutter ( 7160): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
解决方案
尝试
final items = Map<String, dynamic>.from(json.decode(response.body));
推荐阅读
- angular - 如果数组只有单个元素,则设置 mat-select 默认值,否则填充下拉菜单 Angular
- javascript - 如何在 HTML 和 Javascript 的帮助下从浏览器使用 python (Django) 访问我的网络摄像头?
- javascript - 无法导入 discord.js 打字稿
- python - 使用 Numpy 创建网格时如何更改整数类型?
- android - Android WorkManager 导致原生崩溃
- r - 甘特图结合条形图
- php - 使用 array_filter PHP 创建路由时出现问题
- r - 如何组合两个数据集以仅包含某些观察值以及这些行中的所有数据?
- javascript - 仅用于键盘字母的正则表达式
- openmdao - compute_totals 和有限差分可能导致内存泄漏