首页 > 解决方案 > Flutter for web 编写新标签

问题描述

所以我有一个base64编码字节的html。

我想做类似的事情

let pdfWindow = window.open("")
pdfWindow.document.write("<iframe width='100%' height='100%' src='data:application/pdf;base64, " + encodeURI(base64EncodedPDF) + "'></iframe>")

在 web 上颤动。但是,当我跑步时

var openWindow = html.window.open("", "Form");

我没有能力为 pdf 编写 HTML。

我的目标是能够从浏览器打印 pdf,

有人知道从这里去哪里吗?

标签: flutterflutter-web

解决方案


使用 url_launch 包url_launch

void main() {
runApp(Scaffold(
body: Center(
  child: RaisedButton(
    onPressed: _launchURL,
    child: Text('Show Flutter homepage'),
     ),
   ),
  ));
}

 _launchURL() async {
 const url = 'https://flutter.dev';
  if (await canLaunch(url)) {
 await launch(url);
 } else {
throw 'Could not launch $url';
 }
}

推荐阅读