obx method
Implementation
Widget obx(
NotifierBuilder<NsgBaseControllerData?> widget, {
Widget Function(String? error)? onError,
Widget? onLoading,
Widget? onEmpty,
bool needProgressBar = true,
}) {
return Observer(
builder: (_) {
if (status.isLoading) {
if (onLoading != null || needProgressBar) {
return onLoading ?? getDefaultProgressIndicator();
} else {
return widget(NsgBaseController.emptyData);
}
} else if (status.isError) {
return onError != null ? onError(status.errorMessage) : Center(child: Text('A error occurred: ${status.errorMessage}'));
} else if (status.isEmpty) {
return onEmpty ?? const SizedBox.shrink();
}
return widget(value);
},
);
}