Flutter无法使用fluttersms发送短信

Flutter can''t send sms using fluttersms

我正在尝试在我的应用程序扫描到包含 phone 号码的二维码后发送短信。 我为此使用了 FlutterSMS 包,但它似乎没有按预期工作,它没有发送短信。有帮助吗?

  void _sendSMS(String message, List<String> recipents) async {
    String _result =
        await FlutterSms.sendSMS(message: message, recipients: recipents)
            .catchError((onError) {
      print(onError);
    });
    print(_result);
  }

  Future _scan() async {
    String barcode = await scanner.scan();
    List data = barcode.split("|");
    String id = data[0];
    String phoneNumber = data[1];
    String message = "Halo! Pakaian anda sudah selesai di proses, silahkan ambil di gerai kami -LaundryKu";

    setState(() {
      this.id = id;
      this.barcode = barcode;
      this.phoneNumber = phoneNumber;
    });
    _sendSMS(message, data[1]);
  }

小弟有一点错

第二个参数是列表

_sendSMS(message, recipents);

所以您需要将您的联系电话添加到列表中

List<String> recipents = new List();
recipents.add(data[1].toString());

/// then the Msg in Variable

String message = "This is a test message!";

最终将两个变量作为参数传递给函数

_sendSMS(message, recipents);

终于完成了 ;)