All Projects → nextbss → injector_io

nextbss / injector_io

Licence: MIT License
InjectorIO - Dependency Injection for Flutter

Programming Languages

dart
5743 projects
swift
15916 projects
kotlin
9241 projects
objective c
16641 projects - #2 most used programming language

Projects that are alternatives of or similar to injector io

file manager
FileManager is a wonderful widget that allows you to manage files and folders, pick files and folders, and do a lot more. Designed to feel like part of the Flutter framework.
Stars: ✭ 38 (-47.95%)
Mutual labels:  flutter-package
flutter feather icons
Flutter package for Feather Icons
Stars: ✭ 33 (-54.79%)
Mutual labels:  flutter-package
eva icons flutter
Flutter package for Eva Icons. Eva Icons is a pack of more than 480 beautifully crafted Open Source icons for common actions and items. https://pub.dartlang.org/packages/eva_icons_flutter
Stars: ✭ 80 (+9.59%)
Mutual labels:  flutter-package
CustomSwitch
Custom Switch package created in Flutter
Stars: ✭ 56 (-23.29%)
Mutual labels:  flutter-package
nepali date picker
Material Style Date Picker with Bikram Sambat(Nepali) Calendar Support. Supports both Android and ios.
Stars: ✭ 30 (-58.9%)
Mutual labels:  flutter-package
water drop nav bar
flutter navigation bar with water drop effect.
Stars: ✭ 29 (-60.27%)
Mutual labels:  flutter-package
sliding panel
A Flutter slidable widget that provides an easy to use configuration. Highly customisable. Just as you want it!
Stars: ✭ 88 (+20.55%)
Mutual labels:  flutter-package
glider
Server-side rendering for mobile apps, powered by Flutter
Stars: ✭ 20 (-72.6%)
Mutual labels:  flutter-package
reactive state
An easy to understand reactive state management solution for Flutter.
Stars: ✭ 19 (-73.97%)
Mutual labels:  flutter-package
flutter material showcase
Material Design components showcase for Flutter apps. Use to check ThemeData with most Material widgets.
Stars: ✭ 22 (-69.86%)
Mutual labels:  flutter-package
flutter-devicelocale
A Flutter package to read and return the set device locales
Stars: ✭ 45 (-38.36%)
Mutual labels:  flutter-package
anim search bar
A flutter package that has an animated search bar with loads of customization
Stars: ✭ 28 (-61.64%)
Mutual labels:  flutter-package
common-injector
Heavily influenced by Angular and it's dependency injection. Inspired by Angular and Indiv.
Stars: ✭ 18 (-75.34%)
Mutual labels:  injector
linker
Dependency Injection and Inversion of Control package
Stars: ✭ 33 (-54.79%)
Mutual labels:  injector
time chart
A scrollable time chart in Flutter.
Stars: ✭ 21 (-71.23%)
Mutual labels:  flutter-package
IQPlayer
Simple video player with subtitle for flutter.
Stars: ✭ 16 (-78.08%)
Mutual labels:  flutter-package
lang table
lang_table is a dart plugin to generate string files from a source. Use a table to manage all multi-language resources. Inspired by fetch-mobile-localization-from-airtable
Stars: ✭ 17 (-76.71%)
Mutual labels:  flutter-package
sliding clipped nav bar
Bottom navigation bar with sliding clip effect.
Stars: ✭ 46 (-36.99%)
Mutual labels:  flutter-package
Flutter-firestore-auth
Flutter mobile app with firestore authentication including Email and Social auth.
Stars: ✭ 95 (+30.14%)
Mutual labels:  flutter-package
evilELF
Malicious use of ELF such as .so inject, func hook and so on.
Stars: ✭ 56 (-23.29%)
Mutual labels:  injector

InjectorIO - Dependency Injection for Flutter

Pub support

Inject your dependencies easily and quickly. Register in one place and use get() everywhere to retrieve your instances and InjectorIO will take care of the rest.

Features

  • Create singleton instances;
  • Create factory instances (recreated on every call);
  • Register instances using Module;
  • Get instances from anywhere using the get() function.
  • Logs printed while in DEBUG mode.
  • Easy to test.
  • Doesn't use reflection.
  • InjectorIO prevents you from keeping instances of classes that extends Widget.

Core concepts

  • get() => Used to resolve the instance of a registered class. This is what you will use most.
  • inject() => Used to resolve a dependency inside a Module.
  • single() => Used to register a singleton instance. You will receive a the same instance every time you use get().
  • factory() => Used to register a factory instance. You will receive a new instance every time you use get().

NOTE: don't get confused with get() and inject(). Just remember this: If you are inside a Module and you want to resolve a dependency use inject(), but if you are not within a Module always use get().

Usage

Basic Sample

Here is how you can easily use this package. Import this package and register your dependency instance, then in any part of your code use get() to resolve the registered instance.

import 'package:injectorio/injectorio.dart';

void main(){
  InjectorIO.start()
  .single( CountriesRepository()); // register a instance

  runApp(MyApp());
}

class _MyHomePageState extends State<MyHomePage> {
  // This works
  // final CountriesRepository repository = get();

  CountriesRepository _repository;

  @override
  void initState() {
    super.initState();
    _repository = get(); // resolve the dependency
  }

  @override
  Widget build(BuildContext context) {
    return Container();
  }
}

Register Dependencies

import 'package:injectorio/injectorio.dart';

void main() {
  InjectorIO.start()
  .single(CountriesWebService())
  .factory(() => CountriesRepository(get()));

  runApp(MyApp());
}

Register Dependencies using Module

import 'package:injectorio/injectorio.dart';

class CountriesWebService{}

class CountriesRepository{
  final CountriesWebService webService;
  CountriesRepository(this.webService);
}

class AppModule extends Module{
  AppModule() {
    single( CountriesWebService()); // register a singleton of CountriesWebService
    factory(CountriesRepository(inject())); // the library will take care of getting the instance of CountriesWebService
  }
}

void main(){
  InjectorIO.start()
  .module(AppModule());

  runApp(MyApp());
}

Enable/Disable Logs

InjectorIO can also provide printed logs while in development mode. The function InjectorIO.start() receives a InjectorMode that can be:

  • DEBUG - Displays logs
  • PRODUCTION - Disables logs. You will not see logs from this package in the console.

The default value for this is DEBUG. If you don't want to see logs, just use production mode:

InjectorIO.start(mode: InjectorMode.PRODUCTION)
.module( AppModule());

Help this Library

You can help/support by:

  • Reporting a Bug;
  • Making pull request;
  • Write a tutorial about this;
  • ❤️ Staring this repository;
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].