-
-
Save hasanyatar/c54747392b7a736e13d078e25e94f593 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static List<CameraDescription> _cameras = []; | |
CameraController? _controller; | |
Future _startLiveFeed() async { | |
final camera = _cameras[_cameraIndex]; | |
_controller = CameraController( | |
camera, | |
// Set to ResolutionPreset.high. Do NOT set it to ResolutionPreset.max because for some phones does NOT work. | |
ResolutionPreset.high, | |
enableAudio: false, | |
imageFormatGroup: Platform.isAndroid | |
? ImageFormatGroup.nv21 | |
: ImageFormatGroup.bgra8888, | |
); | |
_controller?.initialize().then((_) { | |
if (!mounted) { | |
return; | |
} | |
_controller?.getMinZoomLevel().then((value) { | |
_currentZoomLevel = value; | |
_minAvailableZoom = value; | |
}); | |
_controller?.getMaxZoomLevel().then((value) { | |
_maxAvailableZoom = value; | |
}); | |
_currentExposureOffset = 0.0; | |
_controller?.getMinExposureOffset().then((value) { | |
_minAvailableExposureOffset = value; | |
}); | |
_controller?.getMaxExposureOffset().then((value) { | |
_maxAvailableExposureOffset = value; | |
}); | |
_controller?.startImageStream(_processCameraImage).then((value) { | |
if (widget.onCameraFeedReady != null) { | |
widget.onCameraFeedReady!(); | |
} | |
if (widget.onCameraLensDirectionChanged != null) { | |
widget.onCameraLensDirectionChanged!(camera.lensDirection); | |
} | |
}); | |
setState(() {}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment