It would be great, if our hearts could only fall in love with someone who would be good for us to love. Unfortunately, it is totally possible to fall wildly in love with someone who will only guarantee us heartbreak. When that happens, all you can do is cut your losses and walk away.
You are fully capable of falling very in love again. Try to avoid the heartbreakers that are out there. (Not always easy.) When you buy a used car, you look for all the things that might be wrong with it. No used car is free of defects. Do the same, when shopping for a partner. Assume anyone you meet has flaws. Try not to give your heart away too soon.
There is no sure-fire way to avoid heartbreak. I've been there myself more than once. Looking back, I can see where my life would have been worse, if those relationshios had lasted longer. Never trust your heart to know what is best for you. That's the job of the brain.