buildWithDates method

  1. @override
Widget buildWithDates(
  1. Widget itemBuilder(
    1. RewardsModel item
    ),
  2. Widget dateBuilder(
    1. String date
    ), {
  3. CrossAxisAlignment dateCrossAxis = CrossAxisAlignment.start,
  4. MainAxisAlignment dateMainAxis = MainAxisAlignment.start,
})
override

Implementation

@override
Widget buildWithDates(
  Widget Function(RewardsModel item) itemBuilder,
  Widget Function(String date) dateBuilder, {
  CrossAxisAlignment dateCrossAxis = CrossAxisAlignment.start,
  MainAxisAlignment dateMainAxis = MainAxisAlignment.start,
}) {
  return rewardProviderGrouped(
    onBuild: (value) {
      if (value == null) {
        return Text("No Data");
      }
      return ListView.builder(
        itemBuilder: (context, index) {
          final currentDate = value.dates[index];
          return Column(
            crossAxisAlignment: dateCrossAxis,
            mainAxisAlignment: dateMainAxis,
            children: [
              dateBuilder(value.dates[index]),
              ListView.builder(
                shrinkWrap: true,
                physics: NeverScrollableScrollPhysics(),
                itemCount: value.rewards[currentDate]?.length ?? 0,
                itemBuilder: (context, index) {
                  final reward = (value.rewards[currentDate] ?? [])[index];
                  return itemBuilder(reward);
                },
              ),
            ],
          );
        },
        itemCount: value.dates.length,
      );
    },
  );
}