haptic_morse 1.0.5
haptic_morse: ^1.0.5 copied to clipboard
Convert text to Morse code and haptic vibration patterns in Dart.
๐ HapticMorse ๐ฅ #
Your Words, in Vibes & Dashes
๐ 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:
morseStringhapticDurationshapticCount
๐งช 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. ๐