flutter_html_css_all library
One dependency and one import for the flutter_html extension packages of
this family, plus the registration order they have to be listed in.
This library re-exports twenty-one packages; BundledCssExtensions registers nineteen instances. The two it leaves out have no default that suits every document, and BundledCssExtensions says which and why.
It declares no extension class
of its own and wraps none of theirs. That is a hard constraint rather than a
style choice: flutter_html_bootstrap and
flutter_html_vuetify recognise a companion extension by
runtimeType.toString(), so a wrapper class would carry the wrong name and
switch their suppression back on. The instances BundledCssExtensions
registers are the sibling classes themselves.
import 'package:flutter_html/flutter_html.dart';
import 'package:flutter_html_css_all/flutter_html_css_all.dart';
Html(
data: '<div style="max-width: 320px; overflow: hidden;">Card</div>',
extensions: const BundledCssExtensions(),
);
BundledCssExtensions is a List<HtmlExtension> with const constructors
only. kBundledCssExtensions is a const instance of the defaults, and
bundledCssExtensions is the function form.
The order is the reason the package exists. Each sibling states its own ordering rules, and several of them are silent failures: the document renders, one property does not apply, and nothing is logged. The order is recorded property by property in doc/order.md.
Classes
- BundledCssExtensions
- The extensions this package registers, in the one registration order that satisfies every ordering rule the sibling packages state.
- ClassListCssResolver
- Implement this to translate ordered class lists into inline CSS.
- ClassToInlineCssExtension
-
Generic HtmlExtension that runs only at the
preStylingstep and merges resolver output intostyle="". - CssBackgroundHtmlExtension
-
Renders the colour of a CSS
backgroundshorthand, whichflutter_html3.0.0 drops whole. - CssBorder
- The four resolved sides of a box.
- CssBorderHtmlExtension
-
Adds runtime support for the CSS border longhand properties
flutter_htmldrops. - CssBorderRadiusHtmlExtension
- Adds runtime support for native CSS border-radius via a wrapper + clipping.
- CssBorderSide
- One resolved side of a box.
- CssColorHtmlExtension
-
Corrects the CSS colours that
flutter_html3.0.0 mis-reads or drops. - CssDeclaration
-
One declaration of an inline
style=""attribute, in source order. - CssEdgeLength
- One side of a padding or margin, as this extension will write it.
- CssEffects
-
The subset of CSS painting properties this package can render, as read from
one element's final inline
style="". - CssEffectsHtmlExtension
-
Adds runtime support for the CSS painting properties
flutter_htmldrops:opacity,box-shadowandvisibility. - CssFlexBasis
-
A parsed
flex-basis. - CssFlexContainer
- Everything this extension reads off a flex or grid container.
- CssFlexHtmlExtension
-
Lays out CSS flexbox containers, single-axis grid containers, and
gap. - CssFlexItem
- Everything this extension reads off a flex item.
- CssFlexLayout
- Lays a list of flex or grid items out the way container asks for.
- CssFontSize
-
One parsed CSS
font-sizevalue. - CssFontSizeHtmlExtension
-
Renders a relative CSS
font-sizethatflutter_html3.0.0 drops or compounds. - CssGridTrack
-
One track of a
grid-template-columnslist. - CssInteraction
-
The interaction behaviour resolved from one element's inline
style="". - CssInteractionHtmlExtension
-
Adds runtime support for the CSS
pointer-events,user-selectandcursorproperties, of whichflutter_html3.0.0 parses none. - CssLineHeight
- One corrected CSS line height.
- CssLineHeightHtmlExtension
-
Renders the CSS
line-heightthatflutter_html3.0.0 renders too tall. - CssMatrixFunction
-
matrix(a, b, c, d, e, f), the raw 2D affine form. - CssObjectFitDeclarations
-
The
object-fitandobject-positiondeclarations of one inline style. - CssObjectFitHtmlExtension
-
Renders the CSS
object-fitandobject-positionproperties on<img>elements. - CssOverflowAxes
-
The computed
overflow-xandoverflow-yof one element, as read from its final inlinestyle="". - CssOverflowClipper
- Clips one axis of a box and leaves the other free.
- CssOverflowHtmlExtension
-
Adds runtime support for the CSS
overflow,overflow-xandoverflow-yproperties, whichflutter_html3.0.0 does not parse at all. - CssPercentEdges
- The sides of one element's padding or margin that this extension writes.
- CssPercentSizeHtmlExtension
-
Renders a percentage
width,height, padding or margin, whichflutter_html3.0.0 renders as zero pixels. - CssPercentSizes
-
The percentage
width,height, padding and margin found on one element's inline style. - CssRotateFunction
-
rotate(), held in radians. - CssScaleFunction
-
scale(),scaleX()andscaleY(). - CssSizeConstraints
-
The
max-width/min-width/max-height/min-heightdeclarations found on one element, still in their authored units. - CssSizeConstraintsHtmlExtension
-
Adds runtime support for the CSS
max-width,min-width,max-heightandmin-heightproperties, whichflutter_html3.0.0 does not parse at all. - CssSizeLength
-
One CSS length written on a
max-*/min-*property, kept in the unit the author wrote it in. - CssSkewFunction
-
skew(),skewX()andskewY(), held in radians. - CssSpacing
-
A parsed
letter-spacingorword-spacingvalue. - CssSpecificity
- The specificity of one selector, as the three counts CSS defines.
- CssStyleRule
- One style rule out of a stylesheet, for one selector.
- CssStylesheetHtmlExtension
-
Makes the declarations in a
<style>block reachflutter_htmland its extension family. - CssTextMetricsHtmlExtension
-
Adds runtime support for the CSS text metrics that
flutter_html'sStylealready carries:letter-spacing,word-spacing,text-decoration-thickness, and the tail of afont-familylist. - CssTextOverflowHtmlExtension
-
Adds runtime support for the CSS text-overflow family:
text-overflow,white-spaceand-webkit-line-clamp. - CssTextTransformHtmlExtension
-
Renders
text-transform, whichflutter_html3.0.0 parses and then never applies. - CssTransform
-
One element's
transformandtransform-origin, read from its final inlinestyle="". - CssTransformBox
- Applies a parsed CSS transform to child at paint time.
- CssTransformFunction
-
One function from a
transformlist, with its percentages still unresolved. - CssTransformHtmlExtension
-
Adds runtime support for the CSS
transformandtransform-originproperties, whichflutter_htmldrops. - CssTransformLength
-
One
<length-percentage>from a transform declaration. - CssTransformOrigin
-
The point a transform turns and scales around: CSS
transform-origin. - CssTranslateFunction
-
translate(),translateX()andtranslateY(). - CssUnitsHtmlExtension
-
Renders the CSS absolute and viewport length units that
flutter_html3.0.0 reads as pixels or as zero. - ImgAltElement
-
The prepared form of an
<img>that renders as itsalttext. - ImgAltHtmlExtension
-
Renders the
alttext of an<img>whosesrcthe built-in image renderer declines. - Insert
- One insertion point inside a BundledCssExtensions.
- RenderCssTransform
- The render object behind CssTransformBox.
- StylesheetDeclaration
-
One
property: valuepair out of a stylesheet or an inline style. - UnrenderableTagReporter
- Collects unrenderable tag names and emits one FlutterError report per parsed document.
- UnsupportedCssRule
-
One rule that renders nothing, handed to
onUnsupportedRule.
Enums
- CssAlign
-
CSS
align-itemsandalign-self. - CssAlignContent
-
CSS
align-content. - CssBorderStyle
-
The
border-stylekeywords CSS defines. - CssEdgeUnit
- The unit of one CssEdgeLength.
- CssFlexBasisKind
- How a flex item sizes itself along the main axis before growing.
- CssFlexDirection
-
CSS
flex-direction. - CssFlexDisplay
- The formatting context an element asks for.
- CssFlexWrap
-
CSS
flex-wrap. - CssFontSizeUnit
-
The units a CSS
font-sizecan state thatflutter_html3.0.0 can hold. - CssJustifyContent
-
CSS
justify-content. - CssObjectFit
-
The CSS
object-fitkeywords, and the BoxFit each one maps to. - CssOverflow
-
The
overflowkeywords this package understands. - CssSizeUnit
- Every CSS unit CssSizeLength understands.
- CssSpacingUnit
- The length units this package resolves.
- CssVisibility
-
The
visibilitykeywords this package understands. - UnsupportedCssReason
- Why a rule in a stylesheet renders nothing.
Constants
- kAssumedDecorationThicknessDivisor → const double
- How many times a text font's own decoration line fits into its font size.
-
kBundledCssExtensionNames
→ const List<
String> - The class name of each default entry of BundledCssExtensions, in order.
- kBundledCssExtensions → const BundledCssExtensions
-
A
constinstance of the defaults, usable wherever aList<HtmlExtension>is. -
kCssAbsoluteUnitsInPx
→ const Map<
String, double> - How many CSS pixels one unit of each absolute length unit is.
-
kCssBackgroundKeywords
→ const Set<
String> -
The keywords the non-colour components of a
backgroundshorthand can be:nonefor the image, the position, size, repeat, attachment and box keywords. Each is a valid component and is dropped from the rewritten declaration. -
kCssBorderProperties
→ const Set<
String> -
The CSS properties
CssBorderHtmlExtensionadds. -
kCssColorFunctions
→ const Set<
String> -
The CSS colour functions. A token
name(...)with one of these names is a colour token to isCssColorToken. -
kCssColorProperties
→ const Set<
String> - The CSS properties rewriteInlineStyleColors rewrites a colour inside.
-
kCssCursorKeywords
→ const Map<
String, SystemMouseCursor> -
CSS
cursorkeywords mapped to their nearest Flutter SystemMouseCursor. -
kCssDisplayRepairValues
→ const Set<
String> -
The
displayvalues this extension repairs without laying them out. -
kCssEffectsProperties
→ const Set<
String> -
The CSS properties
CssEffectsHtmlExtensionrenders. -
kCssFlexDisplayValues
→ const Set<
String> -
The
displayvalues this extension renders. - kCssFlexFallbackFontSize → const double
-
The default font size
flutter_htmlstarts a document at. -
kCssFlexProperties
→ const Set<
String> - The CSS properties this extension renders.
-
kCssFontSizeProperties
→ const Set<
String> - The CSS property CssFontSizeHtmlExtension makes renderable.
-
kCssImageFunctions
→ const Set<
String> -
The CSS image functions a
<bg-image>component can be. -
kCssInteractionProperties
→ const Set<
String> - The CSS properties CssInteractionHtmlExtension renders.
-
kCssLengthProperties
→ const Set<
String> - The CSS properties rewriteInlineStyleUnits rewrites a length inside.
-
kCssLineHeightProperties
→ const Set<
String> - The CSS property CssLineHeight corrects.
-
kCssNamedColorNames
→ const Set<
String> -
Every CSS
<named-color>, lower case. 148 names. -
kCssNamedColors
→ const Map<
String, Color> -
Every CSS
<named-color>, lower case, with its sRGB value. -
kCssObjectFitProperties
→ const Set<
String> - The CSS properties this package reads.
-
kCssOverflowProperties
→ const Set<
String> -
The CSS properties
CssOverflowHtmlExtensionrenders. -
kCssPercentEdgeProperties
→ const Set<
String> - The 22 padding and margin properties this package repairs, lower-cased.
-
kCssPercentSizeProperties
→ const Set<
String> - The two size properties this package repairs, lower-cased.
-
kCssSizeConstraintProperties
→ const Set<
String> - The four CSS properties this package renders, lower-cased.
-
kCssTextMetricsProperties
→ const Set<
String> - The CSS properties CssTextMetricsHtmlExtension makes renderable.
-
kCssTextOverflowProperties
→ const Set<
String> - The CSS properties CssTextOverflowHtmlExtension renders.
-
kCssTransformProperties
→ const Set<
String> -
The CSS properties
CssTransformHtmlExtensionrenders. -
kCssViewportUnits
→ const Map<
String, String> - The viewport units the rewrite resolves, and the axis each one reads.
-
kCssWideKeywords
→ const Set<
String> -
The CSS-wide keywords. A
backgroundwhose whole value is one of these is rewritten tobackground-color: <keyword>, verbatim. -
kFlutterHtmlBorderShorthands
→ const Set<
String> -
The five border properties
flutter_html3.0.0 parses by itself. - kFlutterHtmlLineHeightFactor → const double
-
The number
flutter_html3.0.0 multiplies every CSS line height by. -
kFlutterHtmlRenderableTags
→ const Set<
String> -
Every element name
flutter_html3.0.0 renders on its own. - kFlutterHtmlRootFontSize → const double
-
flutter_html's root font size in logical pixels. -
kNeverMatchingPseudoClasses
→ const Set<
String> -
The pseudo-classes the selector matcher evaluates to
falsefor every element. -
kSupportedPseudoClasses
→ const Set<
String> -
The pseudo-classes the selector matcher in
package:htmlevaluates. -
kSupportedPseudoClassFunctions
→ const Set<
String> - The functional pseudo-classes the selector matcher evaluates.
- kUnclippedAxisExtent → const double
- How far past the element's box CssOverflowClipper lets a free axis run, in logical pixels.
Functions
-
applyRulesToInlineStyle(
String? inlineStyle, Iterable< CssStyleRule> rules) → String -
Merges the winning declarations of
rulesintoinlineStyle. -
backgroundColorOfShorthand(
String value) → String? -
The
background-colorabackgroundshorthand states. -
bundledCssExtensions(
{List< HtmlExtension> before = const <HtmlExtension>[], List<HtmlExtension> after = const <HtmlExtension>[], List<Insert> inserts = const <Insert>[], CssStylesheetHtmlExtension? stylesheetExtension, List<HtmlExtension> utilityClassExtensions = const <HtmlExtension>[], HtmlExtension? utilityClassExtension, bool resolvePercentages = true, double? rootFontSize, Size? viewportSize, Map<String, MouseCursor> extraCursors = const <String, MouseCursor>{}, bool imgAlt = true, Map<String, String> ? imageNetworkHeaders, Set<String> ? imageNetworkDomains, Set<String> imageNetworkSchemas = const <String>{'http', 'https'}, Set<String> ? imageFileExtensions, AssetBundle? imageAssetBundle, String? imageAssetPackage, Set<String> ? imageMimeTypes, String? imageDataEncoding, bool handleNetworkImages = true, bool handleAssetImages = true, bool handleDataImages = true}) → BundledCssExtensions - The function form of BundledCssExtensions, for the argument-heavy call.
-
cascadeTextTransform(
StyledElement element, TextTransform value) → void -
Writes
valueintoelementand every descendant that states no transform of its own. -
convertCssLengthToPx(
double value, String unit, {Size? viewport}) → double? - Converts one CSS length to pixels.
-
cssDisplayRepairOf(
String css) → Display? -
The
Displayto write for thedisplayincss, or null. -
cssFlexDisplayOf(
String css) → CssFlexDisplay? -
The
displayvalue ofcss, if it names a formatting context this extension lays out. -
formatCssColorAsRgba(
Color color) → String -
Writes
coloras the legacyrgba(r, g, b, a)form. -
formatCssPx(
double value) → String - Formats a pixel length the way this package writes it back.
-
isCssBackgroundComponent(
String token) → bool -
Whether
tokenis a valid non-colour component of abackgroundshorthand: a keyword in kCssBackgroundKeywords, a function in kCssImageFunctions, a length, a percentage, a number, a size pair joined by a slash such as50%/auto, or the/that separates the position from the size. -
isCssColorToken(
String token) → bool -
Whether
tokenis one CSS colour. -
isFlutterHtmlRenderableTag(
String tagName) → bool -
Whether
flutter_html3.0.0 renderstagNamewithout an extension. -
joinDeclarationList(
Iterable< StylesheetDeclaration> declarations) → String -
Joins declarations back into an inline
style=""value. -
matchingRules(
Iterable< CssStyleRule> rules, StyledElement element) → List<CssStyleRule> -
The rules of
rulesthatelementmatches, in source order. -
parseCssColorValue(
String value, {Color? currentColor}) → Color? - Parses one CSS colour value into a Color.
-
parseCssFlexContainer(
String css, {double emValue = 14, double remValue = 14}) → CssFlexContainer? - Reads the container properties out of an inline style.
-
parseCssFlexItem(
String css, {double emValue = 14, double remValue = 14}) → CssFlexItem - Reads the item properties out of an inline style.
-
parseCssFontFamilyList(
String? rawValue) → List< String> -
Splits a
font-familyvalue into its font family names, in order. -
parseCssGridTemplateColumns(
String value, double emValue, double remValue) → List< CssGridTrack> -
Parses a
grid-template-columnsvalue into tracks. -
parseCssObjectPosition(
String value) → Alignment? -
Reads one
object-positionvalue into a Flutter Alignment. -
parseCssRules(
String source, {int firstOrder = 0, OnUnsupportedCssRule? onUnsupportedRule}) → List< CssStyleRule> - Reads a stylesheet and returns one CssStyleRule per selector.
-
parseCssSpacing(
String? rawValue) → CssSpacing? -
Parses a
letter-spacingorword-spacingvalue. -
parseCssTextDecorationThickness(
String? rawValue, {double? emBase, double? remBase}) → double? -
Parses a
text-decoration-thicknessvalue into Flutter's multiplier. -
parseCssTextTransform(
String? rawValue) → TextTransform? -
Parses a
text-transformvalue intoflutter_html'sTextTransform. -
parseCssTransform(
String styleAttr, {double? emPx, double? remPx}) → CssTransform -
Reads both properties this package renders out of an inline
style="". -
parseDeclarationList(
String style) → List< StylesheetDeclaration> -
Splits an inline
style=""value into declarations. -
parseInlineCssDeclarations(
String? styleAttribute) → Map< String, String> -
Splits an inline
style=""attribute into declarations. -
parseInlineStyle(
String style) → List< CssDeclaration> -
Splits an inline
style=""attribute into declarations, in source order. -
readAltAttribute(
Node node) → String? -
Reads the
altattribute ofnode, or null if there is nothing to render. -
resolveCssBorder(
List< CssDeclaration> declarations, {String currentColor = '#000000'}) → CssBorder - Resolves the CSS border cascade of one inline style.
-
resolvedFontSizeOf(
StyledElement element, {double rootFontSize = kFlutterHtmlRootFontSize}) → double -
The font size
elementshould render at, in logical pixels. -
rewriteCssValueUnits(
String value, {Size? viewport}) → String - Rewrites every absolute and viewport dimension token in one declaration value to pixels.
-
rewriteInlineBorder(
String style) → String -
Rewrites one inline
style=""so that the border it describes survivesflutter_html's parser. -
rewriteInlineStyleBackground(
String inlineStyle) → String? -
Rewrites every
backgroundshorthand ininlineStyleinto thebackground-colorlonghandflutter_htmlreads. -
rewriteInlineStyleColors(
String inlineStyle, {Color? currentColor}) → String? -
Rewrites every colour this package understands in
inlineStyleinto the legacyrgba()form. -
rewriteInlineStyleUnits(
String inlineStyle, {Size? viewport}) → String? -
Rewrites every absolute and viewport length in
inlineStyleto pixels. -
ruleMatchesElement(
CssStyleRule rule, StyledElement element) → bool -
Whether
elementmatchesrule's selector. -
specificityOfSelector(
String selector) → CssSpecificity - The specificity of one selector, given as source text.
-
splitCssDeclarations(
String inlineStyle) → List< String> -
Splits an inline style into its declarations at every
;that is outside a quoted string and outside brackets. -
splitCssLayers(
String value) → List< String> -
Splits a
backgroundvalue into its layers, at every top-level comma. -
splitInlineCssDeclarations(
String inlineStyle) → List< String> -
Splits an inline
style=""attribute into its declarations. -
statedTextTransform(
StyledElement element) → TextTransform? -
The transform
elementstates for itself, ornullwhen it states none. -
stripImportant(
String? rawValue) → String? -
Removes a trailing
!importantfrom a declaration value. -
tokenizeCssValue(
String layer) → List< String> -
Splits one layer of a
backgroundvalue into its tokens, at every run of top-level whitespace.
Typedefs
- CssFlexChild = ({CssFlexItem item, Widget widget})
- One flex or grid item: the widget to lay out, and the properties read off the element it came from.
- OnUnsupportedCssRule = void Function(UnsupportedCssRule rule)
- Called once per rule that renders nothing. See UnsupportedCssRule.
Exceptions / Errors
- UnrenderableTagsException
-
Names the tags in one parsed document that
flutter_html3.0.0 renders as nothing, although a utility-class extension resolved their classes.