latext
Efficiently display scientific LaTeX equations on Android, iOS, Web, and Desktop platforms using the flutter_math library, without relying on WebView or JavaScript.
A flutter package to efficiently display scientific LaTeX equations using the flutter_math library, without relying on WebView or JavaScript.
{"sdk":"flutter"}^0.7.4{"sdk":"flutter"}^5.0.0English project snapshot. Visit GitHub for the latest content.
Render scientific LaTeX equations using the LaTexT library.
LaTeX rendering is done using flutter_math_fork and using RichText.
latext is working on Android, iOS, the Web and the Desktop platform.
flutter_math_fork is simply taking any input for Math rendering. We split up into Text and Math parts. You can use a separator (eg. the common "$" or "$$"). Content between these separators is rendered as math while anything outside of these separators is rendered as normal Flutter Text. This makes Text containing only some single formula parts much easier.
Add this to your package's pubspec.yaml file:
dependencies:
latext: ^0.4.1
You can install packages from the command line with Flutter:
flutter pub get
Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:latext/latext.dart';
...
// A static LaTeX block which may not change on `setState()`
return LaTexT(laTeXCode: Text("\\alpha", style: Theme.of(context)
.textTheme
.bodyText1
.copyWith(color: Colors.red)))
// A dynamic LaTeX block which is rebuilt on `setState()` (less efficient but required sometimes)
return Builder(builder: (context) => LaTexT(laTeXCode: Text("\\alpha", style: Theme.of(context)
.textTheme
.bodyText1
.copyWith(color: Colors.red))))
This package was adapted from KaTexFlutter.