Uni*_*ing 11 dart flutter flutter-dependencies
我正在构建一个应用程序,它必须能够接受订单并将其发送到特定的 WhatsApp 号码。我到底该怎么做?我可以打开 WhatsApp,但在打开它时我不知道如何发送消息。
title: new Text("WhatsApp"),
trailing: new Icon(Icons.message),
onTap: () async {
int phone = 962770593839;
var whatsappUrl = "whatsapp://send?phone=$phone";
await UrlLauncher.canLaunch(whatsappUrl) != null
? UrlLauncher.launch(whatsappUrl)
: print(
"open WhatsApp app link or do a snackbar with
notification that there is no WhatsApp installed");
},
Run Code Online (Sandbox Code Playgroud)
我希望当我输入一个 TextField 并按下发送时,保存的字符串将能够在启动 WhatsApp 后发送到 WhatsApp 号码。
Ste*_*wal 12
使用插件。
使用以下链接:https : //api.whatsapp.com/send?phone =XXXXXXXXXXX(在 X 的位置键入您要联系的人的电话号码,包括国家/地区代码,但不带 + 号。)
Run Code Online (Sandbox Code Playgroud)RaisedButton( onPressed: () async => await launch( "https://wa.me/${number}?text=Hello"),, child: Text('Open Whatsapp'), ),
或者
您可以使用这个其他插件。
whatsapp_unilink 包可帮助您构建 HTTP 链接并为您提供一个惯用的 Dart 接口:
Run Code Online (Sandbox Code Playgroud)import 'package:whatsapp_unilink/whatsapp_unilink.dart'; import 'package:url_launcher/url_launcher.dart'; launchWhatsApp() async { final link = WhatsAppUnilink( phoneNumber: '+001-(555)1234567', text: "Hey! I'm inquiring about the apartment listing", ); await launch('$link'); }
| 归档时间: |
|
| 查看次数: |
17669 次 |
| 最近记录: |