WithCache class
WithCache
Annotation for Cached package.
Annotating a class with @WithCache will flag
it as a needing to be processed by Cached code generator.
It can take one additional boolean parameter useStaticCache.
If this parameter is set to true, generator will generate
cached class with static cache.
It means each instance of this class will have access
to the same cache. Default value is set to false
Throws an InvalidGenerationSourceError
- if class has to many constructors. Class can have only one constructor
Example
Use @withCache annotation
@withCache
abstract mixin class Gen implements _$Gen {
...
}
or with parameters
@WithCache(useStaticCache: true)
abstract mixin class Gen implements _$Gen {
...
}
do not forget add
part '<file_name>.cached.dart';
if you want to cache method use Cached annotation
- Annotations
-
- @Target.new({TargetKind.classType})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- useStaticCache → bool?
-
If this parameter is set to true,
generator will generate cached class with static cache.
It means each instance of this class will have access
to the same cache. Default value is set to
false.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