Firstly, I congratulate you for not doing as others sometimes do which is to avoid the big "scary looking" dog at all costs. All dogs can look very scary at times, some (unfortunately) just always have that look despite being as soft as can be.
However, please, please please ask before petting a stranger's dog. Rarely do dogs enjoy being patted on the head by strangers and it would only take a split second for your child to be severely hurt if that dog reacted badly. Please teach your child that while she needn't be afraid of dogs, they – like some people – do not always want to be touched, or even noticed. She will be protecting herself from potential harm and that is what's important.
As we approached from the opposite direction, I stood to one side with my dog beside the wall: This was done not because he's nasty and I expected trouble, nor was it so my dog could be patted, but because the pavement was narrow and it seemed better to let you by. My dog had no chance to prepare for the little girl who came round the corner and touched him, there are dogs who might not handle this well.
Of course everything turned out fine and your daughter petted the big dog and he didn't mind, but what if next time it doesn't turn out the same way? How awful it would be for your daughter, you, the dog walker and the dog, who would then be classed as vicious...
I know this might seem dramatic but I work hard to ensure that everyone is safe around my dog because he is my responsibility, and though I know him to be a big, soft, cuddly, goofy, hairy thing, he's an animal with extremely sharp teeth with potential to do harm, just like EVERY other dog, however unlikely it may seem.
Please be careful x