📜  如何使事件相机颤动 - 无论代码示例

📅  最后修改于: 2022-03-11 15:00:26.006000             🧑  作者: Mango

代码示例1
void onNewCameraSelected(CameraDescription cameraDescription) async {
if (controller != null) {
  await controller.dispose();
}
controller = CameraController(
  cameraDescription,
  ResolutionPreset.high,
  enableAudio: enableAudio,
);

// If the controller is updated then update the UI.
controller.addListener(() {
  if (mounted) setState(() {});
  if (controller.value.hasError) {
    showInSnackBar('Camera error ${controller.value.errorDescription}');
  }
});

try {
  await controller.initialize();
} on CameraException catch (e) {
  _showCameraException(e);
}

if (mounted) {
  setState(() {});
}
}