FileBasedIdStorage class final

An IdStorage persisted as one JSON file, loaded on first use.

Codes are written sorted so the file diffs cleanly, and every mutation is written through before it reports success — a store that only mutated memory would look correct for a session and lose everything after it.

Implemented types

Constructors

FileBasedIdStorage({required File file})
Creates a store backed by file; the file is created on first write.

Properties

file → File
The file holding the JSON state.
final
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

add({required String idType, required String idCode}) → Future<Either<IdStorageFailure, Unit>>
Records idCode under idType, keeping whatever is already stored.
override
clear() → Future<Either<IdStorageFailure, Unit>>
Drops every code and every counter.
override
codesFor({required String idType}) → Future<Either<IdStorageFailure, Set<String>>>
Every code stored under idType.
override
contains({required String idType, required String idCode}) → Future<Either<IdStorageFailure, bool>>
Whether idCode is stored under idType.
override
counterFor({required String idType}) → Future<Either<IdStorageFailure, int>>
The counter stored for idType, or 0 when none was ever set.
override
idTypes() → Future<Either<IdStorageFailure, Set<String>>>
Every id type holding at least one code.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
remove({required String idType, required String idCode}) → Future<Either<IdStorageFailure, Unit>>
Removes idCode from idType; removing an absent code is a success.
override
setCounter({required String idType, required int value}) → Future<Either<IdStorageFailure, Unit>>
Stores value as the counter for idType.
override
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited