MathJax icon indicating copy to clipboard operation
MathJax copied to clipboard

Is there plugin to render the mathjax content in flutter app ?

Open gkumar9 opened this issue 6 years ago • 6 comments

Hi, so I am creating a flutter where I am trying to render the mathjax i.e <p><math xmlns="http://www.w3.org/1998/Math/MathML"><msqrt><mn>2</mn></msqrt></math>&nbsp;This is the content for a question</p>

So, is there a plugin to render it in there.

Thanks, Gaurav

gkumar9 avatar Feb 27 '20 13:02 gkumar9

It looks like

https://pub.dev/packages/mathjax_view

might do what you are looking for, or perhaps

https://pub.dev/packages/flutter_tex

dpvc avatar Feb 27 '20 13:02 dpvc

Note: this issue tracker is for reporting bugs in MathJax, not general questions. Those should be asked in the MathJax User Forum where more people will see them.

dpvc avatar Feb 27 '20 13:02 dpvc

Thanks for the reference

gkumar9 avatar Feb 27 '20 15:02 gkumar9

Hi, so I am creating a flutter where I am trying to render the mathjax i.e <p><math xmlns="http://www.w3.org/1998/Math/MathML"><msqrt><mn>2</mn></msqrt></math>&nbsp;This is the content for a question</p>

So, is there a plugin to render it in there.

Thanks, Gaurav any update on this. even i am looking for it. please let me know if u have any update on this

satishkodavalla avatar Mar 31 '20 10:03 satishkodavalla

@satishkodavalla well the above-mentioned package does render but what I am facing the issue is of rendering multiple cards in tab bar panel to render the mathjax content but it crashes my app.

gkumar9 avatar Mar 31 '20 11:03 gkumar9

Here's an effective approach using the flutter_tex package:

  1. Add flutter_tex to your dependencies, in your pubspec.yaml file, add the following line under the dependencies section:

YAML
flutter_tex: ^0.0.20
Use code [with caution.](https://github.com/faq#coding)
content_copy
Run pub get to install the package.

  1. Render the equation using flutter_tex:

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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('MathJax Rendering'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              TeXView(
                child: TexParser.fromRtf(
                  r"$\sqrt{2}$ This is the content for a question",
                ),
                renderingMode: RenderingMode.tex,
                // You can customize styling here (optional)
                textStyle: TextStyle(fontSize: 24),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

The flutter_tex package uses a mini-MathJax library to render equations. TeXView displays the equation parsed by TexParser.fromRtf. The renderingMode is set to RenderingMode.tex for MathJax rendering. You can optionally customize the text style using textStyle.

d3vobed avatar Jun 12 '24 09:06 d3vobed