CustomAsyncDep<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 AsyncDep class and it covers most of the use cases.

Abstract base class for creating custom async dependency types.

Use this class as a base when you need to create a specialized async dependency that requires initialization and disposal with custom behavior or validation.

Example:

class HttpClientDep extends CustomAsyncDep<HttpClient> {
  HttpClientDep(BaseScopeContainer scope, {required String baseUrl})
    : super(
        scope,
        () => HttpClient()..baseUrl = baseUrl,
        init: (client) async {
          await client.authenticate();
          print('HTTP client authenticated');
        },
        dispose: (client) async {
          await client.logout();
          client.close();
          print('HTTP client disposed');
        },
      );
}

You can also pass a custom behavior to the dependency.

Example:
```dart
class HttpClientDepBehavior extends AsyncDepBehavior<HttpClient, HttpClientDep> {
  @override
  HttpClient getValue(AsyncDepAccess<HttpClient, HttpClientDep> access) {
    final client = access.dep.get;
    if(!client.loggedIn) {
      throw StateError('Client is not logged in');
    }
    return client;
  }
}
Inheritance

Constructors

CustomAsyncDep(BaseScopeContainer scope, DepBuilder<Value> builder, {required AsyncDepCallback<Value> init, required AsyncDepCallback<Value> dispose, String? name, AsyncDepObserverInternal? observer, AsyncDepBehavior<Value, AsyncDep<Value>>? behavior})
Creates a custom async 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