Flashbacks serve as a reminder to the reader that they are indeed reading what is only an illusion. This weakens the trance and can even break it.
Foreshadowing, however, is a literary device that alludes to something that will happen later in the story. Foreshadowing is subtle way to draw the reader deeper into the illusion with the promise of the excitement to come.
In the Beginning, or the first 1/4 of the page count or scene count, foreshadows actually appear as introductions.
Harper Lee, in To Kill a Mockingbird, uses foreshadowing in such a way as to strengthen the illusion of the story world. In the Beginning of the story, the reader is introduced, but not shown, Boo as a "malevolent phantom."
At the end of the Beginning we learn that Scout was "so busy looking at the fire you didn't know it when [Boo] put the blanket around you," The reader now has a sense that Boo is not what he first appeared. This act of Boo's in the Beginning foreshadows the Climax of the story. And it is the reader's curiosity about who Boo really is that draws them into the heart of the story.
Burris Ewell is also introduced in the Beginning. The reader comes to know Burris as "the filthiest human I had ever seen." "He's a mean one, a down-hard mean one. He's liable to start somethin'." Soon after we learn that his "paw's right contentious." Because of this introduction in the Beginning to the boy and his paw, when we learn what the paw has done in the Middle of the story, we are not surprised.
At the end of the Beginning, Scout wakes up to snow, something she has never seen before, and screams: "The world's endin', Atticus! Please do something --!" This is a powerful way to leave the Beginning and launch into the Middle of the story -- the actual story world itself because from that moment on, Scout's world as she knows it, does in fact, end.
Much later in the story, in the middle of the End, after Tom Robinson commits suicide, we learn that "Mr. Ewell said it made one down and about two more to go."
Soon after that the Judge, who embarrassed Mr. Ewell in the trial, has an attempted break-in at his house. If the reader had not already figured it out, they now know for sure whom the third party is that Mr. Ewell alluded to. The reader becomes viscerally afraid for Atticus and starts turning the pages faster. Soon after, when Aunt Alexandra stops short in the middle of her sentence, and says, "Somebody just walked over my grave," the reader feels the sensation as well and their fear deepens.
Even as the reader "sees" Scout in her Halloween costume and is caught up in the light-hearted fun of her presentation to the family and Calpurnia, the hair on the back of the reader's neck does not relax. When Jem escorts Scout to the pageant and their friend pops out behind the big oak tree to frighten them, the sense of doom heightens. On the way home after the pageant, when the Jem and Scout approach that same tree, the reader knows the Climax is near.
Reading is a mindful activity. When the writing is good and in scene, a reader reads the words, but rather than pay attention to them, becomes engaged with the characters. This keeps the reader in the present moment -- not real time present moment, but story time present moment. While we are reading in scene, there is only a sense of flow.
This paradigm does not only occur when reading "above the line" scenes or, in other words, scenes filled with tension, conflict and suspense. Even when the character is reflecting on an experience, going inward to find out what they are feeling and thinking, still the reader can stay in the illusion.
However, this sort of inner reflection by the character usually is not necessary because a character's external behavior is directly influenced by their inner state of being both in the moment and as a reflection of the past.
The best reading occurs when the reader is so in the trance of the story that there never seems to be a good enough reason to put the book down. Foreshadowing helps create this feeling. The reader cannot stop until they find out if what they think will happen based on clever foreshadowing does in fact happen. But what about that next foreshadow? The reader is as unable to stop or even slow down as the characters are.
Now is not the time to throw in a flashback, especially not in the final 1/4 of the story. A flashback can give the reader a good reason to stop. Foreshadowing, however, pulls the reader deeper and deeper into the story world and gives more and more reasons to keep on reading.