我正在尝试使用 flutter 包 url 启动器发送短信。当我按下按钮时:只有这个出现在短信的正文中(在安卓上):https://www.google.com/maps/dir/?api=1
但是'Text'有点长。有解决办法吗?谢谢!
RaisedButton(
onPressed: () {
launch(
'sms:000000000?body=https://www.google.com/maps/dir/?api=1&destination=47.751076,-120.740135');
},
我测试了没有“&”符号的链接。比它通过一切。是否可以选择使用 & 符号?
最佳答案
您需要对 URL 中的特殊字符使用 URL 编码。
所以 &
等于 %26
这会起作用
launch('sms:000000000?body=https://www.google.com/maps/dir/?api=1%26destination=47.751076,-120.740135');
另一种方法是通过 Uri.encodeFull(urlString)
或 Uri.encodeComponent(urlString)
进行编码和传递
像这样。
launch("sms:" + Uri.encodeComponent('000000000?body=https://www.google.com/maps/dir/?api=1&destination=47.751076,-120.740135'));
关于Flutter Url Launcher 不会将整个文本传递给短信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57448693/