darin_flutter 0.1.0 copy "darin_flutter: ^0.1.0" to clipboard
darin_flutter: ^0.1.0 copied to clipboard

Flutter inherited widget for Darin scopes.

Flutter

Flutter inherited widget for Darin scopes.

Features #

For features of Darin, and the explanation of the concept, see the main package: Darin

Getting started #

Import the package (published to pub.dev soon):

dependencies:
  darin_flutter:
    git: https://github.com/TamasBarta/darin_flutter.git

Usage #

You can use the Darin inherited widget to pass scopes down the widget tree. Down the tree you can then get objects with their dependencies resolved, and new scopes with new Darin inherited widgets.

// Declare your scopes
final exampleScope = Scope(
  (scope) => scope
    ..factory((scope) => MyFeatureScreen(scope.get()),
);

// Concat all your scopes from all your packages, if you have multiple
compileScopes() => Scope.fromScopes(
      [
        exampleScope,
      ],
    );

// Wrap your application widgets in a `Darin` widget, do you can query
// objects down the tree
class App extends StatelessWidget {
  const App({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Darin(
      scope: compileScopes(),
      // `Builder` is used, so `builderContext` already can be used
      // for widget inheritance, so Darin is already available here
      child: Builder(
        builder: (builderContext) => MaterialApp(
          title: 'Darin Demo',
          ... 
        ),
      ),
    );
  }
}

// And somewhere lower in the widget tree, you can obtain objects,
// or create new scopes.
Widget build(BuidlContext context) {
  return Text(context.darinGet(qualifier: "MyStringTitle"))
}

// Use can use `.of()` style static functions as well instead of
// the extension methods on `BuildContext`.
Widget build(BuidlContext context) {
  return Text(Darin.get(context, qualifier: "MyStringTitle"))
}
1
likes
110
pub points
15%
popularity

Publisher

verified publisherbartatamas.hu

Flutter inherited widget for Darin scopes.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

darin, flutter

More

Packages that depend on darin_flutter