Your two sounds just like mine! I feel for you!
I actually think that when I first took Scottie to his obedience class, that's where he developed his barking issues with other dogs. Prior to the class, I took him to socialize at dog meet ups, he was fine.
Anyway, when Casie came along she was a quick learner and instantly took to Scottie's habits of barking at other dogs during our walks. I have tried to train them with treats during our walks. The amount of effort required (taking high value treats and stuffing them in my pockets, doing this 3 times a day, holding two leashes, getting poop bags, sometimes needing to hold an umbrella) was a little overwhelming. Eventually I sort of gave up, embarrassingly. Other dog owners always frown at us. But we're known in our neighborhood. Most try to stay away. And most know that I will make all efforts to keep our distance. For example, I will cross the road, turn around, find any alternative route if I see an oncoming dog. Prevention is kind of my only solution.
Though, I have been training them the command "leave it" at home. They love the "leave it" game. I then started using the command during our walks, like when they sniff dirty things. I know they know what it means, so I recently also started using the command as a means to tell them to stop barking,
before they actually start barking. It seems to work sometimes, if I can't them before they go crazy, and while running the other way. Also, possibly because they're a little older now, at 4 years and 2.5 years, they seem to be under a little better control (as opposed to before), but will still bark.