We introduce and study two classes of Hubbard models with magnetic flux or with spin-orbit coupling, which have a flat lowest band separated from other bands by a non-zero gap. We study the Chern number of the flat bands, and find that it is zero for the first class but can be non-trivial in the second. We also prove that the introduction of on-site Coulomb repulsion leads to ferromagnetism in both the classes.