There's no magical way or trick to prevent girls from flaking. If I knew it I would sell it on a book and be rich right now. There's no way to prevent that brother, sorry.
HOWEVER, the only way of reducing the chances of flaking is by becoming the man that women want.
Work on improving yourself. Work out, build some hobbies, educate yourself, dress well, look good, smell good, build a social circle.
The more you work on yourself as a man the more valuable you become. The more valuable you become the less likely women will flake on you since you are a hot commodity.
Not only that but once you have your life in check you won't really care much about women flaking. It's when we don't have a good life of our own and have too much time on our hands that flaking kills us. When you spend your free time on video games flaking will hurt. When you spend your free time on hobbies that are improving you then it won't hurt as much.
Another point is that getting women is a number's game. If you are affected by a woman flaking on you then YOU HAVEN'T ASKED OUT ENOUGH WOMEN!
The more women you ask out the more more experience you will get (and more rejections you will get). Rejections won't mean anything at all once you've asked out enough girls. You will delete her # and move on to the next one like if she didn't even exist. Take this as a sign that you still need to ask out A LOT MORE GIRLS if you are affected by flaking.