Sub6Resources / flutter_html

A Flutter widget for rendering static html as Flutter widgets (Will render over 80 different html tags!)
https://pub.dev/packages/flutter_html
MIT License
1.79k stars 859 forks source link

[BUG] Html keep reload #727

Closed haophan1996 closed 2 years ago

haophan1996 commented 3 years ago

hello guys, currently I have one issue on loading image. Even when loading is completely but the widget still loading

Capture

as you can see on the image that the widget keep spinning, this widget inside listview.builder -> Html - > this widget

here is my code

Capture2

and flutter doctor -v Capture3

Is they anyway to prevent that widget keep rebuilding

yisan commented 3 years ago

I had the same problem .

tneotia commented 3 years ago

@yisan are you also using ExtendedImage.network?

haophan1996 commented 3 years ago

I dont think extended image causes issue, i tried something else such cachedimage, image but still problem.

yisan commented 3 years ago

@yisan are you also using ExtendedImage.network? Html(data:info.content) and Html( data: info.content, customImageRenders: { networkSourceMatcher(domains: ["seapard.com"]): (context, attributes, element) { if(attributes['src'].toString().contains('static.seapard.com')){ return Image.network(attributes['src'].toString(),width: 300,height: 300,); }else{ return Container(); } }, } )

the same problem.

info.content ===>
image

tneotia commented 3 years ago

@yisan I tried your code on master branch and I couldn't reproduce the reloading issue (Samsung S10+, latest Flutter beta): image The Image.network only rebuilds twice.

@haophan1996 could you share your HTML code so I can try and reproduce the issue? I have a feeling the reloading issue only happens with longer HTML pages.

haophan1996 commented 3 years ago

@yisan I tried your code on master branch and I couldn't reproduce the reloading issue (Samsung S10+, latest Flutter beta): image The Image.network only rebuilds twice.

@haophan1996 could you share your HTML code so I can try and reproduce the issue? I have a feeling the reloading issue only happens with longer HTML pages.

@tneotia I just figured out that the image keep loading because there are some posts contains gif image, so it keep reloading.

but if I scroll up and down, the image widget keep loading,

I'm sorry for a late replies

here is the html

html.txt

tneotia commented 3 years ago

@haophan1996 for GIFs it will reload because it is loading multiple frames, it is not a static image.

As for your HTML, thanks, I tried it out:

image

As you can see there are not any widget rebuilds. I scrolled up and down many times. I think your rebuilds are just because Flutter is disposing the image to free up resources as the page scrolls, and when the image is loaded back into view, Flutter rebuilds it. I could be wrong but I don't think this would be an issue with the package, since we store the widget as a final variable and only load it once. I used a print statement in the customRender function and it was only displayed at the beginning, not while scrolling.

haophan1996 commented 3 years ago

@tneotia Thank you for helping me sir

jiangxiaoqiang commented 3 years ago

so, this is the flutter problem? not html package's problem?

LucMoreau33560 commented 3 years ago

Hi, even if it is a flutter issue, does someone have a workaround to stop image reloading ?

tneotia commented 3 years ago

Hi, even if it is a flutter issue, does someone have a workaround to stop image reloading ?

Not a flutter issue, we have a PR for the issue to fix it. Thanks to @jiangxiaoqiang

Edit: Actually it was merged, do you still experience this problem on the latest release?

LucMoreau33560 commented 3 years ago

Hello @tneotia , Yes I'm still having this problem using pub.dev 2.1.2 version. I also clone the master branch of the git repo (2.1.2), and the problem is also still present.

https://user-images.githubusercontent.com/22540544/133383610-9959b418-b4ae-407e-b43f-aab7f6062186.mp4

Below I put the code of the widget that uses flutter_html package and I also put the html text that is displayed.

`import 'dart:core';

import 'package:flutter/material.dart'; import 'package:flutter_html/flutter_html.dart'; import 'package:lawgo/src/widgets/simpleAppBar.dart';

class PageInformations extends StatelessWidget { String texte; String titre;

PageInformations({this.titre, this.texte});

@override Widget build(BuildContext context) { return Stack(children: [ Container( decoration: BoxDecoration( image: DecorationImage( image: AssetImage("assets/images/fond-gris.png"), fit: BoxFit.cover, ), ), ), Scaffold( backgroundColor: Colors.transparent, body: getScrollingDisplay(), extendBody: true, extendBodyBehindAppBar: true, appBar: titre == null ? null : SimpleAppBar(titre, "", true, false), ) ]); }

Widget getScrollingDisplay() { return SingleChildScrollView( child: Padding( padding: EdgeInsets.only(top: 40, left: 20, right: 20, bottom: 100), child: Html(data: this.texte), ), ); } } `

`

 1. Cliquez sur  pour trouver l’avocat qu’il vous faut. Vous pouvez faire une recherche en fonction de vos besoins (par mots-clés ou par domaine de compétences), en fonction de vos disponibilités ou par ville.

 2. Cliquez sur  pour retrouver les visio-consultations que vous avez réservées.

 3. À l’heure choisie, il vous suffira ensuite de cliquer sur  . La visio-consultation se lancera ensuite lorsque l’avocat sera également présent.

 4. Vous disposez d’une visio-consultation d’une durée maximale de 20 minutes pour obtenir en toute confidentialité des conseils de la part de votre avocat. 

Si vous souhaitez obtenir les coordonnées de l'avocat, il vous suffit de le faire avant l'expiration du délai de 20 minutes.

 


Foire aux questions

1. Comment se déroule la visio-consultation ?

Comme pour une consultation en cabinet, vous devez exposer clairement votre situation à l’avocat qui pourra alors vous conseiller utilement. Durant la visio-consultation, vous pourrez si vous le souhaitez présenter des documents à l’avocat en utilisant la caméra de votre smartphone.

2. Est-il possible d’annuler une visio-consultation ?

Oui. Vous pouvez annuler sans frais une visio-consultation jusqu’à 24 heures avant l’heure réservée. Au-delà il ne vous sera plus possible d’annuler et aucune somme ne vous sera restituée

3. Est-ce que la visio-consultation est confidentielle ?

Oui. La visio-consultation est non seulement confidentielle mais elle également sécurisée. Nous vous recommandons d’effectuer la visio-consultation dans un endroit vous permettant de vous exprimer librement avec l’avocat.

3. Suis-je limité dans le nombre de visio-consultations ?

Non. Vous pouvez réserver autant de visio-consultations que vous le souhaitez.

` Many thanks for your help