*[<Null safety>](https://dart.dev/null-safety)*
ComponentContext.create()
Creates the component context. Users need to make sure that they call serve after they have finished adding all their public services.
Note: ComponentContext can only be constructed once.
Example:
Future<void> main() async {
final context = ComponentContext.create();
...
await doAsyncSetup();
...
context.outgoing.serveFromStartupInfo();
}
Implementation
factory ComponentContext.create() {
if (_componentContext != null) {
throw Exception(
'Attempted to construct ComponentContext multiple times. Ensure that the existing ComponentContext is reused instead of constructing multiple instances.');
}
return _componentContext = ComponentContext(
svc: Platform.isFuchsia ? Incoming.fromSvcPath() : Incoming(),
outgoing: Outgoing(),
);
}