Flares from the supermassive black hole in our Galaxy, Sagittarius~A$^star$ (Sgr A$^star$), are routinely observed over the last decade or so. Despite numerous observational and theoretical efforts, the nature of such flares still remains poorly understood, although a few phenomenological scenarios have been proposed. In this work, we develop the Yuan et al. (2009) scenario into a magnetohydrodynamic (MHD) model for Sgr A$^star$ flares. This model is analogous with the theory of solar flares and coronal mass ejection in solar physics. In the model, magnetic field loops emerge from the accretion flow onto Sgr A$^star$ and are twisted to form flux ropes because of shear and turbulence. The magnetic energy is also accumulated in this process until a threshold is reached. This then results in a catastrophic evolution of a flux rope with the help of magnetic reconnection in the current sheet. In this catastrophic process, the magnetic energy is partially converted into the energy of non-thermal electrons. We have quantitatively calculated the dynamical evolution of the height, size, and velocity of the flux rope, as well as the magnetic field in the flare regions, and the energy distribution of relativistic electrons in this process. We further calculate the synchrotron radiation from these electrons and compare the obtained light curves with the observed ones. We find that the model can reasonably explain the main observations of near-infrared (NIR) and X-ray flares including their light curves and spectra. It can also potentially explain the frequency-dependent time delay seen in radio flare light curves.