Flashing and other visual oddities are common as we age. You are young for this to happen, but it does sometimes start even in folks your age. Have you heard of PVD (Posterior Vitreous Detachment)? You can google it and find tons of info, but in case you haven't, here's a copy/paste of some representative info:
PVD is typically a normal age related change that occurs at some point in nearly every eye as it ages. .......As the vitreous ages naturally throughout life, its collagen protein structure slowly degenerates and becomes more fluid-like and less gel-like. The vitreous gel/fluid is encased in a loose sack-like material which clings to the retina. A posterior vitreous detachment (PVD) occurs when this sack like material separates from the retina. Typically when this occurs one notices intermittent flashing lights, new floaters, cobwebs and perhaps a shower of black dots.
This is generally more noticeable at night or in the dark and can sometimes become more intense with eye movement. Some people have prominent symptoms while others notice hardly anything at all.
Ok, so that's pretty much what info you will find about PVD just about anywhere you look. To clarify further...yours could just be starting early (it is possible in folks your age), or if you have had any jarring movements of the head, that could have initiated it early. Just because a person has PVD early does not mean their eyes are unhealthy.
I will ask you this, did the optometrist you went to do a scleral depression during your eye exam? This is where they place a tool in various places on your eyelid areas, then push in in-between your eyeball and your eye socket. They move your eyeball around this way while they look at your retina, and they can do a more thorough exam that way. You said optometrist, but I hope you meant ophthalmologist. They are better trained for this sort of thing.
I have learned all of this because I had the same symptoms, saw an ophthalmologist, & was diagnosed with PVD AND lattice degeneration (also kind of common). I was referred to a retina specialist who explained a lot to me and I was told to watch for a black curtain coming across my vision (symptoms of a detached retina). I never had the curtain, but about 7 weeks later at my follow up visit, I had a torn retina (not detached tho). It was promptly repaired. It is going on three months now since the repair and I have a few blurries & floaters here and there, but the flashes have subsided greatly. Oh, and my follow up with the ophthalmologist after the retina repair showed great healing and no more issues.
Ok, that's about as thorough as I can be, as I am not an ophthalmologist. I would suggest you see one if you haven't. If the one you saw was indeed an ophthalmologist, and if they did a scleral depression during your exam, then things are probably ok. Until the vitreous is fully detached you will see the flashes. It's just part of life. It freaks some people out, but it rarely leads to anything serious. Hope this helps!