Hi Sarah –
Hmm, let me guess… was it Miracle Gro Potting Soil?
Fungus gnats are a common pest of plants grown indoors, especially where humidity and moisture are high. Now that you’ve had a problem with them you will notice them flying around most nurseries and garden stores. To combat them you will need to go after both the larvae (in the soil) and the egg laying adults. We typically recommend you top dress houseplants with Beneficial Nematodes to destroy the larvae stage and Yellow Sticky Traps placed horizontally at the soil surface to capture large numbers of adults. Here’s a link that will help:
https://www.planetnatural.com/pest-problem-solver/houseplant-pests/fungus-gnat-control/
Good luck!