flutter_widget_from_html icon indicating copy to clipboard operation
flutter_widget_from_html copied to clipboard

Text wrap around image

Open ankelkoss opened this issue 8 months ago • 0 comments

Good day. Please tell me how to implement text wrapping around a picture. The only thing I managed to implement is this:

StylesMap? customStylesBuilder(element) {
    final width = MediaQuery.of(context).size.width.toInt();
    const imgSize = 150;

    if (element.classes.contains("container")) {
      final map = {
        "width": "${width}px",
        // "max-width": "${width}px",
        "display": "flex",
        "flex-wrap": "wrap",

        "align-items": "flex-start",
        // "margin-right": "10px",
        // "margin-bottom": "10px",
      };

      return map;
    }

    if (element.classes.contains("image")) {
      return {
        "flex": "0 0 auto",
        "max-width": "${imgSize}px",
        "margin-right": "10px",
        "margin-bottom": "10px",
      };
    }

    if (element.classes.contains("text")) {
      return {
        "flex": "1 1 0",
        // "min-width": "${width - imgSize - 10}px",
        "margin": "0",
      };
    }

    return null;
  }

    <div>
        <div class=""container"">
            <img>IMAGE</img>
            <p class=""text"">
                TEXT
            </p>
        </div>
        <p class=""text"">
            TEXT
        </p>
    </div>
    <div class=""container"">
        <p class=""text"">
            TEXT
        </p>
          <img>IMAGE</img>
    </div>

ankelkoss avatar Apr 18 '25 09:04 ankelkoss