A simple, lightweight and easy to use package to generate acronyms.
Usage
You can use it with the standard arguments to generate your acronym:
import 'package:acronym/acronym.dart';
const String input = "The United States of America";
final String output = generateAcronym(input);
print(output); // "USA"
Sample usage with the extension:
import 'package:acronym/acronym.dart';
const String input = "The United States of America";
final String output = input.toAcronym();
print(output); // "USA"
You can use it with stop words like this:
import 'package:acronym/acronym.dart';
const String input = "The United States of America";
final String output = input.toAcronym(stopWords: stopWords);
final String output1 = generateAcronym(input, stopWords: stopWords);
print(output); // "USA"
print(output1); // "USA"
Add your own stop words:
import 'package:acronym/acronym.dart';
const String input = "The United States of America";
final List<String> stopWords = [...stopWords, "states"];
final String output = input.toAcronym(stopWords: stopWords);
print(output); //UA
If you want to generate the Acronym without any words you can do it like this
import 'package:acronym/acronym.dart';
const String input = "The United States of America";
final String output = input.toAcronym(stopWords: []);
print(output); //TUSOA
If you want to generate the acronym out of its syllables just add the splitSyllables Flag
import 'package:acronym/acronym.dart';
const String input = "The United States of America";
final String output5 = input.toAcronym(splitSyllables: true);
print(output5); // UtStArc
Libraries
- acronym
- A acronym generator for Strings.