vmEmptyView<T extends BaseViewModel<BaseModel, BaseEntity>> function

Widget vmEmptyView<T extends BaseViewModel<BaseModel, BaseEntity>>({
  1. required dynamic builder(
    1. T vm
    ),
  2. bool isEmpty(
    1. T vm
    )?,
  3. Widget? nullChild,
})

Implementation

Widget vmEmptyView<T extends BaseViewModel>(
    {required Function(T vm) builder,
    bool Function(T vm)? isEmpty,
    Widget? nullChild}) {
  return Consumer<T>(
    builder: (_, vm, __) {
//      LogUtil.printLog(vm.empty);
      bool isNull = isEmpty != null ? isEmpty(vm) : vm.empty;
      return isNull
          ? nullChild ?? ViewStateEmptyWidget(onTap: () => vm.viewRefresh())
          : builder(vm);
    },
  );
}