Which flatworms are you talking about? There are thousands of species.
Convolutriloba retrogemma, the red flatworm common in the hobby has endosymbiotic algae that give it most of their energy. They don't "feed" on anything perse. They do have a toxin that is released when they die though.