Fungus gnats are, as the name suggests, attracted by fungi.
Soil works by releasing nutrients when it decomposes, mainly by fungi.
Therefore, you have to get rid of soil as a substrate. No soil, no problems.
There are quite a few soil-less media out there.
The most common one is coco coir.
It behaves quite similar to soil, so you don't have to change anything regarding how you water etc.
You have to pre-treat it sometimes however, or else it might harm your plant. If you don't wanna do that, get hydroponic grade and not the cheap one.

My substrate of choice is LECA (expaned clay balls). The method is called "semi-hydro". The inner pot is submerged 1/3 into nutrient solution, and you have a water level indicator that tells you when to water again.



Pon is also popular. It behaves like a mix of the two above.
It's a mix of zeolith, pumice and lava rock.

The said substrates are all inert however, so they don't absorb or contain any nutrients. You have to use synthetic, full spectrum fertilizer for hydroponics.
Additional, I have a few carnivorous plants around. Pinguicula are my favourite, since they are super easy to take care of.
Nepenthes are also amazing if you have the light and RO water for them :)





