Strictly speaking % climb gradient = ROC/Ground Speed.
But for small climb angles in still air it is close enough to say that it is ROC/TAS
For this type of question it is also close enough to say that
% climb = 100 x Sin Climb angle.
Sin Climb angle = (Thrust - Drag) /weight
So assuming that thrust is constant ( which it is for a jet), for best climb angle (and best % climb) we need the speed that gives minimum drag. This is Vmd.
Deploying flaps increases drag, so it decreases best climb angle and best % climb.
For a jet best climb angle occurs at Vmd and for a prop it occurs at about Vmp. Both of these speeds decrease with deployment of flaps.
So deploying flaps decreases both the best % climb and the speed for best % climb.