You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I used statemixin and futurize but to trigger onEmpty it doesn't work properly. For Widgets that appear in a successful position, onLoading and onError are running properly but onEmpty is not running properly even with the help of change(GetStatus.empty)... Under what conditions is onEmpty triggered? Let's say I have a List of Model, does onEmpty refer to the length of lists = 0 (.isEmpty)?
To Reproduce
I just followed the futurize tutorial on the youtube channel and realized that onEmpty will not be triggered under any circumstances. https://www.youtube.com/watch?v=5XQkeWy_5Ko
Describe the bug
I used statemixin and futurize but to trigger onEmpty it doesn't work properly. For Widgets that appear in a successful position, onLoading and onError are running properly but onEmpty is not running properly even with the help of change(GetStatus.empty)... Under what conditions is onEmpty triggered? Let's say I have a List of Model, does onEmpty refer to the length of lists = 0 (.isEmpty)?
Futurize (default) method from rx_notifier.dart
Future<void> futurize( Future<T> Function() body, { T? initialData, String? errorMessage, bool useEmpty = true, }) async { final Future<T> Function() compute = body; _value ??= initialData; await compute().then( (T newValue) { if ((newValue == null || newValue._isEmpty()) && useEmpty) { status = GetStatus<T>.loading(); } else { status = GetStatus<T>.success(newValue); } refresh(); }, onError: (Object err) { status = GetStatus<T>.error(errorMessage ?? err.toString()); refresh(); }, ); }
Change to
Future<void> futurize( Future<T> Function() body, { T? initialData, String? errorMessage, }) async { final Future<T> Function() compute = body; _value ??= initialData; await compute().then( (T newValue) { if (newValue == null) { status = GetStatus<T>.loading(); } else { if( newValue!._isEmpty()){ status = GetStatus<T>.empty(); } else { status = GetStatus<T>.success(newValue); } } refresh(); }, onError: (Object err) { status = GetStatus<T>.error(errorMessage ?? err.toString()); refresh(); }, ); }
To Reproduce
I just followed the futurize tutorial on the youtube channel and realized that onEmpty will not be triggered under any circumstances.
https://www.youtube.com/watch?v=5XQkeWy_5Ko
I referenced from the getx issue jonataslaw/getx#2966
Expected behavior
onEmpty will be triggered when the data is retrieved and the data is empty
Screenshots
If applicable, add screenshots to help explain your problem.
Flutter Version:
3.22.0
Refreshed Version:
2.7.0
Describe on which device you found the bug:
IQOO Neo8 Pro, Realme XT, and OPPO F11
The text was updated successfully, but these errors were encountered: