SequentialIdGenerator class final
Produces predictable identifiers of the form <prefix><n>.
Intended for tests and for golden-file fixtures, where an assertion on an exact identifier is far more readable than a regular expression.
final ids = SequentialIdGenerator(prefix: 'run-');
ids.generate(); // 'run-1'
ids.generate(); // 'run-2'
- Implemented types
- Available extensions
- Annotations
-
- @visibleForTesting
Constructors
- SequentialIdGenerator({String prefix = 'id-', int start = 1})
-
Creates a generator that counts up from
start.
Properties
Methods
-
generate(
) → String -
Returns a new identifier.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
prefixed(
String prefix) → String -
Available on IdGenerator, provided by the PrefixedIds extension
Returns<prefix>_<id>. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited