Fungi is where you will find these flies because that serves as a major food source for their larvae. That would be decaying plant material, animal excrement or fungus, while others feed in rotting wood or under the bark of fallen trees. They can also be found in the nests of birds or squirrels.
Inside your home they can infest the soil of overwatered potted plants and atriums, also where there are water leaks or moisture problems evident in water stains, peeling paint, swelling of walls or wall coverings. Flat roofs are very conducive to moisture problems along with the bottom of birdcages that are not kept frequently cleaned out.
Outside there are multiple areas where you will find them. Mulched areas, especially those areas where the previous year's mulch has not been removed. Accumulations of dead leaves, old firewood piles, compost piles, etc.
These flies are a nuisance pest and they can be an agricultural pest.
For further information, click on the link below.
Courtesy of Washington State University Extension