get_it_di_global_variable 0.0.6 copy "get_it_di_global_variable: ^0.0.6" to clipboard
get_it_di_global_variable: ^0.0.6 copied to clipboard

A tiny Dart package that exposes a global instance of GetIt (sl) for easy and consistent dependency injection across your Flutter or Dart project.

get_it_di_global_variable #

A simple Dart package that provides a globally accessible instance of GetIt, a popular service locator for dependency injection in Flutter and Dart apps.

πŸ”§ Installation #

Add this package to your pubspec.yaml:

dependencies:
  get_it_di_global_variable: latest_version 

Then run:

flutter pub get

πŸš€ Usage #

This package exposes a globally accessible instance of GetIt named sl, which is short for "service locator".

Import the package: #

import 'package:get_it_di_global_variable/get_it_di_global_variable.dart';

Register your dependencies: #

sl.registerSingleton<ApiService>(ApiService());

Retrieve your dependencies: #

final apiService = sl<ApiService>();

πŸ“¦ Provided Code #

import 'package:get_it/get_it.dart';

final GetIt sl = GetIt.I;

🎯 Why use this? #

  • Avoid boilerplate in each file to define a GetIt instance.
  • Cleaner and more readable dependency registration and access.
  • Common convention (sl) used in many Flutter projects.

πŸ“ License #

This package is released under the MIT License.

1
likes
150
points
630
downloads

Publisher

unverified uploader

Weekly Downloads

A tiny Dart package that exposes a global instance of GetIt (sl) for easy and consistent dependency injection across your Flutter or Dart project.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, get_it

More

Packages that depend on get_it_di_global_variable