commons_lang 0.0.8 copy "commons_lang: ^0.0.8" to clipboard
commons_lang: ^0.0.8 copied to clipboard

Commons Lang provides a host of helper utilities for Dart / Flutter applications.

example/commons_lang_example.dart

import 'package:commons_lang/commons_lang.dart';

void main() {
  Map map = {"animal": "quick brown fox", "target": "lazy dog"};
  StrSubstitutor sub = StrSubstitutor.fromMap(map);

  // The quick brown fox jumps over the lazy dog.
  print(sub.replace('The \${animal} jumps over the \${target}.'));

  // The ${person} jumps over the lazy dog.
  print(sub.replace('The \${person} jumps over the \${target}.'));

  // Use \$ as an escape character
  // The ${animal} jumps over the lazy dog.
  print(sub.replace('The \$\${animal} jumps over the \${target}.'));

  // Variable substitution still occurs in escaped variables
  // The ${quick brown fox} jumps over the lazy dog.
  print(sub.replace('The \$\${\${animal}} jumps over the \${target}.'));

  sub.setVariablePrefix('#[');
  sub.setVariableSuffix(']');
  sub.escapeChar = '@';

  // The quick brown fox jumps over the lazy dog.
  print(sub.replace('The #[animal] jumps over the #[target].'));

  // Use @ as an escape character
  // The #[animal] jumps over the lazy dog.
  print(sub.replace('The @#[animal] jumps over the #[target].'));
}
1
likes
160
points
119
downloads

Publisher

verified publisherlimeslice.org

Weekly Downloads

Commons Lang provides a host of helper utilities for Dart / Flutter applications.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

More

Packages that depend on commons_lang