Can a capacitor smooth out PWM based dimming?

a simular thread is already made, maybe take a look there. if i understand correctly it would work but the size of those capacitors would be to big to fit a flashlight.