xStreambuilder method

StreamBuilder xStreambuilder(
  1. Widget builder(
    1. BuildContext,
    2. List<XDataModel>?
    )
)

Implementation

StreamBuilder xStreambuilder(
    Widget Function(BuildContext, List<XDataModel>?) builder) {
  return StreamBuilder(
    stream: database().snapshots(),
    builder: (context, AsyncSnapshot snapshot) {
      List? data = snapshot.hasData ? snapshot.data.docs : null;
      List<XData>? dataSet;
      if (data != null) {
        dataSet = data.map((e) => utils.document(e, fields)).toList();
      } else {
        dataSet = null;
      }
      return builder(context, dataSet);
    },
  );
}