我在Android设备上尝试了此软件包
https://pub.dartlang.org/packages/flutter_sms#-readme-tab-
但是我认为我有一个问题。
我使用了Github https://github.com/AppleEducate/plugins/blob/master/packages/flutter_sms/example/lib/main.dart上共享的示例
插件需要三思而后行
1: String message = "your message";
2: List<String> recipents = ['XXXXXXXXX'];
但是,当我输入电话号码并启动SMS时,我在输出['XXXXXXXXX']中代替了XXXXXXXXX 所以我的邮件没有发送,因为格式错误
这是插件的dart代码
class FlutterSms {
static const MethodChannel _channel = const MethodChannel('flutter_sms');
static Future<String> get platformVersion async {
final String version = await _channel.invokeMethod('getPlatformVersion');
return version;
}
static Future<String> sendSMS({
@required String message,
@required List<String> recipients, // I tried to change List<String> by String but I have ise
}) async {
var mapData = Map<dynamic, dynamic>();
mapData["message"] = message;
mapData["recipients"] = recipients;
final String result = await _channel.invokeMethod('sendSMS', mapData);
//String _log = "SMS Message: $message";
//for (var person in recipients) _log += "\nSent: $person";
// final String result = _log;
return result;
}
}
我找到了如何通过字符串更改列表的方法,但是我总是输入[XXXXXXXX],而我只输入:recipents =“ XXXXXXXX”; 为什么我有[] !!!
我认为我需要重写这一部分
var mapData = Map<dynamic, dynamic>();
mapData["message"] = message;
mapData["recipients"] = recipients;