Anisotropic flow of identified particles in Pb--Pb collisions at $\sqrt{s_{\rm NN}} = 5.02$ TeV