flutter_html icon indicating copy to clipboard operation
flutter_html copied to clipboard

[BUG] half of the picture is cut out in mobile screen, but in the old version, everything was fine, can you help what to do ?

Open Tigran-Kosemyan opened this issue 1 year ago • 4 comments

Tigran-Kosemyan avatar Jun 27 '23 06:06 Tigran-Kosemyan

Can you provide some more detail, like an example of your code?

jasonflaherty avatar Jun 29 '23 19:06 jasonflaherty

Html(
      shrinkWrap: true,
      data: html,
      style: {
        "table": Style(
          height: Height.auto(),
          width: Width.auto(),
        ),
        "tr": Style(
          height: Height.auto(),
          width: Width.auto(),
        ),
        "th": Style(
          padding: HtmlPaddings.all(6),
          height: Height.auto(),
          border: const Border(
            left: BorderSide(color: Colors.black, width: 0.5),
            bottom: BorderSide(color: Colors.black, width: 0.5),
            top: BorderSide(color: Colors.black, width: 0.5),
          ),
        ),
        "td": Style(
          padding: HtmlPaddings.all(6),
          height: Height.auto(),
          border: const Border(
            left: BorderSide(color: Colors.black, width: 0.5),
            bottom: BorderSide(color: Colors.black, width: 0.5),
            top: BorderSide(color: Colors.black, width: 0.5),
            right: BorderSide(color: Colors.black, width: 0.5),
          ),
        ),
        "col": Style(
          height: Height.auto(),
          width: Width.auto(),
        ),
      },
      extensions: [
        TagWrapExtension(
            tagsToWrap: {'table'},
            builder: (child) {
              return SingleChildScrollView(
                scrollDirection: Axis.horizontal,
                child: SizedBox(
                  width: 1000,
                  child: child,
                ),
              );
            }),
        const TableHtmlExtension(),
      ],

sure Im add table style because table lines not show and parent on Html SingleChildScrollview inside Scaffold

Tigran-Kosemyan avatar Jun 29 '23 20:06 Tigran-Kosemyan

I finally fix this issue by using FittedBox

Html(
            extensions: [
              TagWrapExtension(
                  tagsToWrap: {'img'},
                  builder: (child) {
                    return FittedBox(
                      child: child,
                    );
                  })
            ]
        )

Update : From issue #1307, I decide to use TagExtension instead.

TagExtension(
          tagsToExtend: {"img"},
          builder: (context){
            return FittedBox(
              child: Image(
                image: NetworkImage(context.attributes["src"]!),
              ),
            );
          }
        )

CHA7R1K avatar Sep 06 '23 03:09 CHA7R1K

The FittedBox Approach didn't work for me, neither using ConstrainedBox with maxHeight works. The only solution for me is to give the image a fixed height, say 300 but it will also scale all images with lower resolution to 300. Any other solutions?

kedarkarkee avatar Dec 26 '23 15:12 kedarkarkee