The first few inches of soil should be allowed to dry out regularly, your planters should have a drainage hole, and the soil should be well-draining.
One simple trick to help prevent fungus gnats from laying their eggs is to block their access to the soil. You can do this by putting a shallow layer of pebbles, marbles, shells, aquarium gravel, or other decorative stones on top of the soil.
Sticky traps really do work—not to resolve the underlying issue that allows fungus gnat larvae to thrive in your plants’ soil, of course, but at least to reduce the amount of fungus gnats buzzing around your plants.
There’s nothing a fungus gnat loves more than the sweet, sweet scent of fermenting organic material. As with fruit flies, a homemade vinegar trap can therefore work wonders to reduce the amount of adult specimens flying around.
Spray liberally on the soil and all over the plant. Repeat whenever it’s time to water so you catch the gnats in all their life stages.