How can I prevent calf cramps when swimming?

“Firstly, you should ensure that you eat properly before swimming, not too much, and you should also avoid fasting to avoid cramps from cold water stimulation after hypoglycaemia.
Secondly, you should also do a good warm-up exercise before swimming, such as leg stretching and upper limb stretching.
Then you should also ensure that you exercise in moderation, as cramps are also likely to occur if you swim too long and too fast.”