We consider a generalized nonlinear Schrödinger equation with dual power law nonlinearities, complex potential, and position- and time-dependent strengths of dispersion and nonlinearities. Using a standard similarity transformation, we obtain the integrability conditions and solitonic solutions of this equation by mapping it to its homogeneous version. Using a modified similarity transformation, where a solution of the homogeneous equation, which we denote as a seed, enters also in the transformation operator, a wider range of exact solutions is obtained including cases with complex potentials. We apply these two transformations to obtain two exact solitonic solutions of the homogeneous nonlinear Schrödinger equation, which are derived here for the first time for a general power of the nonlinearities, namely the flat-top soliton and tanh solution. We discuss and derive explicit solutions to the experimentally relevant cases associated with parabolic and PT-symmetric potentials.