getWidget method Null safety

Widget getWidget(
  1. {required Widget onData(
    1. List<Document>
    ),
  2. required Widget onError(
    1. String
    ),
  3. required Widget onLoading(
      )}
    )

    Implementation

    Widget getWidget({
      required Widget Function(List<Document>) onData,
      required Widget Function(String) onError,
      required Widget Function() onLoading,
    }) {
      return FutureBuilder<IndexSnapshot>(
          future: get(),
          builder: (context, AsyncSnapshot<IndexSnapshot> snapshot) {
            if (snapshot.hasData) {
              if (snapshot.data!.success) {
                return onData(snapshot.data!.docs);
              } else {
                return onError(snapshot.data!.reason);
              }
            }
            return onLoading();
          });
    }