haptic_morse 1.0.5 copy "haptic_morse: ^1.0.5" to clipboard
haptic_morse: ^1.0.5 copied to clipboard

Convert text to Morse code and haptic vibration patterns in Dart.

๐ŸŒŸ HapticMorse ๐Ÿ’ฅ #

pub package pub points

Your Words, in Vibes & Dashes

codecov Dart Vibration-Powered


๐Ÿš€ Introduction #

HapticMorse is a powerful, customizable Dart library that brings Morse code to life โ€” not just in symbols, but in vibrations. Whether you're building accessibility tools, games, messaging apps, or just love Morse code (who doesnโ€™t?), this package translates any text input into:

โœจ Readable Morse Code ๐Ÿ“ณ Haptic Feedback Patterns ๐Ÿ”  Custom Symbol Mappings โ€” including non-Latin characters!

All wrapped in a single elegant, performant class.


๐ŸŽฏ Features #

  • ๐Ÿ”  Convert text (A-Z, 0-9) to Morse code strings (.-- --- .-. -.. ...)
  • ๐Ÿ“ณ Generate haptic patterns for dots, dashes, and all gaps
  • ๐Ÿงฉ Fully customizable character & digit mappings โ€” even for non-Latin alphabets!
  • โš™๏ธ Custom timing control (dot, dash, gaps) for complete UX freedom
  • ๐Ÿง  Smart parsing & fallback for unsupported characters
  • โœ… 100% Test Coverage โ€” we've tested every buzz ๐Ÿ’ฏ

๐ŸŒ International & Custom Support #

Youโ€™re not limited to just English! Add custom mappings for other languages, symbols, or even emoji-based Morse (yes, that's a thing now).

final morse = HapticMorse.custom(
  charMap: ['.-', '-...', 'โ˜€๏ธ-', '๐Ÿ’ง๐Ÿ’ง'], // Your custom Morse patterns
  charReference: 'ABๆ—ฅๆฐด', // Must match the map's order
  numericMap: ['...', '...-', '๐Ÿ’Ž', '๐ŸŒ™'],
  numericReference: '0123', // Also in order
);

Now this works:

final output = morse.convertTextToMorseString("ABๆ—ฅๆฐด");
print(output); // .- -... โ˜€๏ธ- ๐Ÿ’ง๐Ÿ’ง

๐ŸŽ‰ Boom โ€” custom Morse for Japanese Kanji, emoji, or anything your heart desires.


๐Ÿ› ๏ธ Usage #

โœ… Default Usage #

final morse = HapticMorse();

final text = "HELLO WORLD";
final result = morse.convertTextToMorseMap(text);

print(result['morseString']); // ".... . .-.. .-.. --- / .-- --- .-. .-.. -.."
print(result['hapticDurations']); // [100, 100, 100, 300, ...]

๐Ÿ”ง With Custom Timings #

final morse = HapticMorse.custom(
  dotDuration: 80,
  dashDuration: 240,
  gapSymbolDuration: 80,
  gapLetterDuration: 240,
  gapWordDuration: 600,
);

โ›“๏ธ Extended from String Directly #

final morse = 'HELLO WORLD'.toMorseString({
  List<String>? charMap,
  String? charReference,
  List<String>? numericMap,
  String? numericReference,
  int? dotDuration,
  int? dashDuration,
  int? gapSymbolDuration,
  int? gapLetterDuration,
  int? gapWordDuration,
  String? symbolReference,
});
final morse2 = 'HELLO WORLD'.toMorseMap({
  List<String>? charMap,
  String? charReference,
  List<String>? numericMap,
  String? numericReference,
  int? dotDuration,
  int? dashDuration,
  int? gapSymbolDuration,
  int? gapLetterDuration,
  int? gapWordDuration,
  String? symbolReference,
});
final morse3 = 'HELLO WORLD'.toHapticPattern({
  List<String>? charMap,
  String? charReference,
  List<String>? numericMap,
  String? numericReference,
  int? dotDuration,
  int? dashDuration,
  int? gapSymbolDuration,
  int? gapLetterDuration,
  int? gapWordDuration,
  String? symbolReference,
});

Vibrate Module #

Call HapticVibration to integrate vibration functionality. #

๐Ÿ“ฆ API Overview #

๐Ÿงฉ convertTextToMorseString(String?) โ†’ String? #

Returns a Morse code string using dots (.) and dashes (-), separating words with /.

๐ŸŽต convertTextToHapticPattern(String?) โ†’ List<int> #

Returns a list of vibration durations for:

  • ๐Ÿ”น Dot
  • ๐Ÿ”ธ Dash
  • โฑ Symbol/letter/word gaps

๐Ÿ”„ convertTextToMorseMap(String?) โ†’ Map<String, dynamic> #

Returns a rich object with:

  • morseString
  • hapticDurations
  • hapticCount

๐Ÿงช Test Coverage #

โœ… 100% Test Coverage This library is thoroughly tested โ€” every line, every case, every buzz! ๐Ÿงช You're in safe, vibrating hands. ๐Ÿ’ฏ


๐Ÿ’ก Use Cases #

  • ๐Ÿ”” Silent alerts & accessibility tools
  • ๐ŸŽฎ Hidden messages in games
  • ๐Ÿง Support for the hearing impaired
  • ๐Ÿ’ฌ Secret Morse-coded chat apps
  • ๐Ÿง  Educational tools
  • ๐ŸŒ Multi-lingual & emoji Morse messages!

๐Ÿ“š Resources #


๐Ÿ‘ Contribute #

Got a new idea or feedback? PRs and issues are always welcome! Letโ€™s make text feel awesome! ๐Ÿ’ฅ


๐Ÿ“œ License #

MIT License. Vibrate responsibly. ๐Ÿ˜Ž

0
likes
160
points
18
downloads

Publisher

unverified uploader

Weekly Downloads

Convert text to Morse code and haptic vibration patterns in Dart.

Repository (GitHub)
View/report issues

Topics

#morse #haptic #vibration

Documentation

API reference

License

MIT (license)

Dependencies

vibration

More

Packages that depend on haptic_morse