I may not be as qualified as some of the older members here to answer, but personally I always retract flaps at touchdown, as well as go full aft on the yoke or stick as soon as I'm far enough under flying speed that there's no danger of a gust getting me airborne again (to be fair, the second may just be a habit that carries over from tailwheel flying).
This goes for both retract and FG aircraft. However, the retracts I fly really have no chance of confusing the flaps and gear. If I thought there was a chance, I would probably leave them. I feel like it helps the braking and controllability a lot, especially in airplanes prone to floating, like the Diamonds.
One other technique I use with mechanical flaps is to slowly retract flaps a few inches off the ground. This is probably not a great practice, to be fair, but in my dad's STOL kit equipped 172B, it will not settle on the ground with flaps in until under 40MPH, and doesn't grip the ground until almost 30. Easing the flaps out on that last few inches makes it much more stable at touchdown. However, that airplane is one I've spent a lot of time in, and it's very quirky. I wouldn't recommend trying it, and I'll probably be railed for admitting to it
Bottom line, as the poster above me said, do what you're comfortable with, do what you've learned. It's okay to develop your own technique, but only after you know the airplane and have reached a high level of comfort with it.