Showing
1 changed file
with
9 additions
and
0 deletions
| @@ -62,6 +62,15 @@ mixin StateMixin<T> on ListNotifier { | @@ -62,6 +62,15 @@ mixin StateMixin<T> on ListNotifier { | ||
| 62 | refresh(); | 62 | refresh(); | 
| 63 | } | 63 | } | 
| 64 | } | 64 | } | 
| 65 | + | ||
| 66 | + void append(Future<T> Function() body(), {String errorMessage}) { | ||
| 67 | + final compute = body(); | ||
| 68 | + compute().then((newValue) { | ||
| 69 | + change(newValue, status: RxStatus.success()); | ||
| 70 | + }, onError: (err) { | ||
| 71 | + change(state, status: RxStatus.error(errorMessage ?? err.toString())); | ||
| 72 | + }); | ||
| 73 | + } | ||
| 65 | } | 74 | } | 
| 66 | 75 | ||
| 67 | class Value<T> extends ListNotifier | 76 | class Value<T> extends ListNotifier | 
- 
Please register or login to post a comment