Bad state: Stream has already been listened to.

See original GitHub issue

Issue: I am calling notification in xyz.dart page I have made initialization correctly though when the notification displayed and when I clicked on it does not open the desired page but instead of any button click on the page it listening to that time and I am getting this issue.

Bad state: Stream has already been listened to.

log:

`════════ Exception caught by widgets library ═══════════════════════════════════════════════════════ The following StateError was thrown, building Builder: Bad state: Stream has already been listened to.

The relevant error-causing widget was: MaterialApp file:///D:/code/xyz/lib/main.dart:60:12 When the exception was thrown, this was the stack: #3 _xyzState.initState (package:xyz.dart:136:47) #4 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4765:58) #5 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4601:5) … Normal element mounting (132 frames) #137 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3569:14) …`

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Willianocommented, Sep 5, 2021

@josaphatcampos Thank you very much for this wonderful, easy to use and less code package.

This your answer fixed my problem

try{ AwesomeNotifications().actionStream.listen((receivedNotification) {

    Navigator.of(context).pushNamed(AppRoutes.OPERATIONADMIN,
        arguments: {'notifications': receivedNotification});

  });

}catch(e){ print(e); }
1reaction
marcos-bahcommented, Jul 1, 2021

Use inside of Statefull at initState. Its works for me.

@override
  void initState() {
    super.initState();
   AwesomeNotifications().actionStream.listen((receivedNotification) {
      print(receivedNotification);
      Navigator.of(context).pushNamed("/classpage");
 });
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Flutter : Bad state: Stream has already been listened to
In Flutter what will often happen is that widget listening to the stream ("listener") gets destroyed and built again. If you attempt to...
Read more >
Bad State: Stream has already been listened to. · Issue #29105
I have no idea what the bloc code is doing, but it seems likely that you are creating single subcription streams. These will...
Read more >
Bad state: Stream has already been listened to. The ... - Reddit
I think the problem is that the stream. listen is in the build method but i dont know where else to put it...
Read more >
[Solved]-Flutter StreamBuilder Firebase Bad state
[Solved]-Flutter StreamBuilder Firebase Bad state: Stream has already been listened to error-Flutter ... You can solve this by using stream.toBroadcastStream() so ...
Read more >
Bad state: Stream has already been listened to - Code Grepper
bad state : stream has already been listened to. Add Answer | View In TPC Matrix. Technical Problem Cluster First Answered On October...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found