Get It - Simple direct Service Locator that allows to decouple the interface from a concrete implementation and to access the concrete implementation from everywhere in your App. Maintainer: @escamoteur
1,470
stars
492
commits
JavaScript
primary language
Feb 20, 2026
updated
📚 Complete documentation available at flutter-it.dev Check out the comprehensive docs with detailed guides, examples, and best practices!
A blazing-fast service locator for Dart and Flutter that makes dependency management simple.
As your app grows, you need a way to access services, models, and business logic from anywhere without tightly coupling your code to widget trees. get_it is a simple, type-safe service locator that gives you O(1) access to your objects from anywhere in your app—no BuildContext required, no code generation, no magic.
Think of it as a smart container that holds your app's important objects. Register them once at startup, then access them from anywhere. Simple, fast, and testable.
flutter_it is a construction set — get_it works perfectly standalone or combine it with other packages like watch_it (state management), command_it (commands), or listen_it (reactive operators). Use what you need, when you need it.
Learn more about the philosophy behind get_it →
💡 New to service locators? Read Martin Fowler's classic article on Inversion of Control Containers and the Dependency Injection pattern or check out this detailed blog post on using service locators with Flutter.
Add to your pubspec.yaml:
dependencies:
get_it: ^8.0.2
import 'package:get_it/get_it.dart';
// Create a global instance (or use GetIt.instance)
final getIt = GetIt.instance;
// 1. Define your services
class ApiClient {
Future<void> fetchData() async { /* ... */ }
}
class UserRepository {
final ApiClient apiClient;
UserRepository(this.apiClient);
}
// 2. Register them at app startup
void configureDependencies() {
getIt.registerSingleton<ApiClient>(ApiClient());
getIt.registerLazySingleton<UserRepository>(
() => UserRepository(getIt<ApiClient>())
);
}
// 3. Access from anywhere in your app
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: () {
// No BuildContext passing needed!
getIt<UserRepository>().apiClient.fetchData();
},
child: Text('Fetch Data'),
);
}
}
That's it! Three simple steps: define, register, access.
Choose the lifetime that fits your needs:
Singleton — Create once, share everywhere. Perfect for services that maintain state. Read more →
LazySingleton — Create on first access. Delays initialization until needed. Read more →
Factory — New instance every time. Great for stateless services or objects with short lifetimes. Read more →
Scopes — Create hierarchical registration scopes for different app states (login/logout, sessions, feature flags). Read more →
Async Objects — Register objects that need async initialization with dependency ordering. Read more →
Startup Orchestration — Easily orchestrate initialization of asynchronous objects during startup. Read more →
Named Instances — Register multiple implementations of the same type with different names. Read more →
Multiple Registrations — Register multiple implementations and retrieve them all as a collection. Read more →
get_it makes testing a breeze:
allowReassignment or reset()reset() clears all registrations between tests// In tests
setUp(() {
getIt.registerSingleton<ApiClient>(MockApiClient());
});
tearDown(() async {
await getIt.reset();
});
get_it includes a DevTools extension that lets you visualize and inspect all registered objects in your running app:
toString() output of created instances to inspect their stateEnable debug events in your app (typically in main.dart). This enables the extension to receive automatic updates when registrations change:
void main() {
GetIt.instance.debugEventsEnabled = true;
// ... rest of your setup
runApp(MyApp());
}
Run your app in debug mode and open DevTools
Open DevTools in the browser — The extension currently only works in the browser-based DevTools, not in the IDE-embedded version.
Enable the extension — Click the Extensions button (puzzle piece icon) in the top right corner of DevTools and enable the get_it extension.
Find the "get_it" tab — The extension will appear as a new tab in DevTools
For more information on using DevTools extensions, see the official Flutter DevTools documentation.
💡 Tip: Override
toString()in your registered classes to see meaningful details in the DevTools extension. By default, Dart'stoString()only shows the type name and instance ID.
class UserRepository {
final String userId;
@override
String toString() => 'UserRepository(userId: $userId)';
}
get_it works seamlessly with Flutter's widget previewer. Since previews run in isolation, you need to initialize get_it within the preview itself:
@Preview()
Widget myPreview() {
if (!getIt.isRegistered<MyService>()) {
getIt.registerSingleton<MyService>(MockService());
}
return const MyWidget();
}
Or use a reusable wrapper for automatic cleanup:
@Preview(name: 'My Widget', wrapper: myWrapper)
Widget myPreview() => const MyWidget();
get_it works independently — use it standalone for dependency injection in any Dart or Flutter project.
Want more? Combine with other packages from the flutter_it ecosystem:
Optional: watch_it — Reactive state management built on get_it. Watch registered objects and rebuild widgets automatically.
Optional: command_it — Command pattern with loading/error states. Integrates seamlessly with get_it services.
Optional: listen_it — ValueListenable operators (map, where, debounce). Use with objects registered in get_it.
Remember: flutter_it is a construction set. Each package works independently. Pick what you need, combine as you grow.
This package includes AI skill files in the skills/ directory that help AI coding assistants
(Claude Code, Cursor, GitHub Copilot, and others) generate correct code using get_it.
The skill files teach AI tools critical rules, common patterns, and anti-patterns specific to get_it.
Included skills: get-it-expert, flutter-architecture-expert.
They follow the Agent Skills open standard.
allReady()Contributions are welcome! Please read the contributing guidelines before submitting PRs.
MIT License - see LICENSE file for details.
Many thanks to Brian Egan and Simon Lightfoot for the insightful discussions on the API design.
Part of the flutter_it ecosystem — Build reactive Flutter apps the easy way. No codegen, no boilerplate, just code.
(top 30 of 47)
JavaScript
85.8%
Dart
12.3%
Get It - Simple direct Service Locator that allows to decouple the interface from a concrete implementation and to access the concrete implementation from everywhere in your App. Maintainer: @escamoteur
1,470
stars
492
commits
JavaScript
primary language
Feb 20, 2026
updated
📚 Complete documentation available at flutter-it.dev Check out the comprehensive docs with detailed guides, examples, and best practices!
A blazing-fast service locator for Dart and Flutter that makes dependency management simple.
As your app grows, you need a way to access services, models, and business logic from anywhere without tightly coupling your code to widget trees. get_it is a simple, type-safe service locator that gives you O(1) access to your objects from anywhere in your app—no BuildContext required, no code generation, no magic.
Think of it as a smart container that holds your app's important objects. Register them once at startup, then access them from anywhere. Simple, fast, and testable.
flutter_it is a construction set — get_it works perfectly standalone or combine it with other packages like watch_it (state management), command_it (commands), or listen_it (reactive operators). Use what you need, when you need it.
Learn more about the philosophy behind get_it →
💡 New to service locators? Read Martin Fowler's classic article on Inversion of Control Containers and the Dependency Injection pattern or check out this detailed blog post on using service locators with Flutter.
Add to your pubspec.yaml:
dependencies:
get_it: ^8.0.2
import 'package:get_it/get_it.dart';
// Create a global instance (or use GetIt.instance)
final getIt = GetIt.instance;
// 1. Define your services
class ApiClient {
Future<void> fetchData() async { /* ... */ }
}
class UserRepository {
final ApiClient apiClient;
UserRepository(this.apiClient);
}
// 2. Register them at app startup
void configureDependencies() {
getIt.registerSingleton<ApiClient>(ApiClient());
getIt.registerLazySingleton<UserRepository>(
() => UserRepository(getIt<ApiClient>())
);
}
// 3. Access from anywhere in your app
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: () {
// No BuildContext passing needed!
getIt<UserRepository>().apiClient.fetchData();
},
child: Text('Fetch Data'),
);
}
}
That's it! Three simple steps: define, register, access.
Choose the lifetime that fits your needs:
Singleton — Create once, share everywhere. Perfect for services that maintain state. Read more →
LazySingleton — Create on first access. Delays initialization until needed. Read more →
Factory — New instance every time. Great for stateless services or objects with short lifetimes. Read more →
Scopes — Create hierarchical registration scopes for different app states (login/logout, sessions, feature flags). Read more →
Async Objects — Register objects that need async initialization with dependency ordering. Read more →
Startup Orchestration — Easily orchestrate initialization of asynchronous objects during startup. Read more →
Named Instances — Register multiple implementations of the same type with different names. Read more →
Multiple Registrations — Register multiple implementations and retrieve them all as a collection. Read more →
get_it makes testing a breeze:
allowReassignment or reset()reset() clears all registrations between tests// In tests
setUp(() {
getIt.registerSingleton<ApiClient>(MockApiClient());
});
tearDown(() async {
await getIt.reset();
});
get_it includes a DevTools extension that lets you visualize and inspect all registered objects in your running app:
toString() output of created instances to inspect their stateEnable debug events in your app (typically in main.dart). This enables the extension to receive automatic updates when registrations change:
void main() {
GetIt.instance.debugEventsEnabled = true;
// ... rest of your setup
runApp(MyApp());
}
Run your app in debug mode and open DevTools
Open DevTools in the browser — The extension currently only works in the browser-based DevTools, not in the IDE-embedded version.
Enable the extension — Click the Extensions button (puzzle piece icon) in the top right corner of DevTools and enable the get_it extension.
Find the "get_it" tab — The extension will appear as a new tab in DevTools
For more information on using DevTools extensions, see the official Flutter DevTools documentation.
💡 Tip: Override
toString()in your registered classes to see meaningful details in the DevTools extension. By default, Dart'stoString()only shows the type name and instance ID.
class UserRepository {
final String userId;
@override
String toString() => 'UserRepository(userId: $userId)';
}
get_it works seamlessly with Flutter's widget previewer. Since previews run in isolation, you need to initialize get_it within the preview itself:
@Preview()
Widget myPreview() {
if (!getIt.isRegistered<MyService>()) {
getIt.registerSingleton<MyService>(MockService());
}
return const MyWidget();
}
Or use a reusable wrapper for automatic cleanup:
@Preview(name: 'My Widget', wrapper: myWrapper)
Widget myPreview() => const MyWidget();
get_it works independently — use it standalone for dependency injection in any Dart or Flutter project.
Want more? Combine with other packages from the flutter_it ecosystem:
Optional: watch_it — Reactive state management built on get_it. Watch registered objects and rebuild widgets automatically.
Optional: command_it — Command pattern with loading/error states. Integrates seamlessly with get_it services.
Optional: listen_it — ValueListenable operators (map, where, debounce). Use with objects registered in get_it.
Remember: flutter_it is a construction set. Each package works independently. Pick what you need, combine as you grow.
This package includes AI skill files in the skills/ directory that help AI coding assistants
(Claude Code, Cursor, GitHub Copilot, and others) generate correct code using get_it.
The skill files teach AI tools critical rules, common patterns, and anti-patterns specific to get_it.
Included skills: get-it-expert, flutter-architecture-expert.
They follow the Agent Skills open standard.
allReady()Contributions are welcome! Please read the contributing guidelines before submitting PRs.
MIT License - see LICENSE file for details.
Many thanks to Brian Egan and Simon Lightfoot for the insightful discussions on the API design.
Part of the flutter_it ecosystem — Build reactive Flutter apps the easy way. No codegen, no boilerplate, just code.
(top 30 of 47)
JavaScript
85.8%
Dart
12.3%