flutter_bangla_math 0.3.0 copy "flutter_bangla_math: ^0.3.0" to clipboard
flutter_bangla_math: ^0.3.0 copied to clipboard

Render mixed Bangla text and LaTeX math in Flutter without breaking Bengali glyph shaping.

flutter_bangla_math #

flutter_bangla_math renders mixed Bangla text and LaTeX math in Flutter without breaking Bengali glyph shaping. It uses flutter_math_fork for TeX rendering and bundles Noto Sans Bengali so it works on Android, iOS, web, Linux, macOS, and Windows without depending on runtime font fetching.

Features #

  • Inline math with $...$
  • Block math with $$...$$
  • Fraction layout with BanglaMathFraction
  • Escaped dollar handling with \$
  • Bangla text rendered with Noto Sans Bengali by default
  • Inline math baseline alignment tuned for mixed Bangla and math on the same line
  • Offline-safe bundled Noto Sans Bengali font loading
  • Simple LRU cache for repeated math fragments

Installation #

dependencies:
  flutter_bangla_math: ^0.3.0

The current package version targets Flutter >=3.35.0 and Dart ^3.9.0 because it uses the current google_fonts and flutter_lints releases that fit cleanly on current Flutter stable.

Usage #

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

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await ensureBanglaMathFontsLoaded(disableRuntimeFetching: true);
  runApp(const DemoApp());
}

class DemoApp extends StatelessWidget {
  const DemoApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: Scaffold(
        body: Padding(
          padding: EdgeInsets.all(24),
          child: BanglaMathText(
            data: 'যদি $a^2+b^2=c^2$ হয়, তবে এটি সমকোণী ত্রিভুজ।',
          ),
        ),
      ),
    );
  }
}

Block Math #

const BanglaMathText(
  data: 'সমীকরণটি হল:\n\n$$\\int_0^1 x^2\\,dx=\\frac{1}{3}$$',
);

Bangla Fraction #

const BanglaMathFraction(
  numerator: r'লব $x+1$',
  denominator: r'হর $y+2$',
  style: TextStyle(fontSize: 20),
);

Custom Text Style #

const BanglaMathText(
  data: 'ধরি $f(x)=x^2+1$',
  style: TextStyle(fontSize: 20, color: Colors.black87),
);

API #

BanglaMathText({
  required String data,
  TextStyle? style,
  MathConfig? mathConfig,
  String? fontFamily,
  Locale locale = const Locale('bn'),
  TextAlign textAlign = TextAlign.start,
  bool softWrap = true,
  TextScaler? textScaler,
  MathWidgetCache? cache,
})
BanglaMathFraction({
  required String numerator,
  required String denominator,
  TextStyle? style,
  MathConfig? mathConfig,
  String? fontFamily,
  Locale locale = const Locale('bn'),
  TextAlign textAlign = TextAlign.center,
  bool softWrap = true,
  TextScaler? textScaler,
  MathWidgetCache? cache,
  Color? barColor,
  double barThickness = 1,
  double gap = 4,
  EdgeInsetsGeometry padding = const EdgeInsets.symmetric(horizontal: 4),
})

MathConfig controls inline scaling, block spacing, parser settings, and error fallback styling. BanglaMathFraction reuses the same text and math pipeline, so numerator and denominator strings can contain Bangla text with inline math.

Notes #

  • Unmatched $ or $$ delimiters fall back to plain text instead of crashing.
  • The package bundles only Noto Sans Bengali to keep size lower.
  • The Noto Sans Bengali OFL text remains in the repository for reference, but it is not bundled into runtime Flutter assets.
  • On web, flutter_math_fork works for normal cases. If your app needs a KaTeX-based HTML fallback for highly specialized equations, keep that as an app-level escape hatch rather than part of this package API.

Development #

flutter pub get
flutter analyze
flutter test
1
likes
0
points
178
downloads

Publisher

unverified uploader

Weekly Downloads

Render mixed Bangla text and LaTeX math in Flutter without breaking Bengali glyph shaping.

Repository (GitHub)
View/report issues

Topics

#bangla #latex #math #typography

Documentation

Documentation

License

unknown (license)

Dependencies

collection, flutter, flutter_math_fork, google_fonts

More

Packages that depend on flutter_bangla_math