renderStreamsGrid function

List<Widget> renderStreamsGrid(
  1. EnxController enxController,
  2. RxList<ActiveList> activeTalkerList,
  3. MediaQueryData mediaQueryData,
  4. BuildContext context,
)

Implementation

List<Widget> renderStreamsGrid(
    EnxController enxController,
    RxList<ActiveList> activeTalkerList,
    MediaQueryData mediaQueryData,
    BuildContext context) {
  List<Widget> streamsExpanded = [];
  print("talkerList12:${activeTalkerList.value.length}");

  streamsExpanded.addAll(activeTalkerList
      .map(
        (entry) => Expanded(
          child: GestureDetector(
              onLongPress: (){
                if( enxController.isLongPressEnable){
                     enxController.streamId.value=entry.streamId!;
                     enxController.activeTalker.value=entry;
                     activeTalkerList.remove(entry);
                     enxController.isFullScreen.value=true;
                     enxController.activeTalkerList.remove(entry);
                     enxController.activeTalkerList.refresh();
                     enxController.annotationShare();



                   }

              },
            child: Padding(
              padding: const EdgeInsets.all(1.0),
              child: kIsWeb?Container(
                decoration:
                BoxDecoration(border: Border.all(color: Colors.grey)),
                child: AspectRatio(aspectRatio: 4/3,
                  child: EnxPlayerWidget(
                    entry.streamId!,
                    local: false,
                    zMediaOverlay: false,
                    height: mediaQueryData.size.height.toInt(),
                    width: mediaQueryData.size.width.toInt(),
                  ),
                ),
              ):
                   Container(
                      decoration:
                          BoxDecoration(border: Border.all(color: Colors.grey)),
                      child: EnxPlayerWidget(
                        entry.streamId!,
                        local: false,
                        zMediaOverlay: false,
                        height: mediaQueryData.size.height.toInt(),
                        width: mediaQueryData.size.width.toInt(),
                      ),
                    )

            ),
          ),
        ),
      )
      .toList());

  if (streamsExpanded.length > 2) {
    List<Widget> rows = [];

    for (var i = 0; i < streamsExpanded.length; i += 2) {
      var chunkEndIndex = i + 2;

      if (streamsExpanded.length < chunkEndIndex) {
        chunkEndIndex = streamsExpanded.length;
      }

      var chunk = streamsExpanded.sublist(i, chunkEndIndex);

      rows.add(
        Expanded(
          child: Align(
            alignment: Alignment.center,
            child:kIsWeb? Column(children: chunk): mediaQueryData.orientation == Orientation.portrait
                ? Row(children: chunk)
                : Column(children: chunk),
          ),
        ),
      );
    }
    return rows;
  }

  return streamsExpanded;
}