Flutter : Bad state: Stream has already been listened to

前端 未结 11 1331
灰色年华
灰色年华 2020-12-03 04:21

    class MyPage extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return Defaul         


        
11条回答
  •  时光取名叫无心
    2020-12-03 05:01

    Just to sum up:

    The main difference is broadcast() creates a Stream listenable for multiple sources but it needs to be listened for at least one source to start emitting items.

    A Stream should be inert until a subscriber starts listening on it (using the [onListen] callback to start producing events).

    asBroadcastStream turns an existing Stream into a multi listenable one but it doesn't need to be listened to start emitting since it calls onListen() under the hood.

提交回复
热议问题