Skip to content
pubscout

charcode

1.4.0, released 2 years ago by infimum.dk

Provides named integer constants for ASCII and HTML character codes.

WASM-ready
$ flutter pub add charcode
Source repository

What it does

The package defines symbolic names for character codes, making code that works with integer character values more readable. It also offers a CLI tool to generate a custom set of constants for a project.

AI-written summary of version 1.4.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need readable constants for ASCII or common HTML entities in Dart code.
  • You want to avoid hard‑coding integer literals for characters.
  • You prefer a small, dependency‑free helper for character code lookups.
  • You plan to generate a custom file and keep the package as a dev dependency.

Skip it when

  • You already have a code‑generation tool that produces constants.
  • You need runtime access to a large set of Unicode characters beyond ASCII and HTML entities.
  • You prefer to use string literals instead of integer codes.

Strengths

  • Zero runtime dependency, pure Dart constants.
  • Supports both ASCII and HTML entities with clear naming conventions.
  • CLI generator lets you create a trimmed set of constants for production.
  • No build_runner or code‑gen setup required for basic use.

Weaknesses

  • Limited to ASCII and HTML 4.01 entities; no full Unicode support.
  • Requires manual generation for custom sets if you want to drop unused constants.
  • No integration with other code‑gen workflows.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
0

Add to pubspec, import package/ascii.dart or html_entity.dart, or run CLI to generate a file.

import "package:charcode/ascii.dart";

void main() {
  if (firstChar == $A) {
    print('Starts with A');
  }
}

Alternatives

Packages that do the same job and could replace charcode.

Works with

Packages commonly used together with charcode: ones it builds on, ones built on it, and its own family.