We explore the magnetic properties of a two-dimensional Hubbard model on an inhomogeneous square lattice, which provides a platform for tuning the bandwidth of the flat band. In its limit, this inhomogeneous square lattice turns into a Lieb lattice, and it exhibits abundant properties due to the flat band structure at the Fermi level. By using the determinant quantum Monte Carlo simulation, we calculate the spin susceptibility, double occupancy, magnetization, spin structure factor, and effective pairing interaction of the system. It is found that the antiferromagnetic correlation is suppressed by the inhomogeneous strength and that the ferromagnetic correlation is enhanced. Both the antiferromagnetic correlation and ferromagnetic correlation are enhanced as the interaction increases. It is also found that the effective $d$-wave pairing interaction is suppressed by the increasing inhomogeneity. In addition, we also study the thermodynamic properties of the inhomogeneous square lattice, and the calculation of specific heat provides good support for our point. Our intensive numerical results provide a rich magnetic phase diagram over both the inhomogeneity and interaction.