Skip to content
pubscout

val_latex

0.1.4, released 2 weeks ago by useval.io

LaTeX math parser and layout engine in pure Dart with OpenType fonts.

WASM-ready
$ flutter pub add val_latex

What it does

Parses and lays out LaTeX mathematical formulas in pure Dart without native code or web views. Supports line breaking, right-to-left math, speech output, and OpenType math fonts.

AI-written summary of version 0.1.4, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to render LaTeX math formulas in pure Dart or across all Flutter platforms without WebViews.
  • You are building an LLM streaming chat interface that needs to render incomplete mathematical formulas safely.
  • You need formula layout measurements or speech output in non-Flutter or Flutter environments.

Skip it when

  • You need full, general-purpose HTML/CSS document rendering rather than math typesetting.

Strengths

  • Pure Dart implementation runs anywhere Dart runs (VM, Flutter, server, web).
  • Never throws on bad input, gracefully handling unfinished LLM streams or diagnostics.
  • Supports broad LaTeX coverage including amsmath, physics, and chemistry packages.

Weaknesses

  • Requires an additional companion package (`val_latex_flutter`) to get Flutter widgets like `Math` and `MathText`.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
1

Add val_latex to your pubspec.yaml via dart pub add val_latex.

import 'package:val_latex/val_latex.dart';

final result = parseLatex(r'x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}');
final layout = layoutFormula(result);

Alternatives

Packages that do the same job and could replace val_latex.

Works with

Packages commonly used together with val_latex: ones it builds on, ones built on it, and its own family.