dumpToChannelInfo method

void dumpToChannelInfo(
  1. BuildContext context,
  2. int index,
  3. void back()
)

Implementation

void dumpToChannelInfo(
    BuildContext context, int index, void Function() back) {
  String targetChanelName = listViewDataList[index].name;

  final channelInfoDataMap = <String, Map<String, List<ChannelItemInfo>>>{};

  int type = 0;

  allDataMap.forEach((dayStr, channelMap) {
    var singleDayMap = <String, List<ChannelItemInfo>>{};

    //某天,指定的渠道, 所有数据
    var allMethod = channelMap[targetChanelName];
    if (allMethod?.first.type == 1) {
      type = 1;
      //base channel
      allMethod?.forEach((element) {
        List<ChannelItemInfo> item = [];
        if (singleDayMap.containsKey(element.invokeStackStr)) {
          item = singleDayMap[element.invokeStackStr]!;
        } else {
          singleDayMap[element.invokeStackStr] = item;
        }
        item.add(element);
      });
    } else {
      allMethod?.forEach((element) {
        List<ChannelItemInfo> item = [];
        if (singleDayMap.containsKey(element.methodName)) {
          item = singleDayMap[element.methodName]!;
        } else {
          singleDayMap[element.methodName] = item;
        }
        item.add(element);
      });
    }
    channelInfoDataMap[dayStr] = singleDayMap;
  });
  // print("method $channelInfoDataMap");

  BaseChannelData dataManager =
      MethodDataManager(targetChanelName, channelInfoDataMap);
  if (type == 1) {
    dataManager = StackDataManager(targetChanelName, channelInfoDataMap);
  }
  Navigator.push(
    context,
    MaterialPageRoute(
        builder: (BuildContext context) => BasePage(dataManager)),
  ).then((value) {
    back();
  });
}