rewardProviderGrouped method

Widget rewardProviderGrouped({
  1. required Widget onBuild(
    1. DatedRewards? value
    ),
  2. Widget buildLoading()?,
  3. Widget buildError()?,
})

Implementation

Widget rewardProviderGrouped({
  required Widget Function(DatedRewards? value) onBuild,
  Widget Function()? buildLoading,
  Widget Function()? buildError,
}) {
  return FutureBuilder<DatedRewards?>(
    future: RewardHelper.fetchRewardsGrouped(),
    initialData: null,
    builder: (context, snapshot) {
      if (snapshot.hasError) {
        if (buildError != null) {
          return Center(
            child: Text("Error Fetching Rewards"),
          );
        }
        return Center(
          child: Text("Error Fetching Rewards"),
        );
      }
      if (!snapshot.hasData) {
        if (buildLoading != null) return buildLoading();
        return Center(
          child: CircularProgressIndicator(),
        );
      }
      return onBuild(snapshot.data);
    },
  );
}