If we Consider a point charge of a Q coulombs of positive electricity situated at the center of a sphere of a radius r metres, the field strength at any point on the surface is given by

Refer to below fig.

The electrostatic flux density D can be defined as the number of the lines of electrostatic flux per unit area of normal cross section.
D = ε ε0 E
and the total electrostatic flux is given by-
Φ = D * 4 π r2 = ε ε0 Q * 4 π r2 / 4 π ε ε0r2 = Q
Even when we imagine a closed surface of any shape, instead of sphere enclosing charge Q, the flux across this surface is also Q.
Gauss’s Law states that “If charge Q is enclosed within a surface, the total flux crossing the surface is Q whatever may be distribution of charge enclosed”. It is assumed that the medium is homogeneous.