attach method Null safety

  1. @override
Future<void> attach(
  1. covariant CameraController controller

Called when an output should be attached to a CameraController.

This should not need to be called by a user directly unless implementing their own CameraOutput.


Future<void> attach(covariant CameraController controller) async {
  _controller = controller;

  if (includeAudio) {
    final CaptureDevice? audioDevice =
        await CaptureDevice.defaultDeviceWithMediaType(;

    if (audioDevice == null) {
      throw StateError('Could not find an audio device for this device.');


  movieFileOutput = CaptureMovieFileOutput();
  return controller.session.addOutput(movieFileOutput);