Jonny Borges
Committed by GitHub

Merge pull request #745 from eduardoflorence/statemixin-error-message

Provide error for StateMixin obx widget
... ... @@ -122,13 +122,15 @@ abstract class GetNotifier<T> extends Value<T> with GetLifeCycleBase {
}
extension StateExt<T> on StateMixin<T> {
Widget obx(NotifierBuilder<T> widget, {Widget onError, Widget onLoading}) {
Widget obx(NotifierBuilder<T> widget, {Widget Function(String error) onError, Widget onLoading}) {
assert(widget != null);
return SimpleBuilder(builder: (_) {
if (status.isLoading) {
return onLoading ?? CircularProgressIndicator();
} else if (status.isError) {
return onError ?? Text('A error occured: ${status.errorMessage}');
return onError != null
? onError(status.errorMessage)
: Text('A error occured: ${status.errorMessage}');
} else {
return widget(value);
}
... ...