In my main activity, I have two tab, named tab1 and tab 2. Tab 2 page consists of a listView and I use StreamSubscription to listen upload progress result. On tab2 action bar, it has one icon. When icon is pressed, it will navigate to pageC,which consists of listView, and I use StreamSubscription too.

The problem is I notice when I upload image in PageC, it will display the upload progress in Tab2 page first, then only it will display upload progress in pageC. Why would this happened?

I defined subscription in both page as below

StreamSubscription<UploadTaskResponse> _subscription;
FlutterUploader uploader = FlutterUploader();

  @override
  void initState() {
    super.initState();

    _subscription = uploader.result.listen(
      (result) {
         print("Printing in pageC");
          ....
      },
      onError: (ex, stacktrace) {
      },
    );
    });
  }

I have defined the cancel() in both class too

 void dispose() {
    super.dispose();
    _subscription.cancel();
  }

Output

printing in Tab2
printing in PageC
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.