> For the complete documentation index, see [llms.txt](https://gdgaddis.gitbook.io/mobile-development-reference-tce-c01/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gdgaddis.gitbook.io/mobile-development-reference-tce-c01/products-feature/consuming-the-products-cubit/setting-up-dependency-injection.md).

# Setting up Dependency injection

#### Installing get\_it package

Add this to your package's pubspec.yaml file:

```yaml
dependencies:
  get_it: ^6.0.0
```

#### Now let's set up the dependency injection&#x20;

First, create the "di.dart" file under src/di/ with the following code.

```dart
import 'package:dio/dio.dart';
import 'package:get_it/get_it.dart';
import 'package:techamp_flutter_shopping_app/app.dart';

GetIt getIt = GetIt.instance;

void registerDependencies() {
  _registerConfigurations();
  _registerProduct();
  _registerProfile();
  _registerCart();
}

void _registerCart() {
  getIt.registerFactory<CartCubit>(() => CartCubit());
}

void _registerConfigurations() {
  getIt.registerSingleton(
    Dio(
      BaseOptions(
        baseUrl: 'https://fakestoreapi.com/',
        connectTimeout: 20000,
        receiveTimeout: 30000,
        sendTimeout: 30000,
      ),
    ),
  );
}

void _registerProduct() {
  getIt
    ..registerFactory<ProductRepository>(() => ProductRepositoryImpl(getIt()))
    ..registerFactory(() => ProductsCubit(getIt()));
}

void _registerProfile() {
  getIt
    ..registerFactory<ProfileRepository>(() => ProfileRepositoryImpl(getIt()))
    ..registerFactory(() => ProfileCubit(getIt()));
}
```
