Repository<State> class
abstract
Base class for all repositories.
As repositories are responsible for managing the state of the application, they extend Cubit.
- Inheritance
- Implemented types
- Implementers
- Available extensions
Constructors
- Repository(State initialState)
- Base class for all repositories.
Properties
- errorLevel → Level
-
The level to log error messages at.
no setteroverride
-
hasData
→ Future<
void> -
Available on Repository<
A future that completes when this repository has data.AsyncValue< , provided by the AsyncRepoExt extensionState> >no setter -
hasError
→ Future<
void> -
Available on Repository<
A future that completes when this repository has an error.AsyncValue< , provided by the AsyncRepoExt extensionState> >no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- isAsync ↔ bool
-
true
if the repository emits AsyncValues.latefinal - isClosed → bool
-
Whether the bloc is closed.
no setterinherited
-
isLoading
→ Future<
void> -
Available on Repository<
A future that completes when this repository is loading.AsyncValue< , provided by the AsyncRepoExt extensionState> >no setter - level → Level
-
The level to log messages at.
no setteroverride
- namespace → String
-
The namespace to log messages under.
e.g. 'Service.Auth'
no setteroverride
-
ready
→ Future<
void> -
Future that completes after any ongoing build process is finished.
no setter
- refreshOptimization → bool
-
Determines whether refresh optimization is enabled.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- state → State
-
The current state.
no setterinherited
-
stream
→ Stream<
State> -
The current stream of states.
no setteroverride
- updateInterval → Duration
-
The interval at which the repository should update.
If Duration.zero, the repository will not update unless triggered by another repository.
When automatic updates are enabled, the build method will be called with UpdateTrigger at the specified interval.
no setter
Methods
-
addError(
Object error, [StackTrace? stackTrace]) → void -
Reports an
error
which triggers onError with an optional StackTrace.inherited -
build(
Trigger trigger) → FutureOr< void> - Recalculates the state of the repository. Do not call this method directly, use refresh instead.
-
close(
) → Future< void> -
Closes the instance.
This method should be called when the instance is no longer needed.
Once close is called, the instance can no longer be used.
inherited
-
data(
State data) → void -
Available on Repository<
EmitsAsyncValue< , provided by the AsyncRepoExt extensionState> >AsyncValue.data
with the givendata
. -
dispose(
) → void -
Disposes controllers, streams, etc.
override
-
emit(
State state) → void -
Updates the
state
to the providedstate
. emit does nothing if thestate
being emitted is equal to the currentstate
.override -
error(
Object error, [StackTrace? stackTrace]) → void -
Available on Repository<
EmitsAsyncValue< , provided by the AsyncRepoExt extensionState> >AsyncValue.error
with the givenerror
andstackTrace
. -
guard(
Future< State> future(), {void onData(State)?, void onError(Object, StackTrace?)?}) → Future<void> -
Available on Repository<
Guards the givenAsyncValue< , provided by the AsyncRepoExt extensionState> >future
and emits the result. -
listen(
void onData(State)?, {Function? onError, void onDone()?, bool? cancelOnError}) → StreamSubscription< State> - Shortcut for Stream.listen.
-
loading(
) → void -
Available on Repository<
Emits AsyncValue.loading.AsyncValue< , provided by the AsyncRepoExt extensionState> > -
log(
Object message, [Object? error, StackTrace? stackTrace]) → void -
Logs a message with an optional error and stack trace.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onChange(
Change< State> change) → void -
Called whenever a
change
occurs with the givenchange
. Achange
occurs when a newstate
is emitted. onChange is called before thestate
of thecubit
is updated. onChange is a great spot to add logging/analytics for a specificcubit
.inherited -
onError(
Object error, StackTrace stackTrace) → void -
Called whenever an
error
occurs and notifies BlocObserver.onError.inherited -
refresh(
Trigger trigger) → Future< void> - Triggers a repository refresh. Catches all exceptions thrown during the build process.
-
toString(
) → String -
A string representation of this object.
inherited
-
waitForData<
T> (Repository< AsyncValue< repository) → TT> > -
Available on Repository<
Call this in build to wait for the data of a repository.AsyncValue< , provided by the RepoWatchExt extensionState> > -
watch<
T> (Repository< T> repository) → void -
Watches another
repository
for changes. -
watchAsync<
T> (Repository< AsyncValue< repository, {bool setLoading = true, bool setError = true}) → voidT> > -
Available on Repository<
Does the same as watch but for repositories that return an AsyncValue.AsyncValue< , provided by the RepoWatchExt extensionState> >
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited