The study of the Milky Way is living a golden era thanks to the enormous high-quality datasets delivered by Gaia and space asteroseismic and ground-based spectroscopic surveys. However, the current major challenge to reconstructing the chronology of the Milky Way is the difficulty to derive precise stellar ages for large samples of stars. The colour--magnitude diagram (CMD) fitting technique offers an alternative to individual age determinations to derive the star formation history (SFH) of complex stellar populations. Our aim is to obtain a detailed dynamically evolved SFH (deSFH) of the solar neighbourhood, and the age and metallicity distributions that result from it. We define deSFH as the amount of mass transformed into stars, as a function of time and metallicity, in order to account for the population of stars contained in a particular volume of the MW. We present a new package to derive SFHs from CMD fitting tailored to work with Gaia data, called CMDft.Gaia, and we use it to analyse the CMD of the Gaia Catalogue of Nearby Stars (GCNS), which contains a complete census of the (mostly thin disc) stars currently within 100 pc of the Sun. We present an unprecedentedly detailed view of the evolution of the Milky Way disc at the solar radius.The bulk of star formation started 11--10.5 Gyr ago at metallicity around solar, and continued with a slightly decreasing metallicity trend until 6 Gyr ago. Between 6 and 4 Gyr ago, a notable break in the age--metallicity distribution is observed, with three stellar populations with distinct metallicities (sub-solar, solar, and super-solar), possibly indicating some dramatic event in the life of our Galaxy. Star formation then resumed 4 Gyr ago with a somewhat bursty behaviour, metallicity near solar and average star formation rate higher than in the period before 6 Gyr ago. The derived metallicity distribution closely matches precise spectroscopic data, which also show stellar populations deviating from solar metallicity. Interestingly, our results reveal the presence of intermediate-age populations exhibiting both a metallicity typical of the thick disc, approximately $ M/H and super-solar metallicity. The many tests performed indicate that, with high-precision photometric and distance data such as that provided by Gaia CMDft.Gaia is able to achieve a precision of lesssim 10<!PCT!> and an accuracy better than 6<!PCT!> in the dating of stellar populations, even at old ages. A comparison with independent spectroscopic metallicity information shows that metallicity distributions are also determined with high precision, without imposing any a priori metallicity information in the fitting process. This opens the door to obtaining detailed and robust information on the evolution of the stellar populations of the Milky Way over cosmic time. As an example, we provide in this paper an unprecedentedly detailed view of the age and metallicity distributions of the stars within 100 pc of the Sun.