Morse Code

version MIT License PRs Welcome

Watch on GitHub Star on GitHub

Usage

Fist depend on the library by adding this to your package's pubspec.yaml:

dependencies:
  morse: ^0.1.4

Now inside your Dart code you can import it.

import 'package:morse/morse.dart';

For this example we're going to use the following morse code string:

final String encodedMessage = '.... . .-.. .-.. --- / .-- --- .-. .-.. -..';

There are two ways to decode a morse code string. Either provide the encoded string as an argument to the constructor, and call the decode method.

final Morse morse = new Morse(encodedMessage);
String decodedMessage = morse.decode();

// Or combine the two, for more compact code:
String decodedMessage =  new Morse(encodedMessage).decode();

Or provide the encoded string as an argument to the decode method.

final Morse morse = new Morse();
String decodedMessage = morse.decode(encodedMessage);

// Or again combine the two, for more compact code:
String decodedMessage =  new Morse().decode(encodedMessage);

You can also use the encode method to convert text to morse code.

final String message = 'Hello World';
final Morse morse = new Morse(message);
String encodedMessage = morse.encode();

// Or combine the two, for more compact code:
String encodedMessage =  new Morse(message).encode();

Contributing

Feel free to open a PR with any suggetions!

Libraries

morse