1
我尝试通过我的Flutter应用打电话。用下面的代码:从扑翼应用打电话
UrlLauncher.launch('tel: xxxxxxxx');
我发现在github上扑回购此功能:https://github.com/flutter/flutter/issues/4856
但是,这并不为我工作。这个函数仍然在颤抖和包装?或者有更好的选择从我的应用打电话吗?
我尝试通过我的Flutter应用打电话。用下面的代码:从扑翼应用打电话
UrlLauncher.launch('tel: xxxxxxxx');
我发现在github上扑回购此功能:https://github.com/flutter/flutter/issues/4856
但是,这并不为我工作。这个函数仍然在颤抖和包装?或者有更好的选择从我的应用打电话吗?
我在Android/iOS上试过这个launch("tel://214324234")
,它运行良好。 您需要安装包url_launcher并将其导入
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
home: new Home(),
);
}
}
class Home extends StatelessWidget {
Home({Key key}) : super(key: key);
@override
Widget build(BuildContext context) => new Scaffold(
appBar: new AppBar(
title: new Text("View"),
),
body: new Center(
child: new FlatButton(
onPressed:() => launch("tel://21213123123"),
child: new Text("Call me")),
),
);
}
void main() {
runApp(
new MyApp(),
);
}
您也可以导入import 'package:url_launcher/url_launcher.dart' as UrlLauncher;
然后用UrlLauncher.launch("tel://21213123123")
一定要包括在pubspec.yaml文件为一个条目,在依赖部分: url_launcher:^ 1.0.2
你在代码中如何使用它?我的问题是无法找到UrlLauncher。 –