Flavor of cosmic neutrinos preserved by ultralight dark matter