Gnats and aphids' larvae and eggs appear to be a delicacy for bees. Whenever I put plant pots on a sunny balcony during early spring daytime, I have dozens of bees tinkering in the soil. They also very efficiently clean up the soil and help aerate the roots[1]. Bees are the awesomest living species I know!
They need both moisture and oxygen to reproduce, which means they only live in a damp top layer of soil. So leaving the top layer of soil dry prevents them from reproducing. And since fungus gnats are dumb and slow they fly right into the flypaper, removing themselves from the gene pool.
You can also replace the top couple centimeters of soil. You'll still want to keep the soil as dry as possible for a week so any remaining gnats stop laying eggs.
I've had success suppressing them with frequent sprays of neem oil, direct to the soil of the pots. Daily for a week or two to break the life cycle and then weekly or more often to keep the inevitable survivors knocked back and feeling unwelcome.
They're also suckers for a candle left lit in a darkened room.