Often I see に used with verbs like わかる or できる, such as
私{わたし}の気持ち{きもち}があなたに分かる{わかる}ものか
What is the function of に here? How would that differ from using が for example? I've tried searching it up and I've seen things like it's to avoid a second が and that the noun preceding に has to be a person, but I'm not exactly sure either.