Consumer function
Implementation
Widget Consumer({
String? id,
String? store,
List<String>? stores,
Function? builder,
Function? childBuilder,
Function? childNotifierBuilder,
Function? notifierBuilder,
Widget? child,
}) {
// builder requirement
if (builder == null &&
childBuilder == null &&
childNotifierBuilder == null &&
notifierBuilder == null) {
throw Exception('Atleast one builder is required.');
}
// child requirement
if (child == null && (childBuilder != null || childNotifierBuilder != null)) {
throw Exception('No child widget has been provided.');
}
bool isSingle = stores == null ? true : false;
// print('Consumer: ');
// print(isSingle);
return _RxWidget(
id: id,
requestedStores: isSingle ? [store ?? 'default'] : stores,
builder: builder,
childBuilder: childBuilder,
childNotifierBuilder: childNotifierBuilder,
notifierBuilder: notifierBuilder,
child: child,
isSingle: isSingle,
);
}