Provider class abstract
Abstract base class for service providers.
Providers are used to:
- Register services into the ServiceContainer
- Perform boot-time initialization (e.g., route registration, event listeners)
Lifecycle:
register(container)— bind servicesboot(container)— perform startup logic (async)
Example:
class RouteServiceProvider extends Provider {
@override
void register(ServiceContainer container) {
container.bindInstance<MyService>(MyService());
}
@override
Future<void> boot(ServiceContainer container) async {
final router = container.make<Router>();
router.get('/health', (req) async => req.respond('OK'));
}
}
Constructors
- Provider()
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
-
boot(
ServiceContainer container) → Future< void> - Performs asynchronous boot-time initialization.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
register(
ServiceContainer container) → void - Registers services, bindings, or singletons into the container.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited