CamerAwesome
CamerAwesome copied to clipboard
Initial camera flash mode not set on widget init
Trigger CA plugin's setFlashMode after Flash mode switcher init
It is observed that setting the initial ValueNotifier<CameraFlashes> value does not call the plugin to set a Flash mode. Init method only adds a listener for value changes:
/// inits the Flash mode switcher using [ValueNotifier]
/// Each time user call to switch flashMode we send a call to iOS or Android Plugins
_initFlashModeSwitcher() async {
if (widget.switchFlashMode != null) {
widget.switchFlashMode.addListener(() async {
if (widget.switchFlashMode.value != null && started) {
await CamerawesomePlugin.setFlashMode(widget.switchFlashMode.value);
}
});
}
}
A quick suggestion would be to call the await CamerawesomePlugin.setFlashMode(widget.switchFlashMode.value);
method after attaching the listener or somehow trigger the ValueNotifier so that the mode is set.
/// inits the Flash mode switcher using [ValueNotifier]
/// Each time user call to switch flashMode we send a call to iOS or Android Plugins
_initFlashModeSwitcher() async {
if (widget.switchFlashMode != null) {
widget.switchFlashMode.addListener(() async {
if (widget.switchFlashMode.value != null && started) {
await CamerawesomePlugin.setFlashMode(widget.switchFlashMode.value);
}
});
----> await CamerawesomePlugin.setFlashMode(widget.switchFlashMode.value); <----
}
}
Good one yes. I put this as a bug