SelectableMath.tex constructor

SelectableMath.tex(
  1. String expression, {
  2. Key? key,
  3. TexParserSettings settings = const TexParserSettings(),
  4. MathOptions? options,
  5. OnErrorFallback onErrorFallback = defaultOnErrorFallback,
  6. bool autofocus = false,
  7. Color? cursorColor,
  8. Radius? cursorRadius,
  9. double cursorWidth = 2.0,
  10. double? cursorHeight,
  11. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  12. bool enableInteractiveSelection = true,
  13. FocusNode? focusNode,
  14. MathStyle mathStyle = MathStyle.display,
  15. double? logicalPpi,
  16. bool showCursor = false,
  17. double? textScaleFactor,
  18. TextSelectionControls? textSelectionControls,
  19. TextStyle? textStyle,
  20. ToolbarOptions? toolbarOptions,
})

SelectableMath builder using a TeX string

expression will first be parsed under settings. Then the acquired SyntaxTree will be built under a specific options. If ParseException is thrown or a build error occurs, onErrorFallback will be displayed.

You can control the options via mathStyle and textStyle.

See alse:

Implementation

factory SelectableMath.tex(
  String expression, {
  Key? key,
  TexParserSettings settings = const TexParserSettings(),
  MathOptions? options,
  OnErrorFallback onErrorFallback = defaultOnErrorFallback,
  bool autofocus = false,
  Color? cursorColor,
  Radius? cursorRadius,
  double cursorWidth = 2.0,
  double? cursorHeight,
  DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  bool enableInteractiveSelection = true,
  FocusNode? focusNode,
  MathStyle mathStyle = MathStyle.display,
  double? logicalPpi,
  bool showCursor = false,
  double? textScaleFactor,
  TextSelectionControls? textSelectionControls,
  TextStyle? textStyle,
  ToolbarOptions? toolbarOptions,
}) {
  SyntaxTree? ast;
  ParseException? parseError;
  try {
    ast = SyntaxTree(greenRoot: TexParser(expression, settings).parse());
  } on ParseException catch (e) {
    parseError = e;
  } on Object catch (e) {
    parseError = ParseException('Unsanitized parse exception detected: $e.'
        'Please report this error with correponding input.');
  }
  return SelectableMath(
    key: key,
    ast: ast,
    autofocus: autofocus,
    cursorColor: cursorColor,
    cursorRadius: cursorRadius,
    cursorWidth: cursorWidth,
    cursorHeight: cursorHeight,
    dragStartBehavior: dragStartBehavior,
    enableInteractiveSelection: enableInteractiveSelection,
    focusNode: focusNode,
    mathStyle: mathStyle,
    logicalPpi: logicalPpi,
    onErrorFallback: onErrorFallback,
    options: options,
    parseException: parseError,
    showCursor: showCursor,
    textScaleFactor: textScaleFactor,
    textSelectionControls: textSelectionControls,
    textStyle: textStyle,
    toolbarOptions: toolbarOptions,
  );
}