Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flutter: listening callback not be called #19

Closed
Julyyq opened this issue Dec 9, 2018 · 13 comments
Closed

Flutter: listening callback not be called #19

Julyyq opened this issue Dec 9, 2018 · 13 comments

Comments

@Julyyq
Copy link

Julyyq commented Dec 9, 2018

In my "HomePage" initState function, I place the following code for listening to NewOrderEvent:

import '../eventbus/eventbus.dart';
.....
@override
void initState() {
  super.initState();
  eventBus.on<NewOrderEvent>().listen((event) {
    print("event fired: $event");
  });
}

These code works fine and in main.dart file, I invoke eventBus.fire(new NewOrderEvent("some data"); when my app receive message from Firebase Cloud Message, the eventBus.fire function is indeed be invoked, but the listen callback function not be called.

This is my "eventbus.dart" file content:

import 'package:event_bus/event_bus.dart';

EventBus eventBus = new EventBus();

class NewOrderEvent {
  Map order;

  NewOrderEvent(this.order);
}

I print the firing eventBus object and listening eventBus object:
screenshot 2018-12-09 17 47 57

They are indeed the same object.

BTW, the following are property and methods of the eventBus object:
screenshot 2018-12-09 17 53 36

@Julyyq Julyyq changed the title Flutter: listen callback not be called Flutter: listening callback not be called Dec 9, 2018
@Julyyq
Copy link
Author

Julyyq commented Dec 9, 2018

I solve the problem, seems that there is a bug of attaching Map data to the event.

screenshot 2018-12-09 18 25 52

@Julyyq Julyyq closed this as completed Dec 9, 2018
@rravithejareddy
Copy link

rravithejareddy commented Dec 12, 2018

Is it solved? I need a sample example in flutter using EventBus in different widget class (Other than main), that would be a great for flutter people.

@marcojakob marcojakob mentioned this issue Dec 13, 2018
@marcojakob
Copy link
Owner

Reopening this because there seems to be an issue (also see #16), although I don't quite understand it yet. If someone could clarify, it would be great.

@marcojakob marcojakob reopened this Dec 13, 2018
@Julyyq
Copy link
Author

Julyyq commented Dec 14, 2018

@marcojakob My problem is that passing Map type data to the listener, the listener function cannot be called.

@JordyBaylac
Copy link

JordyBaylac commented Oct 21, 2019

Reopening this because there seems to be an issue (also see #16), although I don't quite understand it yet. If someone could clarify, it would be great.

@marcojakob , Why is it opened if it is not clear that #16 has same issue than this?

@marcojakob
Copy link
Owner

@JordyBaylac Do you also have an issue with event bus and flutter?

@rio45ka
Copy link

rio45ka commented Oct 23, 2019

Is it solved? I need a sample example in flutter using EventBus in different widget class (Other than main), that would be a great for flutter people.

@marcojakob can you give example?

@JordyBaylac
Copy link

@marcojakob no I am not having any issue so far.

@rravithejareddy
Copy link

rravithejareddy commented Oct 23, 2019

Is it solved? I need a sample example in flutter using EventBus in different widget class (Other than main), that would be a great for flutter people.

@marcojakob can you give example?

No actually, i misunderstood flutter flow that's why i needed event-bus then, now we are just following simple pattern, event bus is needed for particular scenarios, at present we are not using it. Thanks for your support.

@marcojakob
Copy link
Owner

I'll close this since the problem seems to not be the event bus but something else.

@uchiha-itachi95
Copy link

I am also facing the same issue. I am also firing one event on message from Firebase. The listener is another screen which is pushed over the screen which is actually sending the event.

Strange enough, if I send event from screen A to Screen B (screen B is a BottomNavigationBarItem) it works. But if screen B is another screen which is pushed onto screen A, it does not work.

Above the author said it does not support Map data. But I am sending basic int data. That also seems not to work.

@marcojakob
Copy link
Owner

@uchiha-itachi95 Please check that you are using the same instance of your EventBus.

@yahu1031
Copy link

yahu1031 commented Jan 2, 2024

@marcojakob I am facing the same issue with the latest version. The data is being intermittently gathered. I have a similar scenario: I have an event bus listener on page A (where it works fine). And now I have 1-2 pages stacked or pushed over page A. And I have an same instance event bus listener which listens to the same event in page B(which gets data intermittently). Hope this will get a fix or a solution(work around).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants