I hate fruit flies! I never really saw any until I started composting without looking much into composting. I just bought a black Dalek style bin and started adding in all of my fruit and veg scraps, along with grass clippings and any prunings I had.
I had a kitchen compost caddy to put the food waste into each mealtime, and when it was full, I emptied it into the compost bin at the end of my small garden.
Remembering back, it must have been the Autumn/Winter when I bought the compost bin and the first summer where I met the fruit flies. They were attracted to my kitchen caddy, which was on my often open kitchen window. The caddy was not locked closed, so there was clear access for the flies. So, I spent my evenings battling, trying to catch and remove the fruit flies.
So, what I have learnt about how to combat this problem now.
1. Bury the fruit and veg
You can bury the food waste that flies are attracted to in the middle of your compost bin, with other material above and to the side.
This approach means getting a bit hands-on with your compost and making sure the food waste is not accessible. It's not easy, as you need a lot of brown non-food waste to cover. There is also no guarantee that you will cover the waste and the flies will not access it!
2. Lasagne approach
Similar to the first solution; however, this is a more organised way of layering your waste.
The idea is that you add your layer of food waste first, and when that is added, you add a layer of brown waste over the top. Brown waste can comprise shredded paper, cardboard, twigs, wood. You will need a good 2-4 inches.
Read my guide on 'Balancing Your Green And Brown Waste In Your Compost'
In practice, you need to keep a stash of brown waste close to your compost bin. I rip up all of the cardboard boxes we get and all of the waste paper we use for the kid's crafts and the cardboard loo rolls!
It would be best to have a sealed container for your food waste until you are ready to add a full layer. However, you can add a small amount and cover it with the required brown material.
3. Fully sealed compost bins
Hotbins are fully sealed hot composters that will not let in any unwanted guests. They tend to be on the pricey side. When you consider the standard benefits of a hotbin, like getting compost in just 30-90 days and being able to compost pretty much all food waste and have no fruit flies - it's a justified investment for gardeners and those looking to reduce their food waste heavily.
Bokashi bins are also fully sealed, and you can put all your food waste too. You can read more about Bokashi composting here.