ItemsProvider<T extends Modelable> class
abstract
Provider that contains a list of Modelable
objects.
- Inheritance
-
- Object
- ChangeNotifier
- FitProvider
- ItemsProvider
Constructors
-
ItemsProvider(Service<
T> ? service, T factoryFunc(), {bool assignUserIdOnCreate = true, bool assignUserIdOnUpdate = true}) - Creates a new ItemsProvider.
Properties
- assignUserIdOnCreate → bool
-
If set to
True
, when creating a new instance, it will automatically be assigned userId.final - assignUserIdOnUpdate → bool
-
If set to
True
, when updating a new instance, it will automatically be assigned userId.final -
data
→ List<
T> -
no setter
- factoryFunc → T Function()
-
Factory function to create an instance of
T
.final - hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
-
initializationStream
→ Stream<
bool> -
Initialization stream.
Gets updated when initialized is changed.
no setterinherited
- initialized ↔ bool
-
Returns
true
if the provider has been initialized.getter/setter pairinherited - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
service
↔ Service<
T> -
Service of the provider.
latefinal
- userId ↔ String
-
User id of the data's owner.
getter/setter pair
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
createNew(
T newData) → Future< (bool, String?)> -
Adds a new instance of
T
,newData
, to the repository. If the creation is sucessful, will returntrue
and the assigned id of the instance. If the creation is not successful, will returnfalse
andnull
. -
delete(
T toDelete) → Future< bool> -
Deletes
toDelete
from the repository. If the suppression is sucessful, returnstrue
. Otherwise,false
. -
destroy(
) → void -
Destroys the data and marks the instance as uninitialized.
override
-
dispose(
) → void -
Discards any resources used by the object. After this is called, the
object is not in a usable state and should be discarded (calls to
addListener will throw after the object is disposed).
inherited
-
initialize(
{dynamic data, String? userId = ""}) → Future< void> -
Initializes the provider.
Should set initialized to
true
at the very end of the implementation.override -
isInstanceValid(
T instance) → bool - Evaluates if an instance is valid within the context of the provider. If an instance is invalid, it won't be created or updated.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
update(
T existingData) → Future< bool> -
Updates
_data
inside the repository. If the creation is sucessful, will returntrue
. Otherwise,false
.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited