Some soil could be kept in a separate container with a screen that doesn't allow fungus gnats to leave or enter.
This soil once free of fungus gnats could be used to inoculate the pots again.
In theory, that might work...but in practice, imo one huge PIA. Especially since I have seen FGs go dormant for months, then--for no reason, suddenly appear with great gusto...like a bear waking up from hibernation.