LScopedAsyncView<T>.put constructor

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

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

Implementation

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