putAsync<S> method
Registers a dependency that requires async initialization.
The asyncBuilder is executed immediately and the instance is stored
once the Future completes. After await putAsync(...), the instance
is available via Sint.find<S>() like any other singleton.
Useful for: SharedPreferences, database connections, HTTP clients, etc.
await Sint.putAsync<SharedPreferences>(
() => SharedPreferences.getInstance(),
);
// Later:
final prefs = Sint.find<SharedPreferences>();
Implementation
Future<S> putAsync<S>(
Future<S> Function() asyncBuilder, {
String? tag,
bool permanent = false,
}) async {
final instance = await asyncBuilder();
return put<S>(instance, tag: tag, permanent: permanent);
}