Apparence-io / CamerAwesome

📸 Embedding a camera experience within your own app shouldn't be that hard. A flutter plugin to integrate awesome Android / iOS camera experience.
https://ApparenceKit.dev
MIT License
976 stars 256 forks source link

onMediaCaptureEvent is not available in CameraAwesomeBuilder.awesome() #486

Open yash-segnotech opened 4 months ago

yash-segnotech commented 4 months ago

I want to show the captured image on the preview page just after clicking the capture button, but can't find a way to do so on capture button click. Also the AwesomeCaptureButton doesn't have any functions to call on onPressed. class CameraPage extends StatelessWidget { const CameraPage({super.key});

@override Widget build(BuildContext context) { return Scaffold( body: Container( color: Colors.white, child: CameraAwesomeBuilder.awesome( saveConfig: SaveConfig.photo( pathBuilder: (sensors) async { final Directory extDir = await getTemporaryDirectory(); final testDir = await Directory( '${extDir.path}/securitytroops', ).create(recursive: true); if (sensors.length == 1) { final String filePath = '${testDir.path}/${DateTime.now().millisecondsSinceEpoch}.jpg'; print(filePath); return SingleCaptureRequest(filePath, sensors.first); } else { return MultipleCaptureRequest( { for (final sensor in sensors) sensor: '${testDir.path}/${sensor.position == SensorPosition.front ? 'front' : "back"}${DateTime.now().millisecondsSinceEpoch}.jpg', }, ); } }, mirrorFrontCamera: true), sensorConfig: SensorConfig.single( sensor: Sensor.position(SensorPosition.front), flashMode: FlashMode.auto, aspectRatio: CameraAspectRatios.ratio_4_3, zoom: 0.0, ), previewAlignment: Alignment.center, previewFit: CameraPreviewFit.contain, onMediaTap: (mediaCapture) { mediaCapture.captureRequest.when( single: (single) { debugPrint('single: ${single.file?.path}'); Navigator.pop(context, single.file?.path); }, multiple: (multiple) { multiple.fileBySensor.forEach((key, value) { debugPrint('multiple file taken: $key ${value?.path}'); Navigator.pop(context, value?.path); }); }, ); }, topActionsBuilder: (CameraState state) { return AwesomeTopActions( state: state, children: [ AwesomeFlashButton( state: state, onFlashTap: (sensorConfig, flashMode) { final newFlashMode = flashMode == FlashMode.none ? FlashMode.on : flashMode == FlashMode.on ? FlashMode.auto : flashMode == FlashMode.auto ? FlashMode.always : flashMode == FlashMode.always ? FlashMode.none : FlashMode.none; sensorConfig.setFlashMode(newFlashMode); debugPrint('Flash mode changed to: $newFlashMode'); }, ), ], ); }, middleContentBuilder: (state) { return Column( children: [ const Spacer(), AwesomeZoomSelector(state: state), ], ); }, // bottomActionsBuilder: (state) { // return AwesomeBottomActions( // state: state, // left: AwesomeOrientedWidget(child: AwesomeCameraSwitchButton(state: state)), // captureButton: AwesomeCaptureButton(state: state), // ); // }, ), ), ); } }

tungthanh1497 commented 3 months ago

I don't know why but I can not find callback func onMediaCaptureEvent in latest deployed version.

Instead of installing this package like camerawesome: ^2.0.1 I used

camerawesome:
    git:
      url: https://github.com/Apparence-io/CamerAwesome.git
      ref: master

Please note that this is only a temporary method before an official announcement or new version from the developer

temcewen commented 2 months ago

Same issue here, thanks for the solution @tungthanh1497