Cacheable class

Marks a class as serializable by quantum_cache's code generator.

When applied to a class, the build_runner code generator will produce a <ClassName>Adapter in a companion .g.dart file.

Example:

part 'product.g.dart';

@Cacheable(typeId: 5)
class Product {
  @CacheField(0) final String id;
  @CacheField(1) final String name;
  @CacheField(2) final double price;
  @CacheField(3) final DateTime createdAt;

  const Product({
    required this.id,
    required this.name,
    required this.price,
    required this.createdAt,
  });
}

Then register the adapter once at startup:

SuperCache.registerAdapter(ProductAdapter());
await SuperCache.init();

Constructors

Cacheable({required int typeId})
Creates a Cacheable annotation.
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
typeId int
Unique numeric identifier for this type in binary streams.
final

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