html_slicer library
A Dart/Flutter plugin that truncates HTML while preserving valid structure and certain specified tags.
Constants
-
defaultPreserveTags
→ const Set<
String> - The default set of tag names whose entire block is preserved without counting inner content toward the visible character limit.
Functions
-
sliceHtml(
String html, int maxLength, {bool preserveNewlines = true, Set< String> preserveTags = defaultPreserveTags, String ellipsis = '...'}) → String -
Slices the given
htmlstring to a specifiedmaxLengthof visible characters, preserving the structure of the HTML and optionally preserving newlines.