honeycomb_flutter 0.8.1+1 copy "honeycomb_flutter: ^0.8.1+1" to clipboard
honeycomb_flutter: ^0.8.1+1 copied to clipboard

discontinuedreplaced by: vessel_flutter

honeycomb for Flutter

Honeycomb for Flutter

For more information about DI itself see honeycomb

Getting started #

Wrap your app in ProviderScope widget:

void main() {
  runApp(
    ProviderScope(child: App())
  );
}

Read your providers with of extension method:

GestureDetector(
  onTap: () => myProvider.of(context).doSomething()
  child: ...
);

Each ProviderScope introduces new ProviderContainer, which becomes child of the previous container. When ProviderScope widget disposes, it disposes ProviderContainer with it.

Overriding and scoping #

It's possible to override provider with another one:

ProviderScope(
  overrides: [
    myProvider.overrideWith(anotherProvider),
  ],
  child: ...
)

Or just scope it:

ProviderScope(
  overrides: [
    myProvider.scope(),
  ],
  child: ...
)

Pass parent #

ProviderScope takes its parent from the BuildContext. But you could override it with parent constructor parameter.

It could be useful with dialogs:

ProviderScope(
  overrides: [myVmProvider.scoped()]
  child: Builder(
    builder: (context) => GestureDetector(
      onTap: () {
        final container = UncontrolledProviderScope.of(context);
        showAlertDialog(
          builder: (context) => ProviderScope(
            parent: container,
            child: ...
          )
        )
      }, 
      child: ...
    )
  )
)

Now your dialog will receive all scoped providers from the parent screen.

1
likes
140
points
19
downloads

Publisher

unverified uploader

Weekly Downloads

honeycomb for Flutter

Documentation

API reference

License

MIT (license)

Dependencies

collection, flutter, honeycomb, meta

More

Packages that depend on honeycomb_flutter