Flag codes have received a lot of attention due to its application in random network coding. In 2021, Alonso-González et al. constructed optimal \((n,{\mathcal {A}})_{q}\) -Optimum distance flag codes (ODFC) for \({\mathcal {A}}\subseteq \{1,2,\ldots ,k,n-k,\ldots ,n-1\}\) with \(k\in {\mathcal {A}}\) and \(k\mid n\) . In this paper, we introduce a new construction of \((n,{\mathcal {A}})_q\) -ODFCs by maximum rank-metric codes, and prove that there is an \((n,{\mathcal {A}})_{q}\) -ODFC of size \(\frac{q^n-q^{k+r}}{q^k-1}+1\) for any \({\mathcal {A}}\subseteq \{1,2,\ldots ,k,n-k,\ldots ,n-1\}\) with \({\mathcal {A}}\cap \{k,n-k\}\ne \emptyset \) , where \(r\equiv n\pmod k\) and \(0\le r<k\) . Furthermore, when \(k>\frac{q^r-1}{q-1}\) , this \((n,{\mathcal {A}})_q\) -ODFC is optimal. Specially, when \(r=0\) , Alonso-González et al.’s result is also obtained. We also give a characterization of almost optimum distance flag codes, and construct a family of optimal almost optimum flag distance codes.