A perfect absorber consisting of an array of polymer cylinders with cavities is proposed. The toroidal dipole resonance is excited when a linearly polarized plane wave is incident on the top surface of the array. The absorber demonstrates an absorption peak with a remarkable absorbance of 99.4%, accompanied by an ultra-narrow full width at half maximum (FWHM) of 0.18 nm. The quality factor (Q) reaches as high as 7571. Furthermore, the proposed absorber maintains an absorbance exceeding 90% over an incident angle range of 0° to 18°, showcasing excellent angular stability. When employed as a refractive index gas sensor, the absorber exhibits a high gas sensitivity of 1021.43 nm/RIU, a high figure of merit (FOM) of 5675 RIU-1, and a low detection limit (DL) of 8.81 × 10-6 RIU. These outstanding characteristics highlight the significant potential of the proposed absorber for applications in gas sensing and environmental monitoring. Moreover, this research provides a valuable reference scheme for designing polymer-based metasurface narrowband absorbers.