未处理的异常:类型“String”不是类型类型“int”的子类型
else if (value is List<int>) {
prefs.setStringList(
"itemsToLoanCats", [...value.map((e) => e.toString())]);
}
“值”的类型= List<int>
我不明白为什么这不管用,我用的是.toString()
堆栈跟踪
I/flutter (16996): Person This is claiming to be
每次必须对数据进行解码时,它都会返回null,而异常类型'double‘不是'int’类型的子类型。问题是下面所附的方法。
Future<void> fetchProducts() async {
final url = Uri.parse(
'https://recipier-e1139-default-rtdb.europe-west1.firebasedatabase.app/recipes.json');
final response = await http.get(url);
final extra
我将在Flutter中使用数据库"Sembast“。具有string和int等数据类型的简单对象工作正常。然而,当使用列表时,它就变得有问题了。 我已经创建了一个示例,并根据以下教程确定了自己的方向:https://resocoder.com/2019/04/06/flutter-nosql-database-sembast-tutorial-w-bloc/在我的示例中,有水果和树叶作为对象。一个水果包含一个叶子列表。 class Fruit {
final String id;
final String name;
final bool isSweet;
final
我已经编写了一个dart方法,该方法接受泛型类型T,然后尝试将动态类型转换为T。(编辑:我已经从等式中删除了泛型,从动态到字符串的转换仍然失败,并出现相同的错误。)
在这个特定的场景中,我传递一个字符串作为T。
下面的代码行抛出错误
T result = value.cast<T>();
完整的代码如下:
class JsonObject{
final Map<String, dynamic> _map;
JsonObject(this._map);
T getValue<T>(String key) {
dyna
import 'dart:convert';
import 'package:flutter/foundation.dart';
import 'package:http/http.dart' as http;
import './cart.dart';
class OrderItem {
final String id;
final double amount;
final List<CartItem> products;
final DateTime dateTime;
OrderItem
我在实现nuget包的接口时遇到了一些问题。接口中有一个如下所示的属性:IList<IInterfaceInstance> Implements {get;}
我的问题是从List<InterfaceInstance>到IList<IInterfaceInstance>的转换。
这就是我想要做的,它给了我以下的例外:
未处理的异常。System.NullReferenceException:对象引用没有设置为对象的实例。
using System;
using System.Collections.Generic;
public class Pro
嗨,我有一个关于Flutter的问题。我得到了这个例外: 未处理的异常:类型'String‘不是类型'bool’的子类型 我尝试从响应中检查token是否存在。 var res = await ApiService().postData(loginData, 'login');
var body = json.decode(res.body);
if (json.decode(res.body)['token']) {
SharedPreferences localStorage = await SharedPreferences.
我使用颤振http请求从服务器获取数据,并在用户滚动到屏幕底部时加载更多数据。我收到这个错误“未处理的异常:类型'List‘不是’Product‘’的一个子类型”。请帮帮忙,我整天都在挣扎,但没有成功。
model.dart文件
class Product {
final int id;
final String accountName,
callNumber,
whatsappNumber,
businessLocation,
caption;
final List<Images> productPhoto;
我有一个ListBox。我在代码中也有一个list。我想将listbox中的所有项目作为我的list的来源。
我试过这样做:
<listBox x:Name="MyList" .../>
list<string> feed = new list<string>();
//to get the source
var feed = MyList.Items.Cast<string>().ToList();
但是它抛出了一个异常:System.InvalidCastException
该怎么办呢?
当我在flutter应用程序中运行main.dart文件时,我得到了以下异常。代码从data.json文件读取数据,并将其映射到SubTypeMap类,然后映射到TypeMap类。有人能建议为什么会发生这种情况以及解决这个问题的方法吗? 例外: [VERBOSE-2:ui_dart_state.cc(186)] Unhandled Exception: type 'List<dynamic>' is not a subtype of type 'List<int>' in type cast
#0 new TypeMap.fr
我正在解码从防火墙获得的JSON对象。但是,在对Map的响应进行类型转换时,我会得到如下错误。
错误:flutter/lib/ui/ui_dart_state.cc(157)未处理的异常:类型'List‘不是'List’的子类型
产品模型
class Product with ChangeNotifier {
final String id;
final String title;
final String description;
final double price;
final String imageUrl;
bool isFavorite;
final leaseMap = lease as Map;
await firebaseProfile.createLease(context, lease).then((newLease) {
leaseMap['documentID'] = newLease.id(); // despite this returns an string it fails
});
未处理异常: NoSuchMethodError:类'String‘没有实例方法'call’。E/颤振( 9361):接收器: