In firefighting missions, human firefighters are often exposed to high-risk environments such as intense heat and limited visibility. To address this, firefighting robots can serve as valuable agents for autonomous navigation and flame perception. This paper proposes a novel visual Simultaneous Localization and Mapping (SLAM) framework, Fire SLAM, tailored for firefighting scenarios. The system integrates a flame detection and tracking thread-based on the YOLOv8n network and Kalman filtering-to achieve real-time flame detection, tracking, and 3D localization. By leveraging the detection results, dynamic flame regions are excluded from the SLAM front-end, allowing static features to be used for robust pose estimation and loop closure. To validate the proposed system, multiple datasets were collected from real-world and simulated fire environments. Experimental results demonstrate that Fire SLAM improves localization accuracy and robustness in fire scenes with flame disturbances, showing promise for autonomous firefighting robot deployment.