LScopedView<T>.put constructor

LScopedView<T>.put(
  1. T create(), {
  2. Key? key,
  3. String? tag,
  4. bool permanent = false,
  5. required Widget builder(
    1. BuildContext context,
    2. T controller
    ),
  6. Widget orElse(
    1. BuildContext context
    )?,
  7. bool autoWatch = true,
  8. String? scopeName,
  9. List<Object?>? args,
})

Shorthand for creating a scope, immediately registering a dependency, and consuming it.

Implementation

factory LScopedView.put(
  T Function() create, {
  Key? key,
  String? tag,
  bool permanent = false,
  required Widget Function(BuildContext context, T controller) builder,
  Widget Function(BuildContext context)? orElse,
  bool autoWatch = true,
  String? scopeName,
  List<Object?>? args,
}) {
  return LScopedView<T>(
    key: key,
    scopeName: scopeName,
    args: args,
    dependencyFactory: (s) {
      s.put<T>(create, tag: tag, permanent: permanent);
    },
    resolver: (context) => context.levit.findOrNull<T>(tag: tag),
    builder: builder,
    orElse: orElse,
    autoWatch: autoWatch,
  );
}