如何将数据保存到Flotter中textformfield中的cloud firebase作为数字

如何将数据保存到Flotter中textformfield中的cloud firebase作为数字,firebase,google-cloud-platform,flutter,Firebase,Google Cloud Platform,Flutter,我的表单包含一些textformfield,其中一个字段是价格,我想保存为数字而不是字符串。下面是我的textformfield代码 new TextFormField( keyboardType: TextInputType.number, style: new TextStyle(fontFamily: "ChelaOne-Regular", colo

我的表单包含一些textformfield,其中一个字段是价格,我想保存为数字而不是字符串。下面是我的textformfield代码

 new TextFormField(
                      keyboardType: TextInputType.number,
                      style: new TextStyle(fontFamily: "ChelaOne-Regular",
                          color: Colors.white,
                          fontSize: 20.0),
                      decoration: new InputDecoration(
                          labelText: "Price",
                          labelStyle: new TextStyle(
                              fontFamily: "ChelaOne-Regular",
                              color: Colors.white),
                          hintText: "Please enter Price ",
                          hintStyle: new TextStyle(
                              fontFamily: "ChelaOne-Regular",
                              color: Colors.white,
                              fontSize: 15.0)),
                      validator: (val) =>
                      val.isEmpty
                          ? 'Please enter Discribtion'
                          : null,
                        onSaved: (val) => price = val,
                    ),
我保存数据的代码是

Firestore.instance.collection('item').document().setData({
        "Discribtion": discribtion,
        "Title": title,
        "price":price,

      });
      Done();
      Navigator.pop(context);
    }
  }
其中price是num(num price;) 请帮我做这件事

String numString = '3';
int numInt = int.parse(numString);
所以你可以这样做:

Firestore.instance.collection('item').document().setData({
        "Discribtion": discribtion,
        "Title": title,
        "price":int.parse(price),

      });