The inflationary epoch and the late time acceleration of the expansion rate of universe can be explained by assuming a gravitationally coupled scalar field. In this article, we propose a new method of finding exact solutions in the background of flat Friedmann-Robertson-Walker (FRW) cosmological models by considering both scalar field and matter where the scalar field potential is a function of the scale factor. Our method provides analytical expressions for equation of state parameter of scalar field, deceleration parameter and Hubble parameter. This method can be applied to various other forms of scalar field potential, to the early radiation dominated epoch and very early scalar field dominated inflationary dynamics. Since the method produces exact analytical expression for $H(a)$ (i.e., H(z) as well), we then constrain the model with currents data sets, which includes-Baryon Acoustic Oscillations, Hubble parameter data and Type 1a Supernova data (Pantheon Dataset). As an extension of the method, we also consider the inverse problem of reconstructing scalar field potential energy by assuming any general analytical expression of scalar field equation of state parameter as a function of scale factor.