RepositoryConnectivityImpl class
Default repository that maps raw payloads to domain (ConnectivityModel) and enforces error semantics using an ErrorMapper.
Error contract
fromPayload(...)detects business errors encoded in payloads and returnsLeft(ErrorItem).- If mapping fails (
fromJsonthrows), the repository converts it intoLeft(ErrorItem)viafromException(...). - Repository never throws; it always returns
Either<ErrorItem, ConnectivityModel>.
Example
final repo = RepositoryConnectivityImpl(gateway, errorMapper: DefaultErrorMapper());
final res = await repo.snapshot();
res.fold(
(err) => print('Repo error: ${err.code}'),
(model) => print('Speed: ${model.internetSpeed}'),
);
- Inheritance
-
- Object
- RepositoryConnectivity
- RepositoryConnectivityImpl
Constructors
- RepositoryConnectivityImpl(GatewayConnectivity gateway, {ErrorMapper? errorMapper})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
checkSpeed(
) → Future< Either< ErrorItem, ConnectivityModel> > -
override
-
checkType(
) → Future< Either< ErrorItem, ConnectivityModel> > -
override
-
current(
) → ConnectivityModel -
override
-
flatMap(
Either< ErrorItem, Map< either) → Either<String, dynamic> >ErrorItem, ConnectivityModel> -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
snapshot(
) → Future< Either< ErrorItem, ConnectivityModel> > -
override
-
toString(
) → String -
A string representation of this object.
inherited
-
watch(
) → Stream< Either< ErrorItem, ConnectivityModel> > -
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited