withImageAutoConfiguration<T> function

T withImageAutoConfiguration<T>({
  1. required ImageAutoMode mode,
  2. TerminalCapabilities? capabilities,
  3. int? cellPixelWidth,
  4. int? cellPixelHeight,
  5. required T callback(),
})

Implementation

T withImageAutoConfiguration<T>({
  required ImageAutoMode mode,
  TerminalCapabilities? capabilities,
  int? cellPixelWidth,
  int? cellPixelHeight,
  required T Function() callback,
}) {
  final sameMode = _currentImageAutoMode == mode;
  final sameCapabilities =
      capabilities == null ||
      identical(_currentImageCapabilities, capabilities);
  final sameCellPixelWidth =
      cellPixelWidth == null || cellPixelWidth == _currentImageCellPixelWidth;
  final sameCellPixelHeight =
      cellPixelHeight == null ||
      cellPixelHeight == _currentImageCellPixelHeight;
  if (sameMode &&
      sameCapabilities &&
      sameCellPixelWidth &&
      sameCellPixelHeight) {
    return callback();
  }
  return dart_async.runZoned(
    callback,
    zoneValues: <Object?, Object?>{
      _imageAutoModeZoneKey: mode,
      _imageCapabilitiesZoneKey: ?capabilities,
      if (cellPixelWidth != null) _imageCellPixelWidthZoneKey: cellPixelWidth,
      if (cellPixelHeight != null) _imageCellPixelHeightZoneKey: cellPixelHeight,
    },
  );
}