load method

Future<T?> load({
  1. bool silent = false,
})

Loads fresh data.

When silent is true, existing data stays visible and the status is not changed to loading. This is useful for background refreshes.

Implementation

Future<T?> load({bool silent = false}) async {
  if (!silent) {
    state.value = snapshot.copyWith(
      status: ResourceStatus.loading,
      clearError: true,
    );
  }

  try {
    final loaded = await loader();
    setData(loaded);
    return loaded;
  } catch (error) {
    setError(error);
    return null;
  }
}