darin_flutter

Creator: coderz1093

Last updated:

0 purchases

darin_flutter Image
darin_flutter Images

Languages

Categories

Add to Cart

Description:

darin 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
copied to clipboard
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"))
}
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.