PurposeThis study examines fluid flow within a rectangular porous medium bounded by walls capable of expansion or contraction. It focuses on a non-Newtonian fluid with Casson characteristics, incompressibility, and electrical conductivity, demonstrating temperature-dependent impacts on viscosity.Design/methodology/approachThe flow is two-dimensional, unsteady, and laminar, influenced by a small electromagnetic force and electrical conductivity. The Hybrid Analytical and Numerical Method (HAN method) resolves the constitutive differential equations.FindingsThe fluid’s velocity is influenced by the Casson parameter, viscosity variation parameter, and resistive force, while the fluid’s temperature is affected by the radiation parameter, Prandtl number, and power-law index. Increasing the Casson parameter from 0.1 to 50 results in a 4.699% increase in maximum fluid velocity and a 0.123% increase in average velocity. Viscosity variation from 0 to 15 decreases average velocity by 1.42%. Wall expansion (a from −4 to 4) increases maximum velocity by 19.07% and average velocity by 1.09%. The average fluid temperature increases by 100.92% with wall expansion and decreases by 51.47% with a Prandtl number change from 0 to 7.Originality/valueUnderstanding fluid dynamics in various environments is crucial for engineering and natural systems. This research emphasizes the critical role of wall movements in fluid dynamics and offers valuable insights for designing systems requiring fluid flow and heat transfer. The study presents new findings on heat transfer and fluid flow in a rectangular channel with two parallel, porous walls capable of expansion and contraction, which have not been previously reported.