In this paper, we present a simple analytical method for obtaining a nonspreading solution of the time-dependent Schr̈odinger equation, which is given by the Airy function. The solution is derived by imposing a restriction on the phase factor of the ansatz that is taken to solve the differential equation. Considering at first the free particle, we show that nonspreading solutions can also be obtained for a time-dependent linear potential. The method is shown to work in both one and two dimensions, and can be easily extended if required. The applicability of the method is discussed in relation to the nonlinear case. ; Comment: 6 pages, 1 figure