outputSize method Null safety

  1. @override
Future<Size?> outputSize()

The size in pixels retrieved by the output.

This should be called after setting AND awaiting CameraController.setControllerPreset. Otherwise, this value could return null. A null value indicates the output is using the default size.


Future<Size?> outputSize() async {
  if (_controller.capturePreset == null) return null;
  switch (_controller.capturePreset) {
    case CaptureSessionPreset.preset352x288:
      return const Size(352, 288);
    case CaptureSessionPreset.preset640x480:
      return const Size(640, 480);
    case CaptureSessionPreset.iFrame960x540:
      return const Size(960, 540);
    case CaptureSessionPreset.preset1280x720:
      return const Size(1280, 720);
    case CaptureSessionPreset.preset1920x1080:
      return const Size(1920, 1080);