It is your decision if you want to put in a flexible working application or leave and try something else. It would depend on when you are due back to work and how quickly your employer considers your request (they can take up to three months legally), but most companies would try and resolve this before you are back from maternity leave. Plus if they reject your application you then will have to go through an appeal.
If the new role is willing to allow you to work flexibly it may be worth going for it. It sounds like you have been treated unfairly, but as you haven’t raised the issues formally before now, the only thing would be for you to go back and if further issues arise then follow a grievance route (you could then also bring up past issues).