我尝试在Android / iOS上运行launch(“tel://214324234”),效果很好。您需要安装软件包url_launcher并将其导入 import it
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.21.0.2
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)