Unable to render katex equation in flutter app using flutter_tex

43 Views Asked by At

Im trying to include formulas on a separate tab in a flutter app. After quite a few tries, the equation is not rendering and I am provided with the written code rather than the formula.

Am I writing the latex code wrong?

import 'package:flutter/material.dart';
import 'package:flutter_tex/flutter_tex.dart';

class FormulasScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Formulas'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(
              'Water Equivalent of Snow (mm)',
              style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
            ),
            SizedBox(height: 16),
            TeXView(
              child: TeXViewDocument(
                r'''
                H_{2DW}(\text{mm}) = \frac{\text{mass of new snow (g)}}{\text{Cross-section area (cm}^2\text{)}} \times 10
                ''',
              ),
            ),

            // Other Formulas here
          ],
        ),
      ),
    );
  }
}

I have tried a simple equation, re-writing the latex code using an online code editor. Tried cleaning my build, rebuilding and ensuring all the dependencies are correct.ect

0

There are 0 best solutions below