Real Time Data change between two activity in Flutter Bloc pattern











up vote
0
down vote

favorite












I have two Activity.



Activity 1 ------> Text



Activity 2 ------> Increment Button



When user click on Activity 2 button then in Activity 1 Text Field will increment like counter.



My Current Bloc class:



class IncrementBloc implements BlocBase {

int _counter;
StreamController<int> _counterController = StreamController<int>();
Sink<int> get _inAdd => _counterController.sink;
Stream<int> get outCounter => _counterController.stream;


StreamController _actionController = StreamController();
Sink get incrementCounter => _actionController.sink;


IncrementBloc(){
_counter = 0;
_actionController.stream.listen(_handleLogic);
}




@override
void dispose() {
_actionController.close();
_counterController.close();
}

void _handleLogic(data){
print("hello");
_counter = _counter + 1;
_inAdd.add(_counter);
}


}



How to achieve my functionality using this bloc class?










share|improve this question




























    up vote
    0
    down vote

    favorite












    I have two Activity.



    Activity 1 ------> Text



    Activity 2 ------> Increment Button



    When user click on Activity 2 button then in Activity 1 Text Field will increment like counter.



    My Current Bloc class:



    class IncrementBloc implements BlocBase {

    int _counter;
    StreamController<int> _counterController = StreamController<int>();
    Sink<int> get _inAdd => _counterController.sink;
    Stream<int> get outCounter => _counterController.stream;


    StreamController _actionController = StreamController();
    Sink get incrementCounter => _actionController.sink;


    IncrementBloc(){
    _counter = 0;
    _actionController.stream.listen(_handleLogic);
    }




    @override
    void dispose() {
    _actionController.close();
    _counterController.close();
    }

    void _handleLogic(data){
    print("hello");
    _counter = _counter + 1;
    _inAdd.add(_counter);
    }


    }



    How to achieve my functionality using this bloc class?










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have two Activity.



      Activity 1 ------> Text



      Activity 2 ------> Increment Button



      When user click on Activity 2 button then in Activity 1 Text Field will increment like counter.



      My Current Bloc class:



      class IncrementBloc implements BlocBase {

      int _counter;
      StreamController<int> _counterController = StreamController<int>();
      Sink<int> get _inAdd => _counterController.sink;
      Stream<int> get outCounter => _counterController.stream;


      StreamController _actionController = StreamController();
      Sink get incrementCounter => _actionController.sink;


      IncrementBloc(){
      _counter = 0;
      _actionController.stream.listen(_handleLogic);
      }




      @override
      void dispose() {
      _actionController.close();
      _counterController.close();
      }

      void _handleLogic(data){
      print("hello");
      _counter = _counter + 1;
      _inAdd.add(_counter);
      }


      }



      How to achieve my functionality using this bloc class?










      share|improve this question















      I have two Activity.



      Activity 1 ------> Text



      Activity 2 ------> Increment Button



      When user click on Activity 2 button then in Activity 1 Text Field will increment like counter.



      My Current Bloc class:



      class IncrementBloc implements BlocBase {

      int _counter;
      StreamController<int> _counterController = StreamController<int>();
      Sink<int> get _inAdd => _counterController.sink;
      Stream<int> get outCounter => _counterController.stream;


      StreamController _actionController = StreamController();
      Sink get incrementCounter => _actionController.sink;


      IncrementBloc(){
      _counter = 0;
      _actionController.stream.listen(_handleLogic);
      }




      @override
      void dispose() {
      _actionController.close();
      _counterController.close();
      }

      void _handleLogic(data){
      print("hello");
      _counter = _counter + 1;
      _inAdd.add(_counter);
      }


      }



      How to achieve my functionality using this bloc class?







      dart flutter






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited yesterday









      dshukertjr

      803422




      803422










      asked 2 days ago









      Yeahia2508

      1,47231435




      1,47231435





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53361711%2freal-time-data-change-between-two-activity-in-flutter-bloc-pattern%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53361711%2freal-time-data-change-between-two-activity-in-flutter-bloc-pattern%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          'app-layout' is not a known element: how to share Component with different Modules

          android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

          SQL update select statement