dependencies_flutter 0.1.5

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new60

pub package

Simple package to ease the use of the dependencies with Flutter leveraging the power of InheritedWidget.

Usage

class SomeRootWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return InjectorWidget.bind(
      bindFunc: (binder) {
        binder
          ..install(MyModule())
          ..bindSingleton("api123", name: "api_key");
      },
      child: SomeWidget()
    );
  }
}

You can also extend BindingInjectorWidget to configure your dependencies:

class MyBinder extends ModuleWidget {
  MyBinder({Key key, @required Widget child}): super(key: key, child: child);
  @override
  void configure(Binder binder) {
    binder
      ..bindSingleton(Object());
  }
}

You can later refer to the injector like any other InheritedWidget.

class SomeWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final injector = InjectorWidget.of(context);
    final apiKey = injector.get(name: "api_key");
    return SomeContainerNeedingTheKey(apiKey);
  }
}

Or using the InjectorWidgetMixin:

class SomeWidget extends StatelessWidget with InjectorWidgetMixin {
  @override
  Widget buildWithInjector(BuildContext context, Injector injector) {
    final object = injector.get<Object>();
    print(object);
    return Container();
  }
}

0.0.1

  • Initial version.

0.0.2

  • Added example.

0.0.3

  • Remove dependencies export.

0.0.4

  • Added InjectorWidgetMixin.

0.0.5

  • Added BindingInjectorWidget.

0.0.6

  • Upgraded to newer dependencies:0.0.5 api.

0.1.0

  • Stable API.

0.1.1

  • Dispose injector when the widget is disposed.

example/example.dart

import 'package:dependencies_flutter/dependencies_flutter.dart';
import 'package:flutter/material.dart';
import 'package:dependencies/dependencies.dart';

class SomeRootWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return InjectorWidget.bind(
        bindFunc: (binder) {
          binder
            ..install(MyModule())
            ..bindSingleton("api123", name: "api_key");
        },
        child: Container(
            child: Container(
              child: SomeWidget(),
            )
        )
    );
  }
}

class MyModule implements Module {
  @override
  void configure(Binder binder) {
    binder
      ..bindSingleton(Object());
  }
}

class SomeWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final injector = InjectorWidget.of(context);
    final apiKey = injector.get(name: "api_key");
    print(apiKey);
    return Container();
  }
}

class SomeOtherWidget extends StatelessWidget with InjectorWidgetMixin {
  @override
  Widget buildWithInjector(BuildContext context, Injector injector) {
    final object = injector.get<Object>();
    print(object);
    return Container();
  }
}

class MyBinder extends ModuleWidget {
  MyBinder({Key key, @required Widget child}): super(key: key, child: child);
  @override
  void configure(Binder binder) {
    binder
      ..bindSingleton(Object());
  }
}

class YetAnotherWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MyBinder(
      child: Container(),
    );
  }

}

Use this package as a library

1. Depend on it

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


dependencies:
  dependencies_flutter: ^0.1.5

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:dependencies_flutter/dependencies_flutter.dart';
  
Version Uploaded Documentation Archive
0.1.5 Nov 14, 2018 Go to the documentation of dependencies_flutter 0.1.5 Download dependencies_flutter 0.1.5 archive
0.1.4 Nov 13, 2018 Go to the documentation of dependencies_flutter 0.1.4 Download dependencies_flutter 0.1.4 archive
0.1.3 Nov 13, 2018 Go to the documentation of dependencies_flutter 0.1.3 Download dependencies_flutter 0.1.3 archive
0.1.2 Nov 4, 2018 Go to the documentation of dependencies_flutter 0.1.2 Download dependencies_flutter 0.1.2 archive
0.1.1 Nov 4, 2018 Go to the documentation of dependencies_flutter 0.1.1 Download dependencies_flutter 0.1.1 archive
0.1.0 Nov 4, 2018 Go to the documentation of dependencies_flutter 0.1.0 Download dependencies_flutter 0.1.0 archive
0.0.6 Oct 31, 2018 Go to the documentation of dependencies_flutter 0.0.6 Download dependencies_flutter 0.0.6 archive
0.0.5 Oct 30, 2018 Go to the documentation of dependencies_flutter 0.0.5 Download dependencies_flutter 0.0.5 archive
0.0.4 Oct 30, 2018 Go to the documentation of dependencies_flutter 0.0.4 Download dependencies_flutter 0.0.4 archive
0.0.3 Oct 30, 2018 Go to the documentation of dependencies_flutter 0.0.3 Download dependencies_flutter 0.0.3 archive

All 12 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
21
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
60
Learn more about scoring.

We analyzed this package on Nov 14, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.6
  • Flutter: 0.11.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
dependencies ^0.1.4 0.1.4
flutter 0.0.0
quiver ^2.0.1 2.0.1
Transitive dependencies
collection 1.14.11
disposables 0.1.2
matcher 0.12.4
meta 1.1.6
path 1.6.2
sky_engine 0.0.99
stack_trace 1.9.3
typed_data 1.1.6
vector_math 2.0.8