Answer: Fungus gnats feed and breed in moist potting soil so the best way to get rid of them is to place a barrier between them and the organic debris in your potting soil. Here are a few suggestions:
Temporarily cover the potting soil with foil or plastic wrap (remove to water your plants, then replace it).
Or, place a layer of pebbles or aquarium gravel over the top of the potting soil. It will be dry at all times, even when the soil is moist, and will discourage the feeding and breeding of fungus gnats.
In addition to placing a barrier over the soil surface, you can set a cup with an inch or so of vinegar or wine near your plants. The fungus gnats will be attracted and most will fall in and drown.
It will take 3-4 weeks for you to control the fungus gnats in this manner.
A final suggestion is to purchase a soil drenching chemical product.
Q&A Library Searching Tips