TeXWidget is a convenient, high-level wrapper around Math2SVG designed specifically for easy LaTeX rendering. It automatically handles text and math mixtures, making it ideal for displaying paragraphs containing equations.
Usage
Simple Example
Render a sentence with mixed text and math effortlessly.
TeXWidget(math:_formula,// Customize the main display equations (centered, large)displayFormulaWidgetBuilder:(context,displayFormula){returnCenter(child:Math2SVG(math:displayFormula,formulaWidgetBuilder:(context,svg)=>SvgPicture.string(svg,colorFilter:constColorFilter.mode(Colors.red,BlendMode.srcIn),height:50,),),);},// Customize inline math (embedded in text)inlineFormulaWidgetBuilder:(context,inlineFormula){returnMath2SVG(math:inlineFormula,formulaWidgetBuilder:(context,svg)=>SvgPicture.string(svg,colorFilter:constColorFilter.mode(Colors.purple,BlendMode.srcIn),height:16,),);},// Customize standard texttextWidgetBuilder:(context,text){returnTextSpan(text:text,style:TextStyle(color:Colors.black));},)
API Reference
math: The string input containing LaTeX.
style: General style for the widget.
loadingWidgetBuilder: Widget to show while parsing.