It may have been caused by a app you installed it might be interfering with your Camera and flashlight. Try cleaning Cache of your camera and device. Try running device in Safe mode and see if the same issue occurs. If even in safe mode issue occurs try resetting your device and see if it fixes it.
Hate to say this but the 7 series phones were buggy. I'm on the note 9 now but had the s7 edge for 3 years. Do device maintenance/ clear cache and restart. Make sure your not In power saving. Try from there. I know I had this issue once or twice but cant remember exactly what fixed.
Hope this helps