CustomDep<Value> class abstract

Warning: Use this class with very caution. It is not recommended to use this class unless you absolutely need to. It is much easier to use the standard Dep class and it covers most of the use cases.

Abstract base class for creating custom dependency types.

Use this class as a base when you need to create a specialized dependency with custom behavior, validation, or additional functionality beyond what the standard Dep class provides.

Example:

class DatabaseDep extends Dep<Database> {
  DatabaseDep._(BaseScopeContainer scope, String connectionString)
    : super._(
      scope,
      () => Database.connect(connectionString),
      DatabaseDepBehavior(),
    );
}

class DatabaseDepBehavior extends DepBehavior<Database, DatabaseDep> {
  @override
  Database getValue(DepAccess<Database, DatabaseDep> access) {
    final db = super.getValue(access);
    if (!db.isConnected) {
      throw StateError('Database connection is not available');
    }
    return db;
  }
}
Inheritance

Constructors

CustomDep(BaseScopeContainer scope, DepBuilder<Value> builder, {String? name, DepObserverInternal? observer, DepBehavior<Value, Dep<Value>>? behavior})
Creates a custom dependency.

Properties

get → Value
Returns an entity by request
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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