So i have just battled this my self. Had some of those fuckers in the soil that i recently got. It happens and they are a pain but you can control them with a few methods. Sticky traps are a must, it catches the adults and stops them from laying the eggs. Sand stops the adults that you dont catch from laying them. Also yes dry soil can prevent them from living but gnat larva can suspend animation during dry spells and and then start again once the soil is moist and damp, so youll need to kill them as well.
Peroxide was the ticket for me, 3% from the drug store will be fine. Mix 1/2 cup to a gallon of water. Its a mild mix but it will do the trick, it wont fry the roots or kill anything else in the soil other than the larva. I did this for two waterings and it took care of the issue along with the traps and the sand. One thing that i would do is water with the mix, then a normal light water from the bottom of the pots. Place them in a saucer and water the saucer and allow the soil to soak up the water. It keeps the top layer from getting damp under the sand and activating the larva again. Then after that watering hit the top again one last time with the peroxide mix. Should take care of the issue. My plants havent taken any kind of hit at all from this.