【发布时间】:2021-09-15 20:55:11
【问题描述】:
【问题讨论】:
标签: flutter android-studio dart mobile
【问题讨论】:
标签: flutter android-studio dart mobile
您收到此错误是因为您的 dataCart[index].price 类型是 String。
当您使用dataCart[index].price *= _count[index] 时,它实际上返回了另一个字符串。假设您的dataCart[index].price 值为"21",_counter[index] 值为3。然后dataCart[index].price *= _count[index] 将返回"212121"。这就是为什么dataCart[index].price *= _count[index] 这个没有任何错误。但是,当您尝试从 String 中减去 Integer 时,它会报错。
因此,您应该将price String 的类型更改为int。
【讨论】:
我认为您必须将price 的类型从String 更改为int。
这是您的错误的解决方案。
【讨论】: