That's a tough one, chances are it might be a software issue, I would try the following steps in order to isolate the problem and with each step check if the problem is resolved or not, if not move on to the next step.
- Restart
2. Reset all settings, Go to Settings > General > Transfer or Reset iPhone > Reset.
(All your data is safe but all settings will be reset) Return iPhone settings to their defaults - Apple Support
3. Backup your phone to restore your device. (How to back up your iPhone, iPad, and iPod touch - Apple Support)
4. Restore your iPhone (Restore your iPhone, iPad, or iPod to factory settings - Apple Support)
If the above steps didn't resolve your flickering issue, then it might be a hardware issue and you need to get your device checked by an Apple authorized service provider or Apple store.
This link can locate an AASP or Apple store near you Find Locations - Apple
Hopefully this answers your question.