QueryState
QueryState describes the current status of your data. It is passed to the builder function in QueryBuilder.
Properties
| Property | Type | Description |
|---|---|---|
status | QueryStatus | High-level status: idle, loading, success, error. |
data | T? | The successfully fetched data. |
error | Object? | Variable containing the error if the request failed. |
dataUpdatedAt | DateTime? | Timestamp of the last successful fetch. |
errorUpdatedAt | DateTime? | Timestamp of the last error. |
Derived Helpers
Fasq provides convenient getters to make checks easier:
isLoading: True if the initial fetch is in progress (no data yet).isFetching: True if any network request is outgoing (including background refreshes).isSuccess: True if the status is success.isError: True if the status is error.
Example: Loading vs Fetching
Understanding the difference is key for good UX.
isLoading: Show a full-screen spinner (loading for the first time).isFetching: Show a small linear indicator at the top (refreshing stale data).
if (state.isLoading) {
return FullScreenSpinner();
}
return Stack(
children: [
if (state.isFetching) TopProgressBar(),
MyDataList(data: state.data),
],
);Last updated on