我收到以下错误:
Instance members can't be accessed from a factory constructor. (Documentation) Try removing the reference to the instance member.
The argument type 'List<Map<String, dynamic>>?' can't be assigned to the parameter type 'List<Vaccination>'. (Document
我使用的是json_serializable和firestore。json_serializable创建了一个以Map作为参数的工厂方法,但是在nullsafety更改之后,firestore开始返回一个Map?作为文档数据,现在我不能调用json_serializable工厂来映射我的firestore类型,因为显示了这个错误消息:The argument type 'Map<String, dynamic>?' can't be assigned to the parameter type 'Map<String, dynamic>
我编写了这段代码来将动态列表转换为Word列表,但是linter说:
Omit type annotations for local variables.在二号线。
但是,如果省略类型注释,则会得到一个错误A value of type 'List<dynamic>' can't be returned from method 'convert' because it has a return type of 'List<Word>'.。
有没有更明智的转换方式?
static List<Word>
我有一个想要保存到本地存储的对象,但是每当我将该对象写入存储时,我都会得到标题中显示的错误。
这是完整的堆栈跟踪
[VERBOSE-2:ui_dart_state.cc(198)] Unhandled Exception: type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'Map<String, double>' in type cast
#0 new Product.fromJson (package:app/src/objects
让我们从以下几个方面开始:
dynamic list = [1];
var ints = list as List<int>; // Works
我正在将dynamic类型的list降为List<int>类型,它可以工作。现在,让我们再举一个例子:
var jsonString = '{"0": [1]}';
var Map<String, dynamic> map = jsonDecode(jsonString);
dynamic list = map['0'];
var ints = list as Lis
我正在尝试创建一个列表[MapString,dynamic],并将其保存到消防局并检索它。问题在于清单,它给了我:type 'List<dynamic>' is not a subtype of type 'List<Map<String, dynamic>>'
我在这里真正想做的就是将下面的属性保存到列表'classes‘中,并检索它们的索引以显示在屏幕上。
班级
class Cards {
final List<String> question;
final List<String>
我最近将我的代码迁移到空安全。在dart迁移命令中得到以下错误。
参数类型为“List<Slots?>?”不能分配给参数类型'List?‘在lib/responsemodels/appointment/calendar/calendar_response.g.dart:17:5
突出显示下面的错误抛出行
calendar_response.dart
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'calendar_response.dart';
// ***********************
大家好,我正在尝试从API中获取JSON,但是当我将JSON映射到我创建的模型中时,我得到了这个错误,它的类型是'_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'String'。
这是JSON响应
{"data":{"userinfo":[{"firstname":"MAEN","lastname":"NASSAN","email":"maen.a
我的代码中有这个错误。 [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'FutureOr<List<dynamic>>' 下面是我的代码: Future<List> getmatches() async{
String url="https://cricapi.com/api/