katex_flutter 4.0.0+24 copy "katex_flutter: ^4.0.0+24" to clipboard
katex_flutter: ^4.0.0+24 copied to clipboard

outdated

Performantly render scientific LaTeX equations using the KaTeX library on Android, iOS, the Web and the Desktop platform.

example/lib/main.dart

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:katex_flutter/katex_flutter.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter KaTeX Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key}) : super(key: key);

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

class _MyHomePageState extends State<MyHomePage> {
  TextEditingController _laTeXInputController = TextEditingController(
      text: r'What do you think about $L' +
          '\'' +
          r' = {L}{\sqrt{1-\frac{v^2}{c^2}}}$ ?');
  String _laTeX;

  @override
  void initState() {
    _renderLaTeX();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('KaTeX Flutter Home Page'),
        ),
        body: Padding(
          padding: const EdgeInsets.all(8.0),
          child: Center(
            child: Column(
              children: <Widget>[
                Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: TextField(
                    keyboardType: TextInputType.multiline,
                    maxLines: null,
                    decoration: InputDecoration(
                        labelText: 'Your LaTeX code here',
                        helperText:
                            'Use \$ as delimiter. Use \$\$ for display LaTeX.'),
                    controller: _laTeXInputController,
                  ),
                ),
                Container(
                    child: Builder(
                        builder: (context) => KaTeX(
                              laTeXCode: Text(_laTeX),
                              background: Colors.grey[50],
                              //onError: (e)=>print(e),
                            )))
              ],
            ),
          ),
        ),
        floatingActionButton: FloatingActionButton.extended(
          onPressed: _renderLaTeX,
          tooltip: 'Render again. Only working on mobile platform.',
          label: Text('Render LaTeX'),
          icon: Icon(Icons.crop_rotate),
        ));
  }

  void _renderLaTeX() {
    setState(() {
      _laTeX = _laTeXInputController.text;
    });
  }
}
54
likes
0
pub points
72%
popularity

Publisher

verified publishertestapp.schule

Performantly render scientific LaTeX equations using the KaTeX library on Android, iOS, the Web and the Desktop platform.

Repository (GitLab)
View/report issues

License

unknown (LICENSE)

Dependencies

catex, flutter, js, webview_flutter

More

Packages that depend on katex_flutter