CameraAwesomeBuilder.awesome constructor

CameraAwesomeBuilder.awesome({
  1. SensorConfig? sensorConfig,
  2. bool enablePhysicalButton = false,
  3. Widget? progressIndicator,
  4. required SaveConfig saveConfig,
  5. dynamic onMediaTap(
    1. MediaCapture
    )?,
  6. OnImageForAnalysis? onImageForAnalysis,
  7. AnalysisConfig? imageAnalysisConfig,
  8. OnPreviewTap onPreviewTapBuilder(
    1. CameraState
    )?,
  9. OnPreviewScale onPreviewScaleBuilder(
    1. CameraState
    )?,
  10. CameraPreviewFit? previewFit,
  11. CameraLayoutBuilder? previewDecoratorBuilder,
  12. AwesomeTheme? theme,
  13. Widget topActionsBuilder(
    1. CameraState state
    )?,
  14. Widget bottomActionsBuilder(
    1. CameraState state
    )?,
  15. Widget middleContentBuilder(
    1. CameraState state
    )?,
  16. EdgeInsets previewPadding = EdgeInsets.zero,
  17. Alignment previewAlignment = Alignment.center,
  18. PictureInPictureConfigBuilder? pictureInPictureConfigBuilder,
  19. AwesomeFilter? defaultFilter,
  20. List<AwesomeFilter>? availableFilters,
  21. OnMediaCaptureEvent? onMediaCaptureEvent,
})

Use the camera with the built-in interface.

You need to provide a SaveConfig to define if you want to take photos, videos or both and where to save them.

You can initiate the camera with a few parameters through the SensorConfig:

  • which sensors to use (front or back)
  • which flashMode to use
  • how much zoom you want (0.0 = no zoom, 1.0 = max zoom)

If you want to customize the UI of the camera, you have several options:

  • use a progressIndicator and define what to do when the preview of the last media taken is tapped thanks to onMediaTap
  • use topActionsBuilder, bottomActionsBuilder, and middleContentBuilder which let you build entirely the UI similarly to how the built-in UI is done. Check AwesomeCameraLayout for more details.
  • build your UI entirely thanks to the custom constructor.

If you want to do image analysis (for AI for instance), you can set the imageAnaysisConfig and listen to the stream of images with onImageForAnalysis.

Implementation

CameraAwesomeBuilder.awesome(
    {SensorConfig? sensorConfig,
    bool enablePhysicalButton = false,
    Widget? progressIndicator,
    required SaveConfig saveConfig,
    Function(MediaCapture)? onMediaTap,
    OnImageForAnalysis? onImageForAnalysis,
    AnalysisConfig? imageAnalysisConfig,
    OnPreviewTap Function(CameraState)? onPreviewTapBuilder,
    OnPreviewScale Function(CameraState)? onPreviewScaleBuilder,
    CameraPreviewFit? previewFit,
    CameraLayoutBuilder? previewDecoratorBuilder,
    AwesomeTheme? theme,
    Widget Function(CameraState state)? topActionsBuilder,
    Widget Function(CameraState state)? bottomActionsBuilder,
    Widget Function(CameraState state)? middleContentBuilder,
    EdgeInsets previewPadding = EdgeInsets.zero,
    Alignment previewAlignment = Alignment.center,
    PictureInPictureConfigBuilder? pictureInPictureConfigBuilder,
    AwesomeFilter? defaultFilter,
    List<AwesomeFilter>? availableFilters,
    OnMediaCaptureEvent? onMediaCaptureEvent})
    : this._(
        sensorConfig: sensorConfig ??
            SensorConfig.single(
              sensor: Sensor.position(SensorPosition.back),
            ),
        enablePhysicalButton: enablePhysicalButton,
        progressIndicator: progressIndicator,
        builder: (cameraModeState, preview) {
          return AwesomeCameraLayout(
            state: cameraModeState,
            onMediaTap: onMediaTap,
            topActions: topActionsBuilder?.call(cameraModeState),
            bottomActions: bottomActionsBuilder?.call(cameraModeState),
            middleContent: middleContentBuilder?.call(cameraModeState),
          );
        },
        saveConfig: saveConfig,
        onMediaTap: onMediaTap,
        onImageForAnalysis: onImageForAnalysis,
        imageAnalysisConfig: imageAnalysisConfig,
        onPreviewTapBuilder: onPreviewTapBuilder,
        onPreviewScaleBuilder: onPreviewScaleBuilder,
        previewFit: previewFit ?? CameraPreviewFit.cover,
        previewDecoratorBuilder: previewDecoratorBuilder,
        theme: theme ?? AwesomeTheme(),
        previewPadding: previewPadding,
        previewAlignment: previewAlignment,
        pictureInPictureConfigBuilder: pictureInPictureConfigBuilder,
        defaultFilter: defaultFilter,
        availableFilters: availableFilters ?? awesomePresetFiltersList,
        onMediaCaptureEvent: onMediaCaptureEvent,
      );