Search code examples
flutterdartandroid-studio

how can i show html layout link in flutter?


I'm trying to make a html ad widget using html package, but the widget just occupy space, doesn't display layout.

Widget _adWIdget() {
    return Html(data: """
    <iframe src=adUrl width="100%" height="44" frameborder="0" scrolling="no" referrerpolicy="unsafe-url"></iframe>
    """);
  }

I think it's because I didn't setup a layout showing, how can I show the html layout?


Solution

  • I solved it, when using iframe, you should use not only html but also the external package html_iframe.(you can install 'flutter pub add flutter_html_iframe')

    The external package includes the following.

    • flutter_html_all
    • flutter_html_audio
    • flutter_html_iframe
    • flutter_html_math
    • flutter_html_svg
    • flutter_html_table
    • flutter_html_video

    and you can use the following code.

    Widget _adWIdget() {
      return Html(
        data: """
          <iframe src=adUrl width="100%" height="44" frameborder="0" scrolling="no" referrerpolicy="unsafe-url"></iframe>
          """,
        extensions: [
          IframeHtmlExtension(),
        ],
      );
    }