Are they fungus gnats, fruit flies, or drain flies?
Correct identification keeps you from treating every flowerpot when the insects are breeding somewhere else.
Fungus gnats
Fungus gnats are small, dark, delicate flies with long legs and antennae. They resemble tiny mosquitoes and tend to walk or make short flights around moist potting mix. Adults may also gather at windows and lights.
Fruit flies
Fruit flies are usually tan to brown with a rounder body. They gather around ripe produce, recycling, sugary residue, and fermenting material. Treating houseplant soil will not solve a fruit-fly source in the kitchen.
Drain flies
Drain flies look fuzzy or moth-like and rest with broad wings held over the body. They breed in organic buildup inside drains and other persistently wet plumbing areas.
To test a suspicious plant, place a yellow sticky card just above the soil and watch for activity after watering. You can also lay a thin raw potato slice on the mix for a few days. Fungus gnat larvae may move to the underside of the slice, where they look like translucent worms with dark heads.