I had Fungus Gnats bad. Put 2 inches of perlite or sand on the soil so they cant lay more eggs... I first used Mosquito dunks to get them pissed off, and put yellow sticky traps everywhere so the flying ones get stuck. The next week i used Azatrol or Azamax, 1.5 tablespoons in 1 gallon of water, and poured 1 pint per gallon of soil, this kills the eggs/larvae. I repeated this 7 days later, and they were GONE. The larvae are what cause all the damage. During this whole process when you water your plants with nutes or RO, water from the bottom of the pot/from the drip tray, that way the top gets dried out and only azatrol gets poured from the top down..
I recommend Azatrol for ALL pests, it just kills everything, and its OMRI compliant. It is toxic stuff even though its organic. I've got my whole arm/hands in a bucket of it and got "chicken pox" looking marks on my arms for a day. I've also breathed its fumes for a while and my tounge tingled and the tip felt numb... I've done this several times and it has not killed me, but it did cause a reaction so wear gloves and a mask, or put a shirt over your nose, etc...
I also used "GoGnats" product, and mixed it with water and used as an "area spray" so they gnats would keep flying around instead of landing on something. That made them more likely to get stuck on the traps... Pests take a multi pronged approach, especially once their eggs have been laid. Once you see several of them, hit the soil with a drench and it will take the lifecycle out...