flutterflutter-tex

How to add custom values in inside expression in flutter math_fork library


class ResultPage extends StatefulWidget {
    DataModel dataModel;
    ResultPage({Key? key, required this.dataModel}) : super(key: key);

    @override
    _ResultPageState createState() => _ResultPageState();
}

class _ResultPageState extends State<ResultPage> {
    @override
    Widget build(BuildContext context) {
        return Scaffold(
            body: Math.tex("m=/frac "${widget.datamodel.value}"")
        );
    }
}

but the math.tex is showing error in flutter how to pass custom values in any equation


Solution

  • class ResultPage extends StatefulWidget {
      DataModel dataModel;
       ResultPage({Key? key, required this.dataModel}) : super(key: key);
    
      @override
       _ResultPageState createState() => _ResultPageState();
        }
    
        class _ResultPageState extends State<ResultPage> {
               @override
        Widget build(BuildContext context) {
         return Scaffold( 
      body:Math.tex(
                "m = ${r'\frac'} {${widget.datamodel.value1}} 
                   {$widget.datamodel.value2}",
                textStyle: textStyle,
              ),
    
        );}}
    

    that is how you can add custom values in the equation in flutter math_fork