katex library

A Flutter widget that renders LaTeX math by painting the box tree produced by the pure-Dart katex package.

See PLAN.md and tickets/BOARD.md at the repo root for status.

Classes

AnimatedMath
A widget that renders a LaTeX math tex string with a reveal animation.
KatexBoxPainter
Paints a BoxNode tree onto a Canvas.
Math
A widget that renders a LaTeX math tex string.

Enums

MathAnimationMode
How an animated render reveals the formula as its progress runs 0 → 1.

Constants

katexFlutterPackage → const String
The name of this package, used so Flutter resolves the bundled fonts declared under flutter: fonts: in this package's pubspec.yaml.
kDefaultMathFontSize → const double
The default base font size, in logical pixels per em, used when the caller does not pass Math.fontSize.
kInkOverflowPadEm → const double
Ink-overflow pad (em) added on every side of a rendered box, matching the SVG serializer's content pad. Glyph/SVG ink can extend past the metric box (bold-glyph overshoot, brace SVG, deep \cfrac denominators); without this margin a parent (or an offscreen raster) clips it.

Functions

boxSizePx(BoxNode root, double fontSize) Size
The intrinsic pixel size of root painted at fontSize pixels per em.
boxSizePxPadded(BoxNode root, double fontSize, {double padEm = kInkOverflowPadEm}) Size
boxSizePx grown by kInkOverflowPadEm on every side. Use this as the canvas/widget size whenever painting with KatexBoxPainter(inkPadEm: …).
countRevealableLeaves(BoxNode node) int
Counts the individually-revealable leaf elements in node — the same units the per-element reveal animation steps through (each GlyphNode, RuleNode, SvgPathNode, ImageNode, and one per EncloseNode for its decorations).
mathSpan(String tex, {bool displayMode = false, double fontSize = 16, Color? color, InlineSpan onError(Object error)?}) InlineSpan
An inline math InlineSpan for use inside Text.rich / RichText.
parseSvgPath(String d) Path
Parses an SVG path d string into a Path.
textStyleFor(KatexFont font, double fontSizePx, {Color? color}) TextStyle
Builds a TextStyle for font at fontSizePx logical pixels.