Service<T> class

A simple utility class that encapsulates a Create and a Dispose function and generates a Provider in order to make the object created with the Create function available in the widget tree.

Just like Providers, the Create function is called lazily by default. If the Service needs to be initialized greedly, the lazy parameter can be used:

AppGadget(
 services: [
    Service(create: (_) => MyCustomService(), lazy: false),
 ]
 child: MyChildWidget()
);

A list of services can be specified when creating a new AppGadget widget:

AppGadget(
 services: [
    Service(create: (_) => MyCustomObject()),
    Service(create: (_) => MyOtherCustomObject()),
 ]
 child: MyChildWidget()
);

Constructors

Service({required Create<T> create, Dispose<T>? dispose, bool lazy = true})

Properties

create ↔ Create<T>
getter/setter pair
dispose ↔ Dispose<T>?
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
lazy bool
getter/setter pair
provider → Provider<T>
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

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