ApplicationHost class

Hosts services and provides dependency injection.

This class also controls the execution of the application itself, providing a framework for services to live in.

There can only be one ServiceHost in an application.

Use this code in your main function:

await ApplicationHost([() => ServiceA(), () => ServiceB()]).run();
Inheritance

Constructors

ApplicationHost(List<BaseService Function()> factories, {bool failWithServices = true, LogBackend? logBackend, Function? onInitialized, List<String> args = const <String>[], Map<String, dynamic> config = const <String, dynamic>{}})
Creates a ServiceHost instance.

Properties

failWithServices bool
finalinherited
hashCode int
The hash code for this object.
no setterinherited
isInShutdown bool
no setterinherited
onInitialized Function?
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

initialize() Future<void>
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
resolveService<TService extends BaseService?>() → TService
inherited
run([CancellationToken? cancel]) Future<void>
Runs the application.
runAsService<T>(T delegate()) → T
inherited
shutdown() Future<void>
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited