rewardProvider method
Widget
rewardProvider({
- required Widget onBuild(
- List<
RewardsModel> value
- List<
- Widget buildLoading()?,
- Widget buildError()?,
Implementation
Widget rewardProvider({
required Widget Function(List<RewardsModel> value) onBuild,
Widget Function()? buildLoading,
Widget Function()? buildError,
}) {
return FutureBuilder<List<RewardsModel>>(
future: RewardHelper.fetchRewardsNormal(),
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 || snapshot.data == null) {
if (buildLoading != null) return buildLoading();
return Center(
child: CircularProgressIndicator(),
);
}
return onBuild(snapshot.data ?? []);
},
);
}