Firebase 颤振火基分配编号

Firebase 颤振火基分配编号,firebase,flutter,google-cloud-firestore,Firebase,Flutter,Google Cloud Firestore,我用的是firebase和Flatter。当我尝试上载产品时,我遇到一个错误: type 'double' is not a subtype of type 'int' 当我在CloudFirestore中手动键入cost时,修复了问题,但我无法从我的应用程序添加产品 以下是我的产品型号的编号部分: dynamic newPrice, buyPrice; dynamic get getNewPrice=> int.parse(newPrice);

我用的是firebase和Flatter。当我尝试上载产品时,我遇到一个错误:

type 'double' is not a subtype of type 'int'
当我在CloudFirestore中手动键入cost时,修复了问题,但我无法从我的应用程序添加产品

以下是我的产品型号的编号部分:

   dynamic newPrice, buyPrice;
      dynamic get getNewPrice=> int.parse(newPrice);
    
      set setNewPrice(dynamic newPrice) =>
          this.newPrice= int.parse(newPrice);
 dynamic get getbuyPrice=> int.parse(buyPrice);

  set setBuyoutPrice(dynamic buyPrice) =>
      this.buyoutPrice = int.parse(buyPrice);
错误


Firebase以双精度格式存储数字,即使您只发送一个int,因此如果您从Firebase获取数字类型的数据,您需要将其解析为双精度。如果您在firebase控制台中手动键入一个整数,您将能够像解析int一样解析它,但这只是一个“手动破解”。

firebase以双精度格式存储数字,即使您只发送int,因此如果您从firebase中获取数字类型的数据,您需要将其解析为双精度。如果您在firebase控制台中手动键入一个整数,您将能够像解析int一样解析它,但这只是一个“手动破解”。

然后尝试在double中解析newPrice和buyPrice。您确实应该避免在Dart中将变量定义为动态变量,除非非常特殊的情况。你需要知道你期望的变量是什么类型。我试着分析double&int确实不能找出总是相同的错误,然后试着在double中分析newPrice和buyPrice。你真的应该避免在Dart中将变量定义为动态变量,除非是非常特殊的情况。你需要知道你期望的变量是什么类型。我试着解析double&int,但真的无法找出总是相同的错误