Flutter send sms with device automatically
我在Flutter中实现了此问题中给出的代码,并在iOS应用中运行了该代码。但是,我遇到了一个MissingPluginException异常(找不到在通道Send SMS上发送方法的实现)
代码
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter/services.dart';
import 'package:sms/contact.dart';
import 'login_page.dart';
class SendSMS extends StatefulWidget{
_SendSMS createState() => new _SendSMS();
}
class _SendSMS extends State<SendSMS>{
@override
static const platform = const MethodChannel('Send SMS ');
Future<Null> send()async {
print("SendSMS");
try {
**final String result = await platform.invokeMethod('send',
<String,dynamic>{"msg":"Hello! I'm sent programatically."});**
} on PlatformException catch (e) {`enter code here`
print(e.toString());
}
}
Widget build(BuildContext context) {
// TODO: implement build
return new Material(
child : new Container(
alignment: Alignment.center,
child : new FlatButton(onPressed: send, child: new Text('send SMS
'))
),
);
}
}
`import'package:flutter / material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter/services.dart';
import 'package:sms/contact.dart';
import 'login_page.dart';
class SendSMS extends StatefulWidget{
_SendSMS createState() => new _SendSMS();
}
class _SendSMS extends State<SendSMS>{
@override
static const platform = const MethodChannel('Send SMS ');
Future<Null> send()async {
print("SendSMS");
try {
**final String result = await platform.invokeMethod('send',
<String,dynamic>{"msg":"Hello! I'm sent programatically."});**
} on PlatformException catch (e) {`enter code here`
print(e.toString());
}
}
Widget build(BuildContext context) {
// TODO: implement build
return new Material(
child : new Container(
alignment: Alignment.center,
child : new FlatButton(onPressed: send, child: new Text('send SMS
'))
),
);
}
}`What should i change to make this working ?