hyphen 0.1.3 copy "hyphen: ^0.1.3" to clipboard
hyphen: ^0.1.3 copied to clipboard

A cross-platform Flutter plugin that provides high-quality word hyphenation.

Hyphen #

pub package License: MIT + MPL 2.0

Hyphen is a cross-platform Flutter plugin that provides high-quality word hyphenation.
It uses the hunspell/hyphen C library under the hood (via FFI) on native platforms, and a WebAssembly/JS runtime on the Web.

With Hyphen, you can automatically insert hyphenation marks into words based on language-specific rules. By default, the plugin uses "=" as the separator, but you can configure it to use any custom separator you want.


✨ Features #

  • Works on all Flutter platforms: Android, iOS, macOS, Windows, Linux, Web
  • Uses battle-tested hyphen dictionaries
  • Two hyphenation APIs available:
    • hnjHyphenate2 – classic hyphenation
    • hnjHyphenate3 – extended API with additional options
  • Unified API – always use the same Hyphen class, no matter the platform

📦 Installing #

Add to your pubspec.yaml:

dependencies:
  hyphen: ^0.1.3

Then run:

flutter pub get

📚 Dictionaries #

Hyphen requires a .dic file for the language you want to hyphenate.
These are not bundled due to licensing reasons.

👉 For instructions on how to obtain dictionary-files, see hunspell/hyphen

Place your dictionary in your Flutter project under assets/, and declare it in pubspec.yaml:

flutter:
  assets:
    - assets/hyph_en_US.dic

🚀 Usage #

import 'package:hyphen/hyphen.dart';

Future<void> main() async {
  // Load a dictionary from assets
  final hyphen = await Hyphen.fromDictionaryPath('assets/hyph_en_US.dic');

  // Hyphenate a word
  final result = hyphen.hnjHyphenate2('hyphenation', separator: '-');
  print(result); // "hy-phen-ation"

  // Using the extended API
  final result2 = hyphen.hnjHyphenate3(
    'hyphenation',
    separator: '=',
    lhmin: 3,
    rhmin: 3,
  );
  print(result2); // "hyphen=ation"
}

🖥 Platform Notes #

  • Android/iOS/macOS/Linux/Windows: Uses the native hyphen lib via FFI.
  • Web: Uses a WASM build of the hyphen lib via hyphen.js.
  • On all platforms, you must provide your own .dic file.

⚠️ License #

This package is dual-licensed:

  • Plugin code (Dart, FFI bindings and wrappers): licensed under MIT.
  • Hyphenation engine: incorporates code from Hunspell/Hyphen,
    which is licensed under the Mozilla Public License (MPL).

Hyphenation dictionaries come with their own licenses – check the
hunspell/hyphen repo before redistributing.


🤝 Contributing #

Issues and pull requests are welcome!

2
likes
0
points
42
downloads

Publisher

unverified uploader

Weekly Downloads

A cross-platform Flutter plugin that provides high-quality word hyphenation.

Repository (GitHub)
View/report issues

Topics

#hyphenation #hyphen #ffi #wasm

License

unknown (license)

Dependencies

characters, ffi, flutter, http, path, plugin_platform_interface, web

More

Packages that depend on hyphen

Packages that implement hyphen