Unified theory of inertial granular flows and non-Brownian suspensions