BifrostModel<T> class abstract

Everything BifrostRepository needs to know about a model type.

One generated object carries both capabilities the repository needs: parsing a real response, and inventing a plausible one. It replaces the bare fromJson callback — the argument count at the call site is unchanged.

Generated by @generateFake; you never write one by hand:

Future<BifrostResult<Product>> getProduct(String id) => fetch<Product, Product>(
      apiRequest: () => api.get(api.product(id)),
      model: const ProductModel(),
      cacheKey: 'product_$id',
    );

Why an object rather than a fake: callback passed alongside fromJson: Dart cannot reach a static member through a type parameter, so M.fake() is inexpressible. Passing an instance is the only way the repository can invoke both behaviours for an arbitrary M — and bundling them means one parameter instead of two.

Implementers

Constructors

BifrostModel()
const

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

fake() → T
Builds a plausible T with no network involved.
fromJson(Map<String, dynamic> json) → T
Parses a decoded JSON object into T.
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