【问题标题】:How do I copy a web page including html tags to a Fluter app?如何将包含 html 标签的网页复制到 Flutter 应用程序?
【发布时间】:2021-05-05 05:45:08
【问题描述】:

如果我选择网页的一部分(如附图所示),并将其复制到 Microsoft Word 中,几乎所有信息都会显示出来,包括标题、超链接和图像。

但如果我将其粘贴到 Flutter 应用程序,则只会显示纯文本。 所以我的问题是如何将这些 html 标签复制到 Flutter 应用程序?

谢谢。

【问题讨论】:

  • 不幸的是没有。我需要先获取那些 html 文本。我现在从剪贴板得到的是纯文本。
  • 为什么你想这样做?除非您使用 dart:html 手动将 html 解析为小部件,否则这是不可能的
  • 用户可能想从互联网上复制一些内容并发布到应用程序。

标签: html flutter clipboard


【解决方案1】:

你可以使用flutter_html包,你可以在这个链接上找到它=> https://pub.dev/packages/flutter_html 这就是你可以使用它的方式

 Future<void> showPrivacyPolicy(BuildContext context) async {
   return showCupertinoModalBottomSheet(
    context: context,
    isDismissible: true,
    builder: (context) => Material(
      child: Column(
       children: [
         AppBar(
           title: Text(
            'PRIVACY POLICY',
             style: TextStyle(color: Colors.white),
           ),
           centerTitle: true,
           backgroundColor: ceruleanTwo,
           elevation: 0,
         ),
         Expanded(
           child: SingleChildScrollView(
             child: Html(
               data: privacyString,
             ),
           ),
         ),
       ],
     ),
    ),
   );
 }

【讨论】:

    猜你喜欢
    • 2018-12-10
    • 2012-02-13
    • 1970-01-01
    • 2019-02-13
    • 2016-11-06
    • 1970-01-01
    • 1970-01-01
    • 2022-07-10
    • 2021-11-02
    相关资源
    最近更新 更多