buildBody method

Widget buildBody(
  1. BuildContext context,
  2. DashboardNotifier provider
)

Implementation

Widget buildBody(BuildContext context, DashboardNotifier provider) {
  if (provider.getAllResponsesState == RequestState.loading) {
    return const Center(
      child: CircularProgressIndicator(),
    );
  } else if (provider.getAllResponses.isEmpty) {
    return const Center(
      child: Text('No Http Activities'),
    );
  } else {
    return ListView.builder(
      itemCount: provider.isSearch
          ? provider.activityFromSearch.length
          : provider.getAllResponses.length,
      itemBuilder: (context, index) {
        var data = provider.isSearch
            ? provider.activityFromSearch[index]
            : provider.getAllResponses[index];
        return InkWell(
          onTap: () {
            Navigator.push<void>(
              context,
              MaterialPageRoute(
                builder: (context) => DetailPage(
                  data: data,
                ),
              ),
            );
          },
          child: ItemResponseWidget(data: data),
        );
      },
    );
  }
}