Skip to content
0:00 / 0:00

#flutter#dart#futurebuilder

Fixing a common FutureBuilder and StreamBuilder problem

Randal L. Schwartz on Dart and Flutter

2.9K subscribers • 5 videos on Hallway

YouTube
  • Recommended by 2 people: 2 in engineering communities.
  • Presented by Randal L. Schwartz

Intermediate. Assumes working knowledge.

14K views5 years ago2 recommendations

Mobile developmentSoftware designFlutter and React NativeSoftware architectureDesign patterns

Randal L. Schwartz explains why constructing futures or streams directly inside Flutter's build method is problematic and shows how to fix it.

Randal shows how a common problem in using a FutureBuilder or StreamBuilder can easily be corrected. TL;DR: do not construct the future or the stream as the argument to the builder. Stash it into a state variable somewhere else so it gets constructed only once. UPDATE: @JohannesMilke did another take on this: youtube.com/watch?v=Pp3zoNDGZUI and youtu.be/g8Y1Eqa4pbc ... Check it out! 📖 Read the modern architectural sequel: Why FutureBuilder is an anti-pattern and how to fix it with reactive signals: dev.to/gde/futurebuilder-and-streambuilder-as-anti-patterns-… Support Randal on Patreon via patreon.com/randalschwartz Or buy Randal a Coffee via buymeacoffee.com/randalschwartz

Why it's here

2 people recommend this

What people say. Recommended as a clear explanation of why creating futures inside Flutter's build method causes performance issues and bugs.

u/RandalSchwartzin r/FlutterDev • Recommends

Why people are getting FutureBuilder and StreamBuilder (usually) wrong So a few of us on Discord late last night started discussion my “fixing futurebuilder/streambuilder” video at link to this video It was suggested to me that many videos actually get it wrong (putting the creation of the future directly in the future: parameter). I could imagine some tutorial videos possibly getting this wrong, but my quick survey led me to believe otherwise. Googling “flutter futurebuilder tutorial” shows many pages of results. Just on the first page, two of the videos have the title that includes “THE RIGHT WAY”. And indeed, they get it right (create the Future in State, then initialize in initState). One Hu…

u/RandalSchwartzin r/FlutterDev • Recommends

Issue filed against broken "Widget of the Week" episode for FutureBuilder - please upvote https://github.com/flutter/flutter/issues/112676 I've filed an issue against the longstanding broken "Widget of the Week" appearing on the FutureBuilder API page. The video suggests obtaining the Future from a function call, and both the documentation and actual practice have long denounced that as erroneous. Please visit the issue and comment and upvote. Thank you. For details on why that is broken, and how to fix it, see my video link to this video

u/Intelligent_Moose770in r/FlutterDev • Recommends

Fixing a common FutureBuilder and StreamBuilder problem

u/RandalSchwartzin r/FlutterDev • Recommends

Solving a common problem with FutureBuilder and StreamBuilder