{"id":15435992,"url":"https://github.com/znjameswu/flutter_math","last_synced_at":"2025-08-20T10:31:16.861Z","repository":{"id":42772174,"uuid":"269868510","full_name":"znjameswu/flutter_math","owner":"znjameswu","description":"Math rendering and editing in pure Flutter.","archived":false,"fork":false,"pushed_at":"2022-01-14T03:04:43.000Z","size":1818,"stargazers_count":126,"open_issues_count":22,"forks_count":51,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-26T01:34:09.316Z","etag":null,"topics":["dart","equation","equations","flutter","katex","math-rendering","tex"],"latest_commit_sha":null,"homepage":"https://znjameswu.github.io/flutter_math_demo/","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/znjameswu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-06T04:35:35.000Z","updated_at":"2024-11-20T07:00:47.000Z","dependencies_parsed_at":"2022-09-02T05:50:14.688Z","dependency_job_id":null,"html_url":"https://github.com/znjameswu/flutter_math","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/znjameswu%2Fflutter_math","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/znjameswu%2Fflutter_math/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/znjameswu%2Fflutter_math/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/znjameswu%2Fflutter_math/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/znjameswu","download_url":"https://codeload.github.com/znjameswu/flutter_math/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230415317,"owners_count":18222158,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dart","equation","equations","flutter","katex","math-rendering","tex"],"created_at":"2024-10-01T18:47:22.043Z","updated_at":"2024-12-19T10:08:47.015Z","avatar_url":"https://github.com/znjameswu.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flutter Math\n\n[![Build Status](https://travis-ci.com/znjameswu/flutter_math.svg?branch=master)](https://travis-ci.com/znjameswu/flutter_math) [![codecov](https://codecov.io/gh/znjameswu/flutter_math/branch/master/graph/badge.svg)](https://codecov.io/gh/znjameswu/flutter_math) [![Pub Version](https://img.shields.io/pub/v/flutter_math)](https://pub.dev/packages/flutter_math)\n\nMath equation rendering in pure Dart \u0026 Flutter. \n\n\nThis project aims to achieve maximum compatibility and fidelity with regard to the [KaTeX](https://github.com/KaTeX/KaTeX) project, while maintaining the performance advantage of Dart and Flutter. A further [UnicodeMath](https://www.unicode.org/notes/tn28/UTN28-PlainTextMath-v3.1.pdf)-style equation editing support will be experimented in the future.\n\n\nThe TeX parser is a Dart port of the KaTeX parser. There are only a few unsupported features and parsing differences compared to the original KaTeX parser. List of some unsupported features can be found [here](doc/unsupported.md).\n\n## [Online Demo](https://znjameswu.github.io/flutter_math_demo/)\n\n## Rendering Samples\n\n`x = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}`\n\n![Example1](https://raw.githubusercontent.com/znjameswu/flutter_math/master/doc/img/delta.png)\n\n`i\\hbar\\frac{\\partial}{\\partial t}\\Psi(\\vec x,t) = -\\frac{\\hbar}{2m}\\nabla^2\\Psi(\\vec x,t)+ V(\\vec x)\\Psi(\\vec x,t)`\n\n![Example2](https://raw.githubusercontent.com/znjameswu/flutter_math/master/doc/img/schrodinger.png)\n\n`\\hat f(\\xi) = \\int_{-\\infty}^\\infty f(x)e^{- 2\\pi i \\xi x}\\mathrm{d}x`\n\n![Example3](https://raw.githubusercontent.com/znjameswu/flutter_math/master/doc/img/fourier.png)\n\n\n## How to use\n\nAdd `flutter_math` to your `pubspec.yaml` dependencies\n\n### Mobile\nCurrently only Android platform has been tested. If you encounter any issues with iOS, please file them.\n\n### Web\nWeb support is added in v0.1.6. It is tested for DomCanvas backend. In general it should behave largely the same with mobile. It is expected to break with CanvasKit backend. Check out the [Online Demo](https://znjameswu.github.io/flutter_math_demo/)\n\n## API usage (v0.2.0)\nThe usage is straightforward. Just `Math.tex(r'\\frac a b')`. There is also optional arguments of `TexParserSettings settings`, which corresponds to  Settings in KaTeX and support a subset of its features.\n\nDisplay-style equations:\n```dart\nMath.tex(r'\\frac a b', mathStyle: MathStyle.display) // Default\n```\n\nIn-line equations\n```dart\nMath.tex(r'\\frac a b', mathStyle: MathStyle.text)\n```\n\nThe default size of the equation is obtained from the build context. If you wish to specify the size, you can use `textStyle`. Note: this parameter will also change how big 1cm/1pt/1inch is rendered on the screen. If you wish to specify the size of those absolute units, use `logicalPpi`\n\n```dart\nMath.tex(\n  r'\\frac a b',\n  textStyle: TextStyle(fontSize: 42),\n  // logicalPpi: MathOptions.defaultLogicalPpiFor(42),\n)\n```\n\nThere is also a selectable variant `SelectableMath` that creates selectable and copy-able equations on both mobile and web. (EXPERIMENTAL) Users can select part of the equation and obtain the encoded TeX strings. The usage is similar to Flutter's `SelectableText`.\n\n```dart\nSelectableMath.tex(r'\\frac a b', textStyle: TextStyle(fontSize: 42))\n```\n\nIf you would like to display custom styled error message, you should use `onErrorFallback` parameter. You can also process the errors in this function. But beware this function is called in build function.\n```dart\nMath.tex(\n  r'\\garbled $tring', \n  textStyle: TextStyle(color: Colors.green),\n  onErrorFallback: (err) =\u003e Container(\n    color: Colors.red,\n    child: Text(err.messageWithType, style: TextStyle(color: Colors.yellow)),\n  ),\n)\n```\n\nIf you wish to have more granularity dealing with equations, you can manually invoke the parser and supply AST into the widget.\n```dart\nSyntaxTree ast;\ntry {\n  ast = SyntaxTree(greenRoot: TexParser(r'\\frac a b', TexParserSettings()).parse());\n} on ParseException catch (e) {\n  // Handle my error here\n}\n\nSelectableMath(\n  ast: ast,\n  mathStyle: MathStyle.text,\n  textStyle: TextStyle(fontSize: 42),\n)\n```\n\n## [Line Breaking](doc/line_breaking.md)\n\n## Credits\nThis project is possible thanks to the inspirations and resources from [the KaTeX Project](https://katex.org/), [MathJax](www.mathjax.org), [Zefyr](https://github.com/memspace/zefyr), and [CaTeX](https://github.com/simpleclub/CaTeX).\n\n## Goals\n- [x] : TeX math parsing (See [design doc](doc/design.md))\n- [x] : AST rendering in flutter\n- [x] : Selectable widget\n- [x] : TeX output (WIP)\n- [ ] : UnicodeMath parsing and encoding\n- [ ] : [UnicodeMath](https://www.unicode.org/notes/tn28/UTN28-PlainTextMath-v3.1.pdf)-style editing\n- [ ] : Breakable equations\n- [ ] : MathML parsing and encoding\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fznjameswu%2Fflutter_math","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fznjameswu%2Fflutter_math","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fznjameswu%2Fflutter_math/lists"}