We present the solution of the weak noise theory (WNT) for the Kardar-Parisi-Zhang equation in one dimension at short time for flat initial condition (IC). The non-linear hydrodynamic equations of the WNT are solved analytically through a connexion to the Zakharov-Shabat (ZS) system using its classical integrability. This approach is based on a recently developed Fredholm determinant framework previously applied to the droplet IC. The flat IC provides the case for a non-vanishing boundary condition of the ZS system and yields a richer solitonic structure comprising the appearance of multiple branches of the Lambert function. As a byproduct, we obtain the explicit solution of the WNT for the Brownian IC, which undergoes a dynamical phase transition. We elucidate its mechanism by showing that the related spontaneous breaking of the spatial symmetry arises from the interplay between two solitons with different rapidities.