Gauss's law is valid only on symmetrical structure of object (like as spherical, cylindrical ,plane symmetry) not on charge distributions.
It is valid in charges of any medium.
The electric field is the resultant effect due to all charges.
But the electric flux is only depend on the charge enclosed by the closed surface i.e ϕ=ϵ0Qm.
So the flux of the electric field through a closed surface due to all the charges is equal to the flux due to the charges enclosed by the surface.