I am near certain that if I were 40 years younger I'd have been ADHD diagnosed. So I can easily believe it's a distraction / concentration mechanism, for me at least.
I suspect the same, am also a rabid note-taker, and rarely revisit my notes. Writing is a means by which I build houses of cards in my head.
Last year I tried some Ritalin I'd been given so I could understand the effect. What I found was that it gives me a sensation that is similar to when I'm in flow. But - for me - it feels plastic. I found it to be inferior to normal flow and I felt less in control than with normal flow. That might improve with exposure.
I can see where Ritalin would be useful if you needed to get to flow on-demand. A back-door I use for this - write a throw-away dear-diary whinge about why I can't get started. The obstacle is a feeling - so I name that. Then I look for a source of it. This is generally a technical problem that's energy-intensive to load into my mind. So I write about the complications that make me see it as energy-intensive. By then it's started. [I've mentioned this before on hn and apologise if I get boring]