Last updated:
0 purchases
morse code translator
Morse Code Translator #
Usage #
Fist depend on the library by adding this to your package's pubspec.yaml:
dependencies:
morse_code_translator: ^0.0.1
copied to clipboard
Now inside your dart project you can import it.
import 'package:morse_code_translator/morse_code_translator.dart';
copied to clipboard
Decoding Morse code #
For this example we're going to use the following Morse code :
String decodingValue = ".... .. / - .... . .-. . / .... --- .-- / .- .-. . / -.-- --- ..- ..--..";
copied to clipboard
Now, we have to decode the Morse code to corresponding string .First we initialize the object.
MorseCode meroMorseCode = MorseCode();
var de = meroMorseCode.deCode(decodingValue);
copied to clipboard
and the corresponding output can be seen
print("The morse code '$decodingValue' is decoded to corresponding String:");
print(de);
copied to clipboard
print statement is for test purpose we can use it with widgets by passing value to text widget or we can use it with TextField and pass value in onChanged property.
Encoding #
String encodingValue = "Hi there how are you?";
copied to clipboard
Now, we have to encode the String to corresponding Morse code .First we initialize the object.
MorseCode meroMorseCode = MorseCode();
var en = meroMorseCode.enCode(encodingValue);
copied to clipboard
and the corresponding output can be seen
print("The String '$encodingValue' is encoded to corresponding morse code:");
print("$en\n");
copied to clipboard
print statement is for test purpose we can use it with widgets by passing value to text widget or we can use it with TextField and pass value in onChanged property.
I had implemented the library here, you can give a look and figure out how to use this library with widgets: https://github.com/Sushil787/MorseCodeTranslator #
Contributing #
Feel for opening a PR with any suggestions !
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.