If you have indoor plants chances are you have had a run in (or two) with fungus gnats. They are harmless to us humans but can be a major source of frustration. The larvae can cause severe problems to the plants. They like their environment wet with plenty of rotting organic matter. This makes soil and moisture control the key to defeating the fungus gnat. Using active compost as a potting medium and overwatering the plant is a sure way to promote their number.
Prevention starts with a potting soil that has fully composted organic material. Stay away from active compost for indoor plants. Keep a good eye on soil moisture because too much is not a good thing. The last thing is to keep the top of the soil free of plant material.
If you have a crop of fungus gnats there are plenty of products to spray or dust to cure the problem. However, if you remove and discard the top one inch of soil and replace the soil will an appropriate potting mix the problem will be solved.