Technical Specification

betto_common

1 Overview

betto_common is a pure Dart utility library shared across the Bettongia project family. It has no Flutter or platform dependencies and is licensed under Apache 2.0.

The package exposes two top-level libraries:

Import Purpose
package:betto_common/collections.dart Generic collection types and iterable utilities
package:betto_common/string.dart Locale-aware string types and Unicode string helpers

2 Libraries

2.1 collections.dart

Symbol Kind Description
Stack<E> class LIFO stack backed by a List. Supports push / pop / peek, bulk pushAll, and distanceToElementWhere for scanning back through the stack.
Range class Numerical progression analogous to Python’s range. Supports arbitrary start, stop, and step; forward and reverse traversal; inclusive or exclusive stop. Implements MappedObject.
range() function Convenience wrapper around Range for use directly in for loops.
IterableChecks extension Adds order-insensitive hasTheSameElements and isSubList to any Iterable.
MappedObject<T> interface Marker interface requiring toMap() → Map<String, T>. Adopted by Range and string types to enable structured serialisation.

2.2 string.dart

Symbol Kind Description
IntlString class A string value paired with a BCP-47 locale. The locale defaults to the current Intl locale if not supplied. Implements MappedObject<String>.
IntlStrings class A locale-keyed map of IntlString values. getString({Locale?}) resolves with exact-match → language-only match → fallback locale (en) precedence. Callable directly as a function for convenience.
StringExtension extension Unicode-aware predicates on String: isWhitespace, hasWhitespace, isAsciiControlCharacter, isAsciiDigit, isAsciiLetter (upper/lower), isUnicodePunctuationCharacter, and line-ending checks (isLineFeed, isCrLf). Also provides cutFirst(separator) (split on first occurrence), clipRight(n), and toUpperCaseFirstLetter. All character operations delegate to the characters package for correct Unicode grapheme-cluster handling.
StringList class A Stack<String>-backed mutable list of strings. Supports add (appends a new entry), concatenate (appends to the top entry), and join. Useful when building up string segments incrementally.

3 Dependencies

Package Role
characters Unicode grapheme-cluster iteration used by StringExtension
collection ListEquality (used by Stack) and UnmodifiableSetView (used by IntlStrings)
intl Intl.getCurrentLocale() and Locale used by IntlString / IntlStrings