Theory of flare stars