Short answer
The safest prevention is to never leave dragon fruit or any human food within your dog's reach. Store fruit in closed cabinets or the refrigerator immediately after use. Consistently training a solid "leave it" command is invaluable for moments when something is accidentally dropped. Remember, while the flesh is safe in small amounts, the skin is indigestible and could cause a blockage if a determined dog eats a large piece. A little management goes a long way in avoiding an unnecessary vet visit.
Dragon fruit — Food safety facts
Safe to share · Dogs · full breakdown on the linked food page
The soft flesh is safe in small pieces. The skin and seeds pass through mostly undigested.
The full verdict, portion guidance and serving notes are collected on the Dragon fruit food facts page.