The results of a search for direct pair production of top squarks in events with two opposite-charge leptons (electrons or muons) are reported, using $36.1~\hbox {fb}^{-1}$ of integrated luminosity from proton?proton collisions at $\sqrt{s}=13$ TeV collected by the ATLAS detector at the Large Hadron Collider. To cover a range of mass differences between the top squark $\tilde{t}$ and lighter supersymmetric particles, four possible decay modes of the top squark are targeted with dedicated selections: the decay $\tilde{t} \rightarrow b \tilde{\chi }_{1}^{\pm }$ into a b-quark and the lightest chargino with $\tilde{\chi }_{1}^{\pm } \rightarrow W \tilde{\chi }_{1}^{0}$ , the decay $\tilde{t} \rightarrow t \tilde{\chi }_{1}^{0}$ into an on-shell top quark and the lightest neutralino, the three-body decay $\tilde{t} \rightarrow b W \tilde{\chi }_{1}^{0}$ and the four-body decay $\tilde{t} \rightarrow b \ell \nu \tilde{\chi }_{1}^{0}$ . No significant excess of events is observed above the Standard Model background for any selection, and limits on top squarks are set as a function of the $\tilde{t}$ and $\tilde{\chi }_{1}^{0}$ masses. The results exclude at 95% confidence level $\tilde{t}$ masses up to about 720 GeV, extending the exclusion region of supersymmetric parameter space covered by previous