I have experienced that people have different views on whether strangers should ask before petting an animal in lead. What is the norm on this? Is there any unspoken rule among dog owners?
It's polite to ask.
Some dogs don't mind. Some do. Some are aggressive in particular circumstances. These circumstances may be unpredictable.
Rescue dogs have fairly frequently formed negative associations with particular things. As an example - I know a dog who was absolutely terrified of carrier bags and prams*. If someone holding a carrier bag approached, he would 'go nuts' and whilst it never came to it, would probably be aggressive out of fear. (And he wasn't a small dog either - a GSD/Rottie cross).
But there's a good chance you simply wouldn't consider something innocuous as distressing to a dog, so out of purely good intentions, someone's been attacked by a dog.
No one wants that to happen. It distresses the dog, and if a dog ever bites a human they will be the one coming off worse. (As an owner, the best outcome is the other person understands. The worst is being prosecuted and having the dog destroyed).
So as a matter of courtesy - it's worth asking for explicit consent, especially if you're not 100% sure you would recognise the dog saying 'no thanks'.
* my current dog dislikes beards, hoods and high-vis jackets (and will bark at people). But is generally disgustingly soppy. If someone asks to 'say hello' I'll warn them that she might react if they have these things, and there are no misunderstandings.
I've learned to ask when in any doubt, since I've known folks with assistance animals, who should never be distracted while they're on duty, and I know someone who fosters pups until they're ready for that training and needs cooperation in setting that on/off duty idea. You can usually tell by how the animal is being handed as you approach, if you're paying attention ... but it never hurts to ask. And it's polite in dog terms to let them approach you rather than vice versa.