| Old name | New name |
|---|---|
| Options | MathOptions |
| Settings | TexParserSettings |
| SizeMode | MathSize |
| ParseError | ParseException |
The FlutterMath class has been deprecated and becomes a wrapper of Math widget. You should use more specific widget variants: Math and SelectableMath.
Math is static, non-selectable. SelectableMath is static but selectable. If you wish to avoid extra performance cost brings by selectibility, use Math.
The constructor name has also been changed to Math.tex and SelectableMath.tex.
TextStyle will be adopted as the parameter in exposed APIs to replace Options. Directly supplying Options is OK, but is apparently not the best way.
TextStyle.fontSizewill be the size of any math symbols.logicalPpiwill be used to decide the size of absolute units (pt, cm, inch, etc).- If
logicalPpiis null, then absolute units will resize on differentTextStyle.fontSizeto keep a consistent ratio (Just like currentbaseSizeMultiplier's behavior). baseSizeMultiplieris deprecated. If you still wish similar behavior, calculate relevant parameters fromMathOptions.defaultFontSizeanddouble defaultLogicalPpi(double fontSize).- If neither
TextStyle.fontSizenorlogicalPpiis supplied, then the widget will use the defaultTextStylesupplied by Flutter's build context.
ParseError will be renamed to ParseException. Also, other throws within the library will be sanitized to throw either ParseException, BuildException, EncodeExecption. All of them extends FlutterMathException. As a result, onErrorFallback will have a different signature and allows users to handle exceptions with type safety.
Detailed exception variant can be found in their respective API documentations.
The final API will look like
Math.tex(
r'\frac a b',
textStyle: TextStyle(fontSize: 42),
// settings: TexParserSettings(),
// logicalPpi: defaultLogicalPpi(42),
onErrorFallback: (err) => {
if (error is ParseException)
return SelectableText('ParseError: ${err.message}');
return Container(
color: Colors.red,
SelectableText(err.toString());
)
},
)