패키지, 저장소 및 앱 카테고리 검색

flutter_math_fork 표지
패키지 상세v0.7.4

flutter_math_fork

순수한 Dart와 Flutter를 사용하여 빠르고 고품질의 TeX 수식 렌더링

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
33.1만
좋아요
172
Pub 점수
140

패키지 설치

flutter pub add flutter_math_fork

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

정밀도와 속도를 갖춘 고성능 Dart 및 Flutter 패키지로 TeX 수학 방정식을 렌더링합니다. flutter_math의 포크로 개발되어 순수 Dart로 구현된 상태에서 Flutter 앱에 수학적 표현을 원활하게 통합할 수 있으며, Android, iOS, Web, macOS, Windows, Linux 등 모든 주요 플랫폼과 호환됩니다. 교육용 앱, 과학 도구 및 정확한 식 표시가 필요한 모든 애플리케이션에 적합합니다.

사용 사례

  • 교육 앱
  • 과학 계산기
  • 수학적 콘텐츠 렌더링
  • 인터랙티브 학습 플랫폼
  • 문서 뷰어

주요 기능

  • 순수 Dart 구현
  • 고속 렌더링
  • 크로스 플랫폼 지원
  • TeX 문법 호환성
  • 사용자 지정 스타일

적합한 대상

  • 수학적으로 부담이 큰 앱을 개발하는 개발자
  • 교육 기술 프로젝트
  • 정확한 방정식 표시가 필요한 앱
  • 경량 수학 렌더링을 찾는 플러터 개발자

고려 사항

  • 기본 TeX 기능에 제한됨
  • 고급 LaTeX 패키지 지원 없음
  • 렌더링 품질은 폰트의 사용 가능 여부에 따라 달라집니다
  • 복잡한 방정식에 맞게 조정이 필요할 수 있습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Flutter Math

Build Status codecov Pub Version

⚠ fork

This is a fork of flutter_math addressing compatibility problems while flutter_math is not being maintained.


Math equation rendering in pure Dart & Flutter.

This project aims to achieve maximum compatibility and fidelity with regard to the KaTeX project, while maintaining the performance advantage of Dart and Flutter. A further UnicodeMath-style equation editing support will be experimented in the future.

The 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.

Online Demo

Rendering Samples

x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}

Example1

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)

Example2

\hat f(\xi) = \int_{-\infty}^\infty f(x)e^{- 2\pi i \xi x}\mathrm{d}x

Example3

How to use

Add flutter_math to your pubspec.yaml dependencies

Mobile

Currently only Android platform has been tested. If you encounter any issues with iOS, please file them.

Web

Web 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

API usage (v0.2.0)

The 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.

Display-style equations:

Math.tex(r'\frac a b', mathStyle: MathStyle.display) // Default

In-line equations

Math.tex(r'\frac a b', mathStyle: MathStyle.text)

The 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

Math.tex(
  r'\frac a b',
  textStyle: TextStyle(fontSize: 42),
  // logicalPpi: MathOptions.defaultLogicalPpiFor(42),
)

There 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.

SelectableMath.tex(r'\frac a b', textStyle: TextStyle(fontSize: 42))

If 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.

Math.tex(
  r'\garbled $tring', 
  textStyle: TextStyle(color: Colors.green),
  onErrorFallback: (err) => Container(
    color: Colors.red,
    child: Text(err.messageWithType, style: TextStyle(color: Colors.yellow)),
  ),
)

If you wish to have more granularity dealing with equations, you can manually invoke the parser and supply AST into the widget.

SyntaxTree ast;
try {
  ast = SyntaxTree(greenRoot: TexParser(r'\frac a b', TexParserSettings()).parse());
} on ParseException catch (e) {
  // Handle my error here
}

SelectableMath(
  ast: ast,
  mathStyle: MathStyle.text,
  textStyle: TextStyle(fontSize: 42),
)

Line Breaking

Credits

This project is possible thanks to the inspirations and resources from the KaTeX Project, MathJax, Zefyr, and CaTeX.

Goals

  • [x] : TeX math parsing (See design doc)
  • [x] : AST rendering in flutter
  • [x] : Selectable widget
  • [x] : TeX output (WIP)
  • [ ] : UnicodeMath parsing and encoding
  • [ ] : UnicodeMath-style editing
  • [ ] : Breakable equations
  • [ ] : MathML parsing and encoding

카테고리

의존성

의존성 목록 5 개

소스 저장소

이 패키지를 사용하는 프로젝트