characters 0.5.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 96

pub package Build Status

NOTE: This package is in technical preview, and breaking API changes are to be expected.

Characters are strings viewed as sequences of user-perceived characters, also know as Unicode (extended) grapheme clusters.

The Characters class allows access to the individual characters of a string, and a way to navigate back and forth between them using a CharacterRange.

Changelog #

0.5.0 #

  • Change [codeUnits] getter to [utf16CodeUnits] which returns an iterable. This avoids leaking that the underlying string has efficient UTF-16 code unit access in the API, and allows the same interface to be just as efficiently implemented on top of UTF-8.

0.4.0 #

  • Added an extension method on String to allow easy access to the Characters of the string:

    print('The first character is: ' + myString.characters.first)
  • Updated Dart SDK dependency to Dart 2.6.0

0.3.1 #

  • Added small example in example/main.dart
  • Enabled pedantic lints and updated code to resolve issues.

0.3.0 #

  • Updated API which does not expose the underlying string indices.

0.1.0 #

  • Initial release


import 'package:characters/characters.dart';

// Small API examples. For full API docs see:
main() {
  String hi = 'Hi πŸ‡©πŸ‡°';
  print('String is "$hi"\n');

  // Length.
  print('String.length: ${hi.length}');
  print('Characters.length: ${hi.characters.length}\n');

  // Last character.
  print('The string ends with: ${hi.substring(hi.length - 1)}');
  print('The last character: ${hi.characters.last}\n');

  // Skip last character.
  print('Substring -1: "${hi.substring(0, hi.length - 1)}"');
  print('Skipping last character: "${hi.characters.skipLast(1)}"\n');

  // Replace characters.
  Characters newHi =
      hi.characters.replaceAll('πŸ‡©πŸ‡°'.characters, 'πŸ‡ΊπŸ‡Έ'.characters);
  print('Change flag: "$newHi"');

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  characters: ^0.5.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:characters/characters.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Apr 4, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.0 <3.0.0
Dev dependencies
pedantic any
test ^1.6.0