Symbolic names for character codes in Dart

Related tags

Templates charcode
Overview

Build Status Pub

Character code constants

This package can generate constant symbolic names for character codes.

The constants can used when working directly with characters as integers, to make the code more readable: if (firstChar == $A) ... vs if (firstChar == 0x41 /*A*/).

Pre-defined constants

The package also provides a set of pre-defined constants covering all ASCII characters and all HTML entities.

Those constants are intended for use while developing a new package or application. When development is done, it's recommended that you generate a file for yourself, containing only the constants that you actually use, and include that in your project.

Usage

To generate a set of constants, run the charcode application with a list of the characters you want to reference.

Example:

dart run charcode -o lib/src/charcodes.dart "09.e\-ftn{}[],:"

Run dart run charcode --help to see other options.

After switching to the generated constants file, you can, and should, remove your dependency on this package, or keep it as a dev-dependency in case you want to generate the file again.

To use the pre-defined constants, import either the ASCII or the HTML library

import "package:charcode/ascii.dart";
// or
import "package:charcode/html_entity.dart";

or import both libraries using the combined charcode.dart library:

import "package:charcode/charcode.dart";

(Importing both libraries directly causes some conflicting names to be inaccessible.)

Naming

The character names are preceded by a $ to avoid conflicting with other variables, due to their short and common names (for example "$i").

Characters that are valid in a Dart identifier directly follow the $. Examples: $_, $a, $B and $3. Other characters are given symbolic names.

The names of letters are lower-case for lower-case letters ($sigma for σ), and mixed- or upper-case for upper-case letters ($Sigma for Σ). The names of symbols and punctuation are all lower-case or camelCase, and omit suffixes like "sign", "symbol" and "mark". Examples: $plus, $exclamation, $tilde, $doubleQuote.

The ascii.dart library defines a symbolic name for each ASCII character. Some characters have more than one name. For example the common name $tab and the official abbreviation $ht for the horizontal tab.

The html_entity.dart library defines a constant for each HTML 4.01 character entity using their standard entity abbreviation, including case. Examples: $nbsp for &nbps;, $aring for the lower-case å and $Aring for the upper-case Å.

The HTML entities include all characters in the Latin-1 code page, Greek letters and some mathematical symbols.

The charcode.dart library exports both ascii.dart and html_entity.dart. Where both libraries define the same name, the HTML entity name is preferred.

Rationale

The Dart language doesn't have character literals. If that ever changes, this package will become irrelevant. Until then, this package can be used for the most common characters. See request for character literals.

You might also like...

Boilerplate codes including Superbase settings for Flutter

Boilerplate codes including Superbase settings for Flutter

flutter_boilerplate_supabase Boilerplate codes including Superbase settings for Flutter. Getting Started You have to create the .env file. Rename the

Feb 7, 2022

An TOTP codes generator for 2FA

An TOTP codes generator for 2FA

otp_generator This is a full mobile and multiplatform application that allow you to generate TOTP codes using secret keys or scanning the QR code offe

Dec 18, 2022

Mysql.dart - MySQL client for Dart written in Dart

Native MySQL client written in Dart for Dart See example directory for examples

Dec 29, 2022

Docker images for the Dart programming language (https://dart.dev)

dart-docker This is the Git repo of the Docker "Official Images" for the Dart programming language. See the Docker Hub page for a full description on

Dec 14, 2022

A most easily usable Duolingo API wrapper in Dart. Duolingo4D is an open-sourced Dart library.

A most easily usable Duolingo API wrapper in Dart! 1. About Duolingo4D Duolingo4D is an open-sourced Dart library. With Duolingo4D, you can easily int

Oct 17, 2022

dna, dart native access. A lightweight dart to native super channel plugin

dna, dart native access. A lightweight dart to native super channel plugin, You can use it to invoke any native code directly in contextual and chained dart code.

Jul 11, 2022

Dart package responsible to provide the basic resources to Lambda Functions with Clean Dart

AWS Lambda Core This package is responsible to provide the basic resources to all services; Usage pubspec.yaml dependencies: aws_lambda_core: laste

Dec 2, 2021

A Dart client for the NATS messaging system. Design to use with Dart and Flutter.

Dart-NATS A Dart client for the NATS messaging system. Design to use with Dart and flutter. Flutter Web Support by WebSocket client.connect(Uri.parse(

Nov 18, 2022
Comments
  • Bump SDK constraints for pub

    Bump SDK constraints for pub

    Use a 2.12.0 lower bound since pub does not understand allowed experiments for earlier versions.

    Use a 3.0.0 upper bound to avoid a warning in pub and to give some flexibility in publishing for stable.

    opened by natebosch 3
  • Command line functionality

    Command line functionality

    Allow the package to generate source for constants.

    This allows this package to be used as a dev-dependency, or a one-time dependency, instead of being depended on at compile- and run-time.

    opened by lrhn 0
Releases(1.1.0)
Gumao: A Game Character Collector App built using Flutter

Gumao-A Game Character Collector App This Application is made in Flutter ?? & Dart ?? Code Style Design Credits This Design is from Dribbble by Vijay

Abhishek Rajendra Wagh 35 Nov 23, 2022
Simple Flutter text highlighting at the character-level.

substring_highlight Highlight Flutter text at the character-level. Designed for case-insensitive search-term highlighting, a single search term sub-st

Peter Alvin 39 Nov 16, 2022
Flutter Plugin - Simple character blocked input that usually used for redeem/validation input.

Block Input Simple character blocked input that usually used for redeem code or validation code input. Gallery Example Full example import 'package:bl

Enkh-Amar 7 Nov 2, 2022
An application that matches users by their character types

MBTI_Match An application that matches users by their character types. Screenshots Packages Dio A powerful Http client for Dart, which supports Interc

Enis Çakırçalı 6 Jul 3, 2022
A Rick and Morty Character Wiki, build in Flutter with Api Rest integration.

Rick and Morty Character Wiki This is an app build in Flutter that loads a list of characters (from the serie Rick and Morty) and his info, and displa

Jessica Aidyl 3 Jul 27, 2022
The codes written while teaching Dart lessons in Flutter Fest

dart_lessons Flutter Fest etkinliğinde Dart dersleri anlatılırken yazılmış kodla

Çağla Betül Sezer 12 Aug 28, 2022
This is an open source Tips & Tricks for Flutter, that helps flutter Developers write simple but powerful dart codes.

Showcasing-flutter - This is an open source Tips & Tricks for Flutter, that helps flutter Developers write simple but powerful dart codes.

Paul Edeme'kong - Flutter Fairy 1 Jan 4, 2022
Mobile app for enroll paid udemy courses using coupen codes

BookMyCourse An android app where you will find ALL free courses of Udemy in an easy and quick way. Show some ❤️ and ⭐ the repo to encourage the proje

ARUN BALAJI 11 Oct 31, 2022
This is a template repository for starting flutter apps with some pre build codes.

flutter_mobile_template A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you

Mazharul Sabbir 5 Nov 16, 2022
Flutter pokedex - All codes related to the project are completed.

flutter_pokedex It is development work for Flutter tutorial. Getting Started A few required resources to get you test this Flutter project: Models : T

Umutcan 0 Jan 2, 2022