The given task must provide immediate feedback—in other words, it makes you feel good, makes you sweat, makes a pleasing sound, etc. Receiving this immediate feedback can encourage you to maintain flow state.
The challenge of the task and your ability to complete it must be more or less at the same level.