flutter_html icon indicating copy to clipboard operation
flutter_html copied to clipboard

[QUESTION] How to remove top and bottom paddings from list items?

Open wodorod opened this issue 5 years ago • 6 comments

Hi, friends, please help in finding, how to remove excessive padding around list items in "ul" list?

Here is a problem visualized (I want to see the same padding as between paragraph html objects: image

Here is a style parameter for Html widget:

{
          "p": Style(
            padding: EdgeInsets.zero,
          ),
          "tr": Style(
            border: Border(bottom: BorderSide(color: Colors.grey)),
          ),
          "th": Style(
            padding: EdgeInsets.all(6)
          ),
          "td": Style(
            padding: EdgeInsets.all(6),
            alignment: Alignment.topLeft,
          ),
          'h5': Style(maxLines: 2, textOverflow: TextOverflow.ellipsis),
          'em': Style(alignment: Alignment.center),
          'li': Style(
            padding: EdgeInsets.zero,
            margin: EdgeInsets.zero,
            listStyleType: ListStyleType.SQUARE
          ),
          'ul': Style(
            padding: EdgeInsets.zero,
            margin: EdgeInsets.zero,
          ),
        },

Here is html example which has unnecessary paddings:

<p>PRUDENCE</p>
<p><em>Deliberation &ndash;</em></p>
<ul>
    <li>Prone to rashness&nbsp;(to charge ahead without proper reflection).</li>
    <li>Tends not to seek advice.</li>
</ul>
<p><em>Decision +</em></p>
<ul>
    <li>Exhibits self-confidence.</li>
</ul>
<p>Сholerics have no problem with making decisions; they have problems with making <em>right </em>decisions. They must practice self-mastery, and moderate their natural impatience. They must also practice humility, and overcome their natural reluctance to ask for advice. This will help them deliberate efficiently.</p>
<p>Cholerics must remember Shakespeare&rsquo;s <em>Othello</em>: he meets a cruel fate brought on by his failure to deliberate. Ever impulsive, he jumps straight to the conclusion without stopping to think. He shoots first and asks questions later.</p>
<p>And yet, the choleric must not let his deliberations &ndash; the time and effort he expends on them &ndash; impede his natural ability to decide. Remember: the aim of prudence is not deliberation, but decision. It is a bad thing not to deliberate, but it is much worse not to decide. Not to decide is basically and fundamentally imprudent.</p>

THANKS

Flutter doesn't allow to use negative paddings and margins, so I couldn't find a solution to "overlap" hidden from eyes paddings.

image

wodorod avatar Oct 23 '21 21:10 wodorod

Hi! Which version of flutter_html are you on. We made several changes/fixes/regressions over the last updates...

erickok avatar Oct 25 '21 08:10 erickok

Hi, @erickok , I use flutter_html: 2.1.5

wodorod avatar Oct 25 '21 18:10 wodorod

Same question here, would be graet to find out how to remove/set the padding/margin

matecode avatar Nov 03 '21 10:11 matecode

@erickok, do you know which version is good to install, where it's fixed?

wodorod avatar Nov 10 '21 18:11 wodorod

@wodorod 2.1.5 is the latest version.

I also ran into this issue, and my workaround, although very - very - hacky, is to split the HTML string on the <ul>'s, and render the news strings separately into Html widgets in a column. flutter_html is too great to skip it all together because of this small 'bugs', but would be great to have it fixed.

@erickok any ideas on how to fix this properly?

codeorelse avatar Nov 23 '21 08:11 codeorelse

Fixed in 2.2.0 release

erickok avatar Nov 29 '21 09:11 erickok