I am learning valuation rings from Matsumura’s Commutative Ring Theory book. There is an exercise that characterizes Prüfer domains among integral domains. Let $A$ be an integral domain. The exercise asks us to prove the equivalence of two conditions on $A$:
(1) The localization $A_m$ at any maximal ideal $m$ of $A$ is a valuation ring.
(2) Every $A$-module is flat if and only if it is torsion-free.
I managed to show (1) implies (2). But for (2) implying (1), I am stuck. I have tried to use the fact that the localization $A_m$ at any maximal ideal $m$ of $A$ is a flat $A$-module, and by (2), it is thus torsion-free. And I tried to use the fact that the field of fractions of $A$ is the same as that of each $A_m$ to derive (1). But I failed. Could somebody help me with the implication (2) implies (1)?