There is ongoing debate about the origin and even the very existence of a high degree of linear polarization of some chromospheric spectral lines observed in solar flares. The standard explanation of these measurements is in terms of the impact polarization caused by non-thermal proton and/or electron beams. In this work, we study the possible role of resonance line polarization due to radiation anisotropy in the inhomogeneous medium of the flare ribbons. We consider a simple two-dimensional model of the flaring chromosphere and we self-consistently solve the non-LTE problem taking into account the role of resonant scattering polarization and of the Hanle effect. Our calculations show that the horizontal plasma inhomogeneities at the boundary of the flare ribbons can lead to a significant radiation anisotropy in the line formation region and, consequently, to a fractional linear polarization of the emergent radiation of the order of several percent. Neglecting the effects of impact polarization, our model can provide a clue for resolving some of the common observational findings, namely: (1) why a high degree of polarization appears mainly at the edges of the flare ribbons; (2) why polarization can also be observed during the gradual phase of a flare; and (3) why polarization is mostly radial or tangential. We conclude that radiation transfer in realistic multi-dimensional models of solar flares needs to be considered as an essential ingredient for understanding the observed spectral line polarization.