syncRegime method

Widget syncRegime()

Режим одновременной загрузки картинок

Implementation

Widget syncRegime() {
  return controller.obxBase((state) {
    NsgDataItem? imageItem = item;
    if (masterSlaveMode) {
      var slaveName = slaveFieldName;
      if (slaveName.isEmpty) {
        slaveName = NsgDataClient.client.getNewObject(controller.dataType).primaryKeyField;
      }
      if (controller.status.isLoading) {
        return const CircularProgressIndicator();
      }
      imageItem = controller.items.firstWhereOrNull((e) => e[slaveName] == item[masterFieldName]);
    }

    if (controller.lateImageRead && imageItem != null) {
      controller.addImageToQueue(ImageQueueParam(imageItem.id.toString(), fieldName));
    }

    if (imageItem == null || (imageItem[fieldName] as Uint8List).isEmpty) {
      return noImage ??
          SizedBox(
            width: width,
            height: height,
          );
    }
    var data = imageItem[fieldName] as Uint8List;
    if (data.isEmpty) {
      return noImage ??
          SizedBox(
            width: width,
            height: height,
          );
    } else {
      return FadeIn(
        duration: const Duration(milliseconds: 500),
        curve: Curves.easeIn,
        child: Image.memory(
          data,
          width: width,
          height: height,
          color: color,
          fit: fit,
          alignment: alignment,
          repeat: repeat,
          centerSlice: centerSlice,
          isAntiAlias: isAntiAlias,
          filterQuality: filterQuality,
        ),
      );
    }
  }, onLoading: child);
}