# injector 3.0.0

injector is a simple to use and lightweight dependency injection library for dart




## Installing
```
export PUB_HOSTED_URL=https://pub.mirror.p-hatan.com
flutter pub add 'injector:3.0.0'
```
Published: 2023-07-04T04:57:56.000403Z
Expected archive SHA-256: ed389bed5b48a699d5b9561c985023d0d5cc88dd5ff2237aadcce5a5ab433e4e

Available in cache; verification: upstream_checksum
## Direct dependencies

## Package README (untrusted upstream documentation)
# Injector 💉 [![Build Status](https://travis-ci.com/tikkrapp/injector.svg?branch=master)](https://travis-ci.com/tikkrapp/injector)

Injector is a simple dependency injection lib for Dart.

It does not replace a complex dependency injection framework like Dagger, but it provides the basics that most apps need.
Feature requests are welcomed!

Internally the injector is a singleton that stores instances and builders in a Map.

Use `registerDependency<Type>()` to register the dependency.
Never ever try to register or get dependencies without the generic type! Dart allows it, but we don't ;)

All instances are lazy loaded, meaning that at the time you request the dependency the instance is created. 
    
Get your dependency using `get<Type>()`. 

    

## Usage

A simple usage example:

    // Register a dependency (Every time a new instance)
    injector.registerDependency<Car>(() {
          var engine = injector.get<Engine>();
          var fuel = injector.get<Fuel>();
          var driver = injector.get<Driver>();
          
          return CarImpl(engine,fuel,driver);
        });
        
    // Register a singleton
    injector.registerSingleton<Car>(() {
              var engine = injector.get<Engine>();
              var fuel = injector.get<Fuel>();
              var driver = injector.get<Driver>();
              
              return CarImpl(engine,fuel,driver);
            });
            
     // Use custom Factories by extending [Factory].
     injector.register(CustomFactory(() => Engine()));
        
    // Register your dependencies / singletons in the  __main.dart__ file

## Notice

If you have an issue with getting dependencies from the injector, check that imports of your dependencies classes are absolute.

Good:
import 'package:<project_name>/some/package/<file_name>.dart';

Bad:
import '../../some/package/<file_name>.dart';

## Features and bugs

Please file feature requests and bugs at the [issue tracker][tracker].

[tracker]: https://github.com/tappeddev/injector/issues

## Changelog
# 3.0.0
- Rename `Builder` to `DependencyBuilder` by [saibotma](https://github.com/tappeddev/injector/pull/37)

# 2.0.0
- Stable release for null safety


## 1.0.9
- Add `get` as shortcut for `getDependency`
- Add deprecated annotation to `getDependency`
- Some preparations for nullability
- [bug] Fixed the bug, that the library detects a wrong circular dependency ([#25][i25])

[i25]: https://github.com/tappeddev/injector/issues/25

## 1.0.8
- Add travis ci badge to readme
- Reformat using dartfmt

## 1.0.7
- Refactor docs

## 1.0.6

- Add remove dependency method
- Add override dependencies property 

## 1.0.5

- **Breaking Changes!** Injector is not a singleton. 
You can use it like a singleton with the static instance ```Injector.appInstance``` 
- You can register your dependencies with a name. But be careful, 
you need always the generic type! It looks like ```Injector.allInstance.registerDependency<UserService>((injector) => UserServiceImpl), dependencyName: "MyCustomName"); ```

## 1.0.4

- Add some documentation for each class


## 1.0.3

- Change license from BSD-3 to Apache 2

## 1.0.2

- Upgrade analysis_options.yaml
- Add missing Cast ("as T")
- Add Test - Cycle dependencies

## 1.0.1

- Upgrade pubspec.yaml (Change dart sdk constraint)
- Update README.md
- Update Description


## 1.0.0

- Create package, 
- Add Injector class
- Add unit tests for "Injector"
- Add example - How to deal with the injector / dependency injector 







 
