flutter_tex 0.0.18

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new73

Flutter TeX #

A Flutter Package to render Mathematics, Physics and Chemistry Equations based on LaTeX with full HTML support using webview_flutter plugin.

This is based on mini-mathjax a simplified version of MathJax a JavaScript library.

Only Tested on Android not on iOS because I don't own a Mac.

Use this package as a library #

1: Add this to your package's pubspec.yaml file:

dependencies:
  flutter_tex: ^0.0.18

2: You can install packages from the command line:

$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3: Now in your Dart code, you can use:

import 'package:flutter_tex/flutter_tex.dart';

4: Make sure to add this line in your AndroidManifest.xml under application like this.

<application
       
       android:usesCleartextTraffic="true">
       
</application>

Example #

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

main() async {
runApp(FlutterTeX());
}

class FlutterTeX extends StatefulWidget {
@override
_FlutterTeXState createState() => _FlutterTeXState();
}

class _FlutterTeXState extends State<FlutterTeX> {
  String teX = Uri.encodeComponent(r"""
  <p>
    A simple Example to render \( \rm\\TeX \) in flutter<br>

    <style>
      .card {
        box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
        transition: 0.3s;
        width: 40%;
      }

      .card:hover {
        box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2);
      }

      .container {
        padding: 2px 16px;
      }
    </style>
    <div class="card">
      <div class="container">
        <p>
          \begin{align}
          \dot{x} & = \sigma(y-x) \\
          \dot{y} & = \rho x - y - xz \\
          \dot{z} & = -\beta z + xy
          \end{align}
        </p>
      </div>
    </div>

    <br>
    <br>

    When \(a \ne 0 \), there are two solutions to \(ax^2 + bx + c = 0\) and they are

    $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$<br>

    $$ \oint_C {E \cdot d\ell = - \frac{d}{{dt}}} \int_S {B_n dA} $$<br>

    Bohr Radius

    \( a_0 = \frac{{\hbar ^2 }}{{m_e ke^2 }} \)<br>

    Relationship between Energy and Principal Quantum Number

    \( E_n = - R_H \left( {\frac{1}{{n^2 }}} \right) = \frac{{ - 2.178 \times 10^{ - 18} }}{{n^2 }}joule \)<br><br>

    $$\ce{CO2 + C -> 2 CO}$$ <br><br>

    $$\ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-}$$ <br><br>

    $$\ce{x Na(NH4)HPO4 ->[\Delta] (NaPO3)_x + x NH3 ^ + x H2O}$$ <br><br>

  </p>
  """);

 @override
 Widget build(BuildContext context) {
   return MaterialApp(
     home: Scaffold(
       appBar: AppBar(
         title: Text("Flutter TeX Example"),
       ),
       body: TeXView(
         teXHTML: teX,
       ),
     ),
   );
 }
}

Screenshots #

FlutterTeXMathsFlutterTeXMaths

[0.0.2] - TODO: Add release date.

  • TODO: Describe initial release.

example/example.dart

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

main() async {
  runApp(FlutterTeX());
}

class FlutterTeX extends StatefulWidget {
  @override
  _FlutterTeXState createState() => _FlutterTeXState();
}

class _FlutterTeXState extends State<FlutterTeX> {
  String teX = Uri.encodeComponent(r"""
 
   <p>
 
     A simple Example to render \( \rm\\TeX \) in flutter<br>
 
     <style>
       .card {
         box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
         transition: 0.3s;
         width: 40%;
       }
 
       .card:hover {
         box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2);
       }
 
       .container {
         padding: 2px 16px;
       }
     </style>
     <div class="card">
       <div class="container">
         <p>
           \begin{align}
           \dot{x} & = \sigma(y-x) \\
           \dot{y} & = \rho x - y - xz \\
           \dot{z} & = -\beta z + xy
           \end{align}
         </p>
       </div>
     </div>

     <br>
     <br>
 
     When \(a \ne 0 \), there are two solutions to \(ax^2 + bx + c = 0\) and they are
 
     $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$<br>
 
     $$ \oint_C {E \cdot d\ell = - \frac{d}{{dt}}} \int_S {B_n dA} $$<br>
 
     Bohr Radius
 
     \( a_0 = \frac{{\hbar ^2 }}{{m_e ke^2 }} \)<br>
 
     Relationship between Energy and Principal Quantum Number
 
     \( E_n = - R_H \left( {\frac{1}{{n^2 }}} \right) = \frac{{ - 2.178 \times 10^{ - 18} }}{{n^2 }}joule \)<br><br>
 
     $$\ce{CO2 + C -> 2 CO}$$ <br><br>
  
     $$\ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-}$$ <br><br>
 
     $$\ce{x Na(NH4)HPO4 ->[\Delta] (NaPO3)_x + x NH3 ^ + x H2O}$$ <br><br>

   </p>
   """);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text("Flutter TeX Example"),
        ),
        body: TeXView(
          teXHTML: teX,
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_tex: ^0.0.18

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_tex/flutter_tex.dart';
  
Version Uploaded Documentation Archive
0.0.18 Mar 20, 2019 Go to the documentation of flutter_tex 0.0.18 Download flutter_tex 0.0.18 archive
0.0.17 Mar 17, 2019 Go to the documentation of flutter_tex 0.0.17 Download flutter_tex 0.0.17 archive
0.0.16 Mar 15, 2019 Go to the documentation of flutter_tex 0.0.16 Download flutter_tex 0.0.16 archive
0.0.15 Mar 15, 2019 Go to the documentation of flutter_tex 0.0.15 Download flutter_tex 0.0.15 archive
0.0.14 Mar 15, 2019 Go to the documentation of flutter_tex 0.0.14 Download flutter_tex 0.0.14 archive
0.0.13 Mar 15, 2019 Go to the documentation of flutter_tex 0.0.13 Download flutter_tex 0.0.13 archive
0.0.12 Mar 15, 2019 Go to the documentation of flutter_tex 0.0.12 Download flutter_tex 0.0.12 archive
0.0.11 Mar 15, 2019 Go to the documentation of flutter_tex 0.0.11 Download flutter_tex 0.0.11 archive
0.0.10 Mar 15, 2019 Go to the documentation of flutter_tex 0.0.10 Download flutter_tex 0.0.10 archive
0.0.9 Mar 14, 2019 Go to the documentation of flutter_tex 0.0.9 Download flutter_tex 0.0.9 archive

All 18 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
51
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
87
Overall:
Weighted score of the above. [more]
73
Learn more about scoring.

We analyzed this package on Mar 20, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.2.0
  • pana: 0.12.14
  • Flutter: 1.3.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/flutter_tex.dart.

Run flutter format to format lib/flutter_tex.dart.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

The package description is too short. (-3 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
mime ^0.9.6+2 0.9.6+2
webview_flutter ^0.3.3+1 0.3.5
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test