We present the charged-particle pseudorapidity density in Pb--Pb collisions at $\sqrt{s_{_{\mathrm{NN}}}}=5.02\,\mathrm{Te\kern-.25exV}$ in centrality classes measured by ALICE. The measurement covers a wide pseudorapidity range from $-3.5$ to $5$, which is sufficient for reliable estimates of the total number of charged particles produced in the collisions. For the most central collisions we find $21\,400\pm 1\,300$ while for the most peripheral we find $230\pm 38$. This corresponds to ani ncrease of $(27\pm4)\%$ over the results ar $\sqrt{s_{_{\mathrm{NN}}}}=2.76\,\mathrm{Te\kern-.25exV}$ previously reported by ALICE. The energy dependence of the total number of charged particles produced in heavy-ion collisions is found to obey a modified power-law like behaviour. The charged-particle pseudorapidity density of the most central collisions is compared to model calculations --- none of which fully describes the measured distribution. We also present an estimate of the rapidity density of charged particles. The width of that distribution is found to exhibit a remarkable proportionality to the beam rapidity, independent of the collision energy from the top SPS to LHC energies.