Committed by
GitHub
Merge pull request #745 from eduardoflorence/statemixin-error-message
Provide error for StateMixin obx widget
Showing
1 changed file
with
4 additions
and
2 deletions
@@ -122,13 +122,15 @@ abstract class GetNotifier<T> extends Value<T> with GetLifeCycleBase { | @@ -122,13 +122,15 @@ abstract class GetNotifier<T> extends Value<T> with GetLifeCycleBase { | ||
122 | } | 122 | } |
123 | 123 | ||
124 | extension StateExt<T> on StateMixin<T> { | 124 | extension StateExt<T> on StateMixin<T> { |
125 | - Widget obx(NotifierBuilder<T> widget, {Widget onError, Widget onLoading}) { | 125 | + Widget obx(NotifierBuilder<T> widget, {Widget Function(String error) onError, Widget onLoading}) { |
126 | assert(widget != null); | 126 | assert(widget != null); |
127 | return SimpleBuilder(builder: (_) { | 127 | return SimpleBuilder(builder: (_) { |
128 | if (status.isLoading) { | 128 | if (status.isLoading) { |
129 | return onLoading ?? CircularProgressIndicator(); | 129 | return onLoading ?? CircularProgressIndicator(); |
130 | } else if (status.isError) { | 130 | } else if (status.isError) { |
131 | - return onError ?? Text('A error occured: ${status.errorMessage}'); | 131 | + return onError != null |
132 | + ? onError(status.errorMessage) | ||
133 | + : Text('A error occured: ${status.errorMessage}'); | ||
132 | } else { | 134 | } else { |
133 | return widget(value); | 135 | return widget(value); |
134 | } | 136 | } |
-
Please register or login to post a comment