Dart Streams - Flutter in Focus

Flutter · 280K views · 2019 · 8:01

Open on YouTube

Web developmentPython, Ruby & scripting languagesSoftware architecture & designexplainer

Why Stack Overflow recommends it

Stack Overflow users link it when asking about or answering Flutter and Dart questions on streams, StreamBuilder and the difference between Future and Stream.

Recommended by 7 people across 8 different months, 2019 to 2023.

What it is

An 8-minute episode of Google's Flutter in Focus series explaining Dart streams as the multi-value counterpart to futures. It covers the basics of reactive, asynchronous coding with streams, including data and errors arriving over time, and is presented by the Flutter team.

What people said

Recommends Augustin R · 2019-09 · Stack Overflow · on “Flutter Page view not updating in Future Builder async snapshot”

Be careful, a future builder only listens once to the future. Maybe you should consider using a Stream instead (see this video [this video] )

Recommends Augustin R · 2020-01 · Stack Overflow · on “Flutter: How to use FutureBuilder like StreamBuilder”

You can either: upgrade your server in order to use a real Stream in your app (for example a socket) build a Dart Stream which calls your server periodically and use it in a StreamBuilder See this video [this video] for more details.

Recommends Suragch · 2020-02 · Stack Overflow · on “What's the difference between async and async* in Dart?”

Short answer async gives you a Future async* gives you a Stream . async You add the async keyword to a function that does some work that might take a long time. It returns the result wrapped in a Future . Future<int> doSomeLongTask() async { await Future.delayed(const Duration(seconds: 1)); return 42; } You can get that result by awaiting the Future: main() async { int result = await doSomeLongTask(); print(result); // prints '42' after waiting 1 second } async* You add the async* keyword to make a function that returns a bunch of future values one at a time. The results are wrapped in a Stream. Stream<int> countForOneMinute() async* { for (int i = 1; i <= 60; i++) { await Future.delayed(con

Recommends zex_rectooor · 2020-10 · Stack Overflow · on “Create stream builder”

Get this errors: 1.A value of type 'Stream' can't be returned from function 'stream' because it has a return type of 'Stream'. (return_of_invalid_type at blahblah) 2.The argument type 'Stream' can't be assigned to the parameter type 'Stream'. (argument_type_not_assignable at blahblah) why? here is code to create stream builder base on this video [this video] from flutter team void main() { runApp(MyApp()); //listen to subscribe to stream } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: SafeArea( child: Center( child: Stream(), ), ), ); } } class Stream extends StatefulWidget { @override _StreamState createState() => _StreamState(); }

Recommends mddg · 2021-08 · Stack Overflow · on “Flutter Streams usage”

You should check more information about streams and reactive programming before going too deep into it. Check this video [this video] from the Flutter channel.

Recommends Yash Bhansali · 2022-01 · Stack Overflow · on “Would having multiple compasses in one app work?”

It's okay if that was a bit confusing. There is this solution and get bit of info regarding streams. [this video] check this video out it explains every thing in a very easy manner. :)

Recommends CoderUni · 2022-04 · Stack Overflow · on “I want to understand how streams work with bloc pattern in flutter?”

Here's the description of what emit.forEach does in the docs [LINK] : Subscribes to the provided stream and invokes the onData callback when the stream emits new data and the result of onData is emitted. Basically, it's the same as a List's .map() method. Each and every data (element) in the list will be converted into another value. Eg: Object to String emit.forEach takes two values: the stream it has to listen to and the onData function. It will listen to all of the values emitted by the stream and convert them into another value (In this case MatrixSuccuClientState ). Think of value2 in onData: (value2) as the " element[index] in a list" . The value2 is the currently emitted value of the

Recommends bitinerant · 2023-02 · Stack Overflow · on “What is a Future and how do I use it?”

If you haven't dealt with futures in another programming language, it will take some time to grasp the concepts. I found Google's Flutter in Focus video series invaluable: ☐1. Isolates and Event Loops [LINK] ; ☐2. Futures [LINK] ; ☐3. Streams [this video] ; ☐4. Async/Await [LINK] ; ☐5. Generators [LINK]

Cites Luis Miguel Mantilla · 2020-05 · Stack Overflow · on “How to add items to a StreamController in flutter”

Firstable when you need to add a list to the stream so convert your map data to a list, just adding toList() at the end of you map as follows: members.forEach((member) { var data = _membersCollectionReference .document(member) .snapshots() .map((memberData) => Member.fromData(data: memberData.data)).toList(); And to push the data in the Stream, you need to use sink.add() this can be an example of a function to push data into the stream and the other one to get the values: final StreamController<List<Member>> _membersController = StreamController<List<Member>>.broadcast(); /// Inputs Function(List<Member>) get changeMembers => _membersController.sink.add; /// Getters String get members => _me

Cites MαπμQμαπkγVπ.0 · 2021-04 · Stack Overflow · on “Flutter : How to make an http stream for StreamBuilder”

I'm not able to replicate your sample code, but here how I understood your question. Let's first define the difference about Future and Streams : From this SO post [LINK] A Future is like the token with a number on it that they give you when you order takeout; you made the request, but the result is not yet ready but you have a placeholder. And when the result is ready, you get a callback (the digital board above the takeout counter shows your number or they shout it out) - you can now go in and grab your food (the result) to take out. A Stream is like that belt carrying little sushi bowls. By sitting down at that table, you've "subscribed" to the stream. You don't know when the next sushi b