首页 > 解决方案 > Flutter Firestore 数据传输

问题描述

我正在为我的应用程序创建一个转账功能,这样当按下转账按钮时,输入的金额将被转账到目标电子邮件的帐户。

这是数据库的屏幕截图, 截图1 截图2

请注意,我特意将文档 id 设置为用户的 uid。

以下是我到目前为止的代码,

Column(
  mainAxisAlignment: MainAxisAlignment.start,
  children: [
    SizedBox(height: 15),
    TextFormField(
      keyboardType: TextInputType.number,
      controller: _amount,
      decoration: InputDecoration(
        hintText: 'Amount',
        helperText:'Enter the amount of money you would like to transfer',
      ),
    ),
    SizedBox(height: 15),
    TextFormField(
      controller: _reference,
      decoration: InputDecoration(
        hintText: 'Transfer Details',
        helperText: 'Enter a Recipient Reference',
      ),
    ),
    SizedBox(height: 15),
    sendButton(_amount.text),
  ],
),

RaisedButton sendButton(String _amount) {
  return RaisedButton(
    color: Colors.green,
    shape: StadiumBorder(),
    child: Text(
      'Send',
      style: TextStyle(
        color: Colors.white,
      ),
    ),
    onPressed: () async {

    },
  );
}

我想这样做,所以当我按下按钮时,我当前登录用户的钱(来自 firestore 字段)将转移到目标收件人的帐户。

我对 Firestore 和 Flutter 还很陌生,所以如果这不可能,也可以是减去当前用户的钱并将相同金额添加到收款人的钱中。

标签: fluttergoogle-cloud-firestore

解决方案


推荐阅读