Skip to content

Instantly share code, notes, and snippets.

@suragch
Last active March 31, 2021 07:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suragch/0aed4ab53245dd0c1373e9c62ecf86ca to your computer and use it in GitHub Desktop.
Save suragch/0aed4ab53245dd0c1373e9c62ecf86ca to your computer and use it in GitHub Desktop.
service locator example
//import 'storage_service_fake.dart';
import 'storage_service_shared_pref.dart';
import 'package:get_it/get_it.dart';
import 'storage_service.dart';
final getIt = GetIt.instance;
setupServiceLocator() {
//getIt.registerLazySingleton<StorageService>(() => StorageServiceFake());
getIt.registerLazySingleton<StorageService>(() => StorageServiceSharedPreferences());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment