characters 0.5.0
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 theCharacters
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:
// https://pub.dev/documentation/characters/latest/characters/characters-library.html
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:
dependencies:
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';
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
66
|
Health:
Code health derived from static analysis.
[more]
|
100
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
100
|
Overall:
Weighted score of the above.
[more]
|
83
|
We analyzed this package on Dec 10, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
- Dart: 2.7.0
- pana: 0.13.1+4