Seeing flashes of light that are not there should always prompt you to see a doctor
because they can be a sign of a serious eye problem. The best type of physician for you to see about this is an ophthalmologist
Seeing flashes of light when you look rapidly in one direction can caused by a phenomenon called retinal detachment. This is where the back part of your eye becomes detached from the rest of the eye. It is rare, but does threaten site in the eye effected. It also normally occurs after trauma and thus, if you have recently hit your head doing something, then this is possible. Other possible causes of flashing lights are migraine headaches. This phenomenon of migraines usually don't occur without the headache portion of it, but migraines are more common than retinal detachment.
Because the sign of flashing lights is a possible sign of retinal detachment, I suggest that you schedule an appointment with an ophthalmologist. The reason for this recommendation is that ophthalmologist's have special equipment in the office which can detect subtle abnormalities in your retina that other doctors
would not be able to see. More than likely, your problem will end up being benign, but you should get checked out.