Total flux through a closed surface depends on:

Shape of surface

Charge enclosed only

Medium only

Charge and Medium