getSlideDetails static method

List<Widget> getSlideDetails(
  1. GetSlideParam params
)

Function for getting slide details

Implementation

static List<Widget> getSlideDetails(GetSlideParam params) {
  List<Widget> tempSlide = [];
  List<Widget> tempShapes = [];
  List<Widget> slideWidget = [];
  double maxWidth = 600;
  double maxHeight = 450;
  double divisionFactor = 12700;
  if (params.slide.slideLayout != null) {
    for (int j = 0; j < params.slide.slideLayout!.components.length; j++) {
      Map<String, double> maxWidthHeight = {"maxWidth": maxWidth, "maxHeight": maxHeight};
      switch (params.slide.slideLayout!.components[j].runtimeType.toString()) {
        case "PresentationPresetShapes":
          List<Widget> tempGetShapes = showPresetShape(
              params.slide.slideLayout!.components[j], params.slide.clearMap, params.slide.colorSchemes, divisionFactor, maxWidthHeight);
          tempShapes.addAll(tempGetShapes);
          break;
        case "PresentationCustomDiagram":
          List<Widget> tempGetCustomDiagrams = showCustomDiagram(
              params.slide.slideLayout!.components[j], params.slide.clearMap, params.slide.colorSchemes, divisionFactor, maxWidthHeight);
          tempShapes.addAll(tempGetCustomDiagrams);
          break;
        case "PresentationTextBox":
          List<Widget> tempGetTextBoxes = showTextBox(params.slide.slideLayout!.components[j], divisionFactor, maxWidthHeight,
              params.slide.slideLayout, params.slide.clearMap, params.slide.colorSchemes);
          tempShapes.addAll(tempGetTextBoxes);
          break;
      }
      maxWidth = maxWidthHeight["maxWidth"]!;
      maxHeight = maxWidthHeight["maxHeight"]!;
    }

  }
  for (int j = 0; j < params.slide.components.length; j++) {
    Map<String, double> maxWidthHeight = {"maxWidth": maxWidth, "maxHeight": maxHeight};
    switch (params.slide.components[j].runtimeType.toString()) {
      case "PresentationPresetShapes":
        //print(params.slide.fileName);
        List<Widget> tempGetShapes =
            showPresetShape(params.slide.components[j], params.slide.clearMap, params.slide.colorSchemes, divisionFactor, maxWidthHeight);
        tempShapes.addAll(tempGetShapes);
        break;
      case "PresentationCustomDiagram":
        List<Widget> tempGetCustomDiagrams =
            showCustomDiagram(params.slide.components[j], params.slide.clearMap, params.slide.colorSchemes, divisionFactor, maxWidthHeight);
        tempShapes.addAll(tempGetCustomDiagrams);
        break;
      case "PresentationTextBox":
        List<Widget> tempGetTextBoxes = showTextBox(
            params.slide.components[j], divisionFactor, maxWidthHeight, params.slide.slideLayout, params.slide.clearMap, params.slide.colorSchemes);
        tempShapes.addAll(tempGetTextBoxes);
        break;
    }
    maxWidth = maxWidthHeight["maxWidth"]!;
    maxHeight = maxWidthHeight["maxHeight"]!;
  }


  if (tempShapes.isNotEmpty) {
    tempSlide.add(SizedBox(
        height: maxHeight,
        width: maxWidth,
        child: Stack(
          children: tempShapes,
        )));
  }
  if(kIsWeb){
    WebImages? webImage=params.webImages.firstWhereOrNull((img){
      return img.name == params.slide.backgroundImagePath;
    });
    if(webImage!=null) {
      slideWidget.add(SingleChildScrollView(
        scrollDirection: Axis.horizontal,
        child: Container(
          constraints: BoxConstraints(
              minHeight: params.height != null ? params.height!.toDouble() / 914400 : 450,
              minWidth: params.width != null ? params.width!.toDouble() / 914400 : 450),
          decoration: params.slide.backgroundImagePath != ""
              ? BoxDecoration(
            color: Colors.white,
            image: DecorationImage(
              image: MemoryImage(webImage.bytes),
              fit: BoxFit.fill,
            ),
          )
              : const BoxDecoration(
            color: Colors.white,
          ),
          width: maxWidth,
          margin: const EdgeInsets.all(8),
          child: Column(
            children: tempSlide,
          ),
        ),
      ))
      ;
    }
  }else{
  slideWidget.add(SingleChildScrollView(
    scrollDirection: Axis.horizontal,
    child: Container(
      constraints: BoxConstraints(
          minHeight: params.height != null ? params.height!.toDouble() / 914400 : 450,
          minWidth: params.width != null ? params.width!.toDouble() / 914400 : 450),
      decoration: params.slide.backgroundImagePath != ""
          ? BoxDecoration(
              color: Colors.white,
              image: DecorationImage(
                image: FileImage(File(params.slide.backgroundImagePath)),
                fit: BoxFit.fill,
              ),
            )
          : const BoxDecoration(
              color: Colors.white,
            ),
      width: maxWidth,
      margin: const EdgeInsets.all(8),
      child: Column(
        children: tempSlide,
      ),
    ),
  ))
  ;}
  return slideWidget;
}