ratexParseAndLayoutInIsolate function

DisplayList ratexParseAndLayoutInIsolate(
  1. Object args
)

Top-level isolate entry for compute; calls RaTeXEngine.parseAndLayout.

Accepts RaTeXParseAndLayoutIsolateArgs or the legacy record RaTeXParseAndLayoutArgs (colorValue is treated like non-null RaTeXParseAndLayoutIsolateArgs.colorArgb).

Implementation

DisplayList ratexParseAndLayoutInIsolate(Object args) {
  final RaTeXParseAndLayoutIsolateArgs resolved = switch (args) {
    final RaTeXParseAndLayoutIsolateArgs a => a,
    (:final String latex, :final bool displayMode, :final int colorValue) =>
      RaTeXParseAndLayoutIsolateArgs(
        latex: latex,
        displayMode: displayMode,
        colorArgb: colorValue,
      ),
    _ => throw ArgumentError.value(
        args,
        'args',
        'Expected RaTeXParseAndLayoutIsolateArgs or '
            '({String latex, bool displayMode, int colorValue}).',
      ),
  };
  final color = resolved.colorArgb == null
      ? const Color(0xFF000000)
      : Color(resolved.colorArgb!);
  return RaTeXEngine.instance.parseAndLayout(
    resolved.latex,
    displayMode: resolved.displayMode,
    color: color,
  );
}