The issue can be anywhere, camera or logic board..anything that stops working after some time is particularly difficult to diagnose for obvious reasons. Flashlight is dependent on camera, if camera stops working the led will follow suite. A camera replacement might solve the issue but that’s a pretty expensive part on an iPhone 8..hard to tell what’s the more recommendable path to choose, camera replacement or a microsoldering lab to fix the issue. In the end choice is yours.