libv_markdown 1.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 71

Flutter Markdown #

A Flutter Package to render so many types of equations based on Markdown/LaTeX, most commonly used are as followings:

  • Mathematics / Maths Equations (Algebra, Calculus, Geometry, Geometry etc...)

  • Code Highlight

  • It also includes full HTML with JavaScript support.

Rendering of equations depends on mini-mathjax a simplified version of MathJax a JavaScript library.

This package mainly depends on webview_flutter plugin.

Use this package as a library in your flutter Application #

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

dependencies:
  libv_markdown: ^1.0.0

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: For Android Make sure to add this line android:usesCleartextTraffic="true" in your <project-directory>/android/app/src/main/AndroidManifest.xml under application like this.

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

and permissions

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />

For iOS add following code in your <project-directory>/ios/Runner/Info.plist


<key>NSAppTransportSecurity</key>

  <dict>
    <key>NSAllowsArbitraryLoads</key> <true/>
  </dict>

<key>io.flutter.embedded_views_preview</key> <true/>

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

import 'package:flutter_markdown/flutter_markdown.dart';

5: Now you can use TeXHTML widget like this.

    markdownView(
          markdownViewHTML: r"""$$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$<br> """,

          onRenderFinished: (height) {
                print("Widget Height is : $height")
                },

          onPageFinished: (string) {
                print("Page Loading finished");
              },
        )

Complete working application Example

Known Issues: #

  • A bit slow rendering speed. It takes 1-2 seconds to render after application loaded.

Cautions: #

  • Please avoid using too many MarkdownViews in a single page, because this is based on webview_flutter a complete web browser. Which may cause to slow down your app.

Thanks to: #

Change Logs #

[1.0.1] #

Update the instruction

[1.0.0] #

Stable Release

example/lib/main.dart

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

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

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

class _FlutterTeXState extends State<FlutterTeX> {
  TextEditingController _teXHTMLEditingController =
      new TextEditingController(text: teXHTML);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        backgroundColor: Colors.white70,
        appBar: AppBar(
          title: Text("Flutter Markdown Example"),
        ),
        body: ListView(
          shrinkWrap: true,
          children: <Widget>[
            Container(
              margin: EdgeInsets.all(10),
              child: Material(
                shape: RoundedRectangleBorder(side: BorderSide()),
                elevation: 5,
                child: Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: TextField(
                    decoration: InputDecoration(labelText: "TeX HTML input"),
                    controller: _teXHTMLEditingController,
                    maxLines: 15,
                    onChanged: (string) {
                      setState(() {});
                    },
                  ),
                ),
              ),
            ),
            Divider(
              height: 20,
            ),
            Text(
              "Rendered Markdown HTML",
              textAlign: TextAlign.center,
              style: TextStyle(
                fontSize: 20,
                color: Colors.black,
                fontWeight: FontWeight.bold,
                decoration: TextDecoration.underline,
              ),
            ),
            Container(
              margin: EdgeInsets.all(10),
              child: Card(
                child: Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: MarkdownView(
                    markdownViewHTML: _teXHTMLEditingController.text,
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

String teXHTML = r"""
$$sin^2x+cos^2x=1$$
$sin^2x+cos^2x=1$
# Flutter Markdown

A Flutter Package to render so many types of equations based on **Markdown/LaTeX**, most commonly used are as followings:

- **Mathematics / Maths Equations** (Algebra, Calculus, Geometry, Geometry etc...)

- **Physics Equations**

- **Flutter**
   """;

Use this package as a library

1. Depend on it

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


dependencies:
  libv_markdown: ^1.0.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:libv_markdown/libv_markdown.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
41
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
71
Learn more about scoring.

We analyzed this package on Jul 11, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because:

  • package:libv_markdown/libv_markdown.dart that imports:
  • package:webview_flutter/webview_flutter.dart that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because:

  • package:libv_markdown/libv_markdown.dart that imports:
  • package:webview_flutter/webview_flutter.dart that declares support for platforms: android, ios

Package does not support Flutter platform web

Because:

  • package:libv_markdown/libv_markdown.dart that imports:
  • package:webview_flutter/webview_flutter.dart that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because:

  • package:libv_markdown/libv_markdown.dart that imports:
  • package:webview_flutter/webview_flutter.dart that declares support for platforms: android, ios

Package not compatible with SDK dart

Because:

  • libv_markdown that is a package requiring null.

Health suggestions

Format lib/libv_markdown.dart.

Run flutter format to format lib/libv_markdown.dart.

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+3 0.9.6+3
webview_flutter ^0.3.18+1 0.3.22+1
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test