Consider what is causing the flies to gather. Maybe your garbage pickup can needs cleaning?
Maybe it's your neighbors? Maybe your dog?
My flies are from my horses. It is stinky but those jars with fly attractant DO work and they are cheap. I even put broken bricks in them so that windy storms won't blow them off of my canoe and my Rubbermaid plastic garden shed, where they are now practically black with those nasty critters AND some moths, btw.
You could purchase Fly Predators at $24.00/month. They are the reason that We are not covered with flies! But I pay about $135.00/season for them. They are sterile, so we have to keep buying more, from April-October.
I also buy 50 pound feed through blocks, $13.00/each, so far they have eaten through 2, 1 is halfway gone, so that my horses help kill their flies, too.
ALSO, keep ALL grasses mowed. Flys rest on grass and weeds and you encourage them. Flowers don't seem to do that, so your sunflowers and cosmos won't contribute to this problem.
Fly season/gardening season runs me sometimes close . $300.00, when you add the fly spray on for the horses, too.
When my can is stinky I pour in some Dawn and put about 8 inches of water in it on a hot day, let it sit, then just dump the contents on the grass, and let it dry out. It stays smelling nice for a good while.
AND, if you think your kitchen garbage bag needs it, Double bag.,