ServiceLocator class

Dependency injection container for ODBC Fast services.

Provides a singleton instance that manages the lifecycle of core services including the native ODBC connection, repository, and service layers.

Sync vs Async Mode

By default, operates in sync mode (blocking operations). Set useAsync to true during initialization for non-blocking async operations, which is recommended for Flutter applications to prevent UI freezing.

Example (Sync Mode)

final locator = ServiceLocator();
locator.initialize();
final service = locator.service;
await service.initialize();
final locator = ServiceLocator();
locator.initialize(useAsync: true);
final service = locator.asyncService;
await service.initialize();

See also:

Constructors

ServiceLocator()
Gets the singleton instance of ServiceLocator.
factory

Properties

asyncNativeConnection AsyncNativeOdbcConnection
Gets the AsyncNativeOdbcConnection instance.
no setter
asyncService OdbcService
Gets the async OdbcService instance.
no setter
hashCode int
The hash code for this object.
no setterinherited
isAsyncMode bool
Whether the locator was initialized with async mode.
no setter
nativeConnection NativeOdbcConnection
Gets the NativeOdbcConnection instance.
no setter
repository IOdbcRepository
Gets the appropriate repository based on initialization mode.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
service OdbcService
Gets the appropriate service based on initialization mode.
no setter
syncService OdbcService
Gets the sync OdbcService instance.
no setter

Methods

initialize({bool useAsync = false}) → void
Initializes all services and dependencies.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
shutdown() → void
Releases async resources (worker isolate). Call on app exit when using async mode.
toString() String
A string representation of this object.
inherited

Operators

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