It is true that, we should not forget other heroes of Independence movement though many of them adopted violence. But at the same time you should not undervalue Gandhiji's role.

British left India for three main reasons:

1. The circumstances of the British economy after the war: severe financial crisis while the Labour government tried to establish the Welfare State and to follow an expensive policy of nationalization
2. In 1947 India was on the verge of revolt because of the growing independence movement (Here Gandhiji played major roll)
3. The international situation : the position of Britain in the context of Cold War and the general anti-colonialist attitude throughout the world.