We present some solutions in Friedmann–Lemaître–Robertson–Walker (FLRW) spacetime in the modified theory of gravity with a general Gauss–Bonnet (GB) term f(G) and R2 including an ideal fluid. We present evolution of the universe introducing an ansatz without a prior choice of f(G) in one approach, while in other class of model, the solutions are obtained assuming few simple forms of f(G). Some of the solutions show early inflationary expansion, further in one solution the fluctuation of the deceleration parameter q is evident at the end of inflation. In all cases, late-time transition to accelerating universe at redshift z [Formula: see text] 0.7 is realizable.