通过Flutter应用拨打电话
我尝试通过Flutter应用程序拨打电话。使用以下代码:
UrlLauncher.launch('tel: xxxxxxxx');我在github
flutter存储库上发现了此功能:https :
//github.com/flutter/flutter/issues/4856
但这对我不起作用。此功能仍在Flutter中和使用哪种包装?还是有更好的选择通过我的应用程序拨打电话?
回答:
我尝试在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
以上是 通过Flutter应用拨打电话 的全部内容, 来源链接: utcz.com/qa/433814.html








