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.fontSize
will be the size of any math symbols.logicalPpi
will be used to decide the size of absolute units (pt, cm, inch, etc).- If
logicalPpi
is null, then absolute units will resize on differentTextStyle.fontSize
to keep a consistent ratio (Just like currentbaseSizeMultiplier
's behavior). baseSizeMultiplier
is deprecated. If you still wish similar behavior, calculate relevant parameters fromMathOptions.defaultFontSize
anddouble defaultLogicalPpi(double fontSize)
.- If neither
TextStyle.fontSize
norlogicalPpi
is supplied, then the widget will use the defaultTextStyle
supplied 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());
)
},
)