Math2SVG is the core engine for high-performance, pure Flutter math rendering. It parses TeX, MathML, or AsciiMath and converts it into Scalable Vector Graphics (SVG), which are then rendered using the flutter_svg package.
Key Features
🚀 Pure Flutter: No WebView required. Lightweight and fast.
💎 High Quality: Resolution-independent rendering that looks sharp on any device.
🎨 Full Control: Custom painters, colors, and sizes.
Usage
Basic Rendering
Pass your math string and specify the input type (default is TeX).
import'package:flutter/foundation.dart';import'package:flutter/material.dart';import'package:flutter_tex/flutter_tex.dart';voidmain()async{// Initialize the rendering server (Required for mobile)if(!kIsWeb){awaitTeXRenderingServer.start();}runApp(constMaterialApp(home:Math2SVGExample()));}classMath2SVGExampleextendsStatelessWidget{constMath2SVGExample({super.key});@overrideWidgetbuild(BuildContextcontext){returnScaffold(appBar:AppBar(title:constText("Math2SVG Example")),body:Center(child:Math2SVG(math:r"\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}",formulaWidgetBuilder:(context,svg)=>SvgPicture.string(svg,width:200,),),),);}}