A novel three-component supramolecular hydrogel based on riboflavin, melamine and amino acid derivatives were constructed for controlled release of pesticides, Niclosamide derivatives. The formation of hydrogel may be attributed to self-assemble via hydrogen bonding and π–π interaction, which have been researched via scanning electron microscopy (SEM) and Fourier transform infrared (FT-IR) spectra. The rheological experiments showed that the hydrogel materials and drug-loaded hydrogel all demonstrated good mechanical strength and high stability. Further experimental results indicated that the drug-loaded hydrogels show large drug loadings, long-term release time and relatively higher efficiency to anti-cercariae in the water environment.