How can I send onTab signal from nested stateful widget to main.dart












0















In my main.dart I have a timer and GestureDetector. The GestureDetector onTap etc. handle the user interaction with _handleUserInteraction().
Every time user tabs the app reset the timer. My problem is I need to send signal the onTab (or similar) from form_a.dart to home.dart.





  • main.dart

  • PageView (with bottomNavigationBar) (home.dart) (with timer)


    • Page 1


      • Page 1 Summary (with ListView) (page_1.dart)

      • ListTile 1 onTab


        • ListView A (a.dart)


          • FormA (form_a.dart)





      • List Tile 2 onTab

      • List Tile 3 onTab



    • Page 2

    • Page 3




How can I send onTab signal from nested stateful widget FormA (**form_a.dart) to home.dart?**



I need to access _timer abd void _handleUserInteraction() function from any widget (as deep as gets) under home.dart



import 'package:flutter/material.dart';
import 'dart:async';
import 'main.dart';
import 'details.dart';


class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

Timer _timer;

// TODO: 3 - INITIALIZE TIMER
void _initializeTimer() {
_timer = Timer.periodic(const Duration(minutes: 5), (__) {
_logOutUser();
});
}

// TODO: 4 - LOG OUT USER
void _logOutUser() {
_timer.cancel();

Navigator.push(context,
new MaterialPageRoute(builder: (context) => new MyApp()));

}

// TODO: 5 - HANDLE USER INTERACTION
void _handleUserInteraction([_]) {
if (!_timer.isActive) {
return;
}
_timer.cancel();
_initializeTimer();
}

@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: _handleUserInteraction,
onDoubleTap: _handleUserInteraction,
onLongPress: _handleUserInteraction,
onScaleEnd: _handleUserInteraction,
onScaleStart: _handleUserInteraction,
onScaleUpdate: _handleUserInteraction,
onTapCancel: _handleUserInteraction,
onTapDown: _handleUserInteraction,
onTapUp: _handleUserInteraction,
child: new Scaffold(
appBar: AppBar(
title: Text("HOME PAGE"),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'GOTO DETAILS PAGE',
),
new RaisedButton(
child: new Text("Details"),
onPressed: (){
Navigator.push(context,
new MaterialPageRoute(builder: (context) => new Details()));
}
)
],
),
),
));
}
}


class LoginState extends InheritedWidget{

LoginState({Key key, Widget child});

@override
bool updateShouldNotify(InheritedWidget oldWidget) => true;
}









share|improve this question





























    0















    In my main.dart I have a timer and GestureDetector. The GestureDetector onTap etc. handle the user interaction with _handleUserInteraction().
    Every time user tabs the app reset the timer. My problem is I need to send signal the onTab (or similar) from form_a.dart to home.dart.





    • main.dart

    • PageView (with bottomNavigationBar) (home.dart) (with timer)


      • Page 1


        • Page 1 Summary (with ListView) (page_1.dart)

        • ListTile 1 onTab


          • ListView A (a.dart)


            • FormA (form_a.dart)





        • List Tile 2 onTab

        • List Tile 3 onTab



      • Page 2

      • Page 3




    How can I send onTab signal from nested stateful widget FormA (**form_a.dart) to home.dart?**



    I need to access _timer abd void _handleUserInteraction() function from any widget (as deep as gets) under home.dart



    import 'package:flutter/material.dart';
    import 'dart:async';
    import 'main.dart';
    import 'details.dart';


    class MyHomePage extends StatefulWidget {
    @override
    _MyHomePageState createState() => _MyHomePageState();
    }

    class _MyHomePageState extends State<MyHomePage> {

    Timer _timer;

    // TODO: 3 - INITIALIZE TIMER
    void _initializeTimer() {
    _timer = Timer.periodic(const Duration(minutes: 5), (__) {
    _logOutUser();
    });
    }

    // TODO: 4 - LOG OUT USER
    void _logOutUser() {
    _timer.cancel();

    Navigator.push(context,
    new MaterialPageRoute(builder: (context) => new MyApp()));

    }

    // TODO: 5 - HANDLE USER INTERACTION
    void _handleUserInteraction([_]) {
    if (!_timer.isActive) {
    return;
    }
    _timer.cancel();
    _initializeTimer();
    }

    @override
    Widget build(BuildContext context) {
    return GestureDetector(
    onTap: _handleUserInteraction,
    onDoubleTap: _handleUserInteraction,
    onLongPress: _handleUserInteraction,
    onScaleEnd: _handleUserInteraction,
    onScaleStart: _handleUserInteraction,
    onScaleUpdate: _handleUserInteraction,
    onTapCancel: _handleUserInteraction,
    onTapDown: _handleUserInteraction,
    onTapUp: _handleUserInteraction,
    child: new Scaffold(
    appBar: AppBar(
    title: Text("HOME PAGE"),
    ),
    body: Center(
    child: Column(
    mainAxisAlignment: MainAxisAlignment.center,
    children: <Widget>[
    Text(
    'GOTO DETAILS PAGE',
    ),
    new RaisedButton(
    child: new Text("Details"),
    onPressed: (){
    Navigator.push(context,
    new MaterialPageRoute(builder: (context) => new Details()));
    }
    )
    ],
    ),
    ),
    ));
    }
    }


    class LoginState extends InheritedWidget{

    LoginState({Key key, Widget child});

    @override
    bool updateShouldNotify(InheritedWidget oldWidget) => true;
    }









    share|improve this question



























      0












      0








      0








      In my main.dart I have a timer and GestureDetector. The GestureDetector onTap etc. handle the user interaction with _handleUserInteraction().
      Every time user tabs the app reset the timer. My problem is I need to send signal the onTab (or similar) from form_a.dart to home.dart.





      • main.dart

      • PageView (with bottomNavigationBar) (home.dart) (with timer)


        • Page 1


          • Page 1 Summary (with ListView) (page_1.dart)

          • ListTile 1 onTab


            • ListView A (a.dart)


              • FormA (form_a.dart)





          • List Tile 2 onTab

          • List Tile 3 onTab



        • Page 2

        • Page 3




      How can I send onTab signal from nested stateful widget FormA (**form_a.dart) to home.dart?**



      I need to access _timer abd void _handleUserInteraction() function from any widget (as deep as gets) under home.dart



      import 'package:flutter/material.dart';
      import 'dart:async';
      import 'main.dart';
      import 'details.dart';


      class MyHomePage extends StatefulWidget {
      @override
      _MyHomePageState createState() => _MyHomePageState();
      }

      class _MyHomePageState extends State<MyHomePage> {

      Timer _timer;

      // TODO: 3 - INITIALIZE TIMER
      void _initializeTimer() {
      _timer = Timer.periodic(const Duration(minutes: 5), (__) {
      _logOutUser();
      });
      }

      // TODO: 4 - LOG OUT USER
      void _logOutUser() {
      _timer.cancel();

      Navigator.push(context,
      new MaterialPageRoute(builder: (context) => new MyApp()));

      }

      // TODO: 5 - HANDLE USER INTERACTION
      void _handleUserInteraction([_]) {
      if (!_timer.isActive) {
      return;
      }
      _timer.cancel();
      _initializeTimer();
      }

      @override
      Widget build(BuildContext context) {
      return GestureDetector(
      onTap: _handleUserInteraction,
      onDoubleTap: _handleUserInteraction,
      onLongPress: _handleUserInteraction,
      onScaleEnd: _handleUserInteraction,
      onScaleStart: _handleUserInteraction,
      onScaleUpdate: _handleUserInteraction,
      onTapCancel: _handleUserInteraction,
      onTapDown: _handleUserInteraction,
      onTapUp: _handleUserInteraction,
      child: new Scaffold(
      appBar: AppBar(
      title: Text("HOME PAGE"),
      ),
      body: Center(
      child: Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
      Text(
      'GOTO DETAILS PAGE',
      ),
      new RaisedButton(
      child: new Text("Details"),
      onPressed: (){
      Navigator.push(context,
      new MaterialPageRoute(builder: (context) => new Details()));
      }
      )
      ],
      ),
      ),
      ));
      }
      }


      class LoginState extends InheritedWidget{

      LoginState({Key key, Widget child});

      @override
      bool updateShouldNotify(InheritedWidget oldWidget) => true;
      }









      share|improve this question
















      In my main.dart I have a timer and GestureDetector. The GestureDetector onTap etc. handle the user interaction with _handleUserInteraction().
      Every time user tabs the app reset the timer. My problem is I need to send signal the onTab (or similar) from form_a.dart to home.dart.





      • main.dart

      • PageView (with bottomNavigationBar) (home.dart) (with timer)


        • Page 1


          • Page 1 Summary (with ListView) (page_1.dart)

          • ListTile 1 onTab


            • ListView A (a.dart)


              • FormA (form_a.dart)





          • List Tile 2 onTab

          • List Tile 3 onTab



        • Page 2

        • Page 3




      How can I send onTab signal from nested stateful widget FormA (**form_a.dart) to home.dart?**



      I need to access _timer abd void _handleUserInteraction() function from any widget (as deep as gets) under home.dart



      import 'package:flutter/material.dart';
      import 'dart:async';
      import 'main.dart';
      import 'details.dart';


      class MyHomePage extends StatefulWidget {
      @override
      _MyHomePageState createState() => _MyHomePageState();
      }

      class _MyHomePageState extends State<MyHomePage> {

      Timer _timer;

      // TODO: 3 - INITIALIZE TIMER
      void _initializeTimer() {
      _timer = Timer.periodic(const Duration(minutes: 5), (__) {
      _logOutUser();
      });
      }

      // TODO: 4 - LOG OUT USER
      void _logOutUser() {
      _timer.cancel();

      Navigator.push(context,
      new MaterialPageRoute(builder: (context) => new MyApp()));

      }

      // TODO: 5 - HANDLE USER INTERACTION
      void _handleUserInteraction([_]) {
      if (!_timer.isActive) {
      return;
      }
      _timer.cancel();
      _initializeTimer();
      }

      @override
      Widget build(BuildContext context) {
      return GestureDetector(
      onTap: _handleUserInteraction,
      onDoubleTap: _handleUserInteraction,
      onLongPress: _handleUserInteraction,
      onScaleEnd: _handleUserInteraction,
      onScaleStart: _handleUserInteraction,
      onScaleUpdate: _handleUserInteraction,
      onTapCancel: _handleUserInteraction,
      onTapDown: _handleUserInteraction,
      onTapUp: _handleUserInteraction,
      child: new Scaffold(
      appBar: AppBar(
      title: Text("HOME PAGE"),
      ),
      body: Center(
      child: Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
      Text(
      'GOTO DETAILS PAGE',
      ),
      new RaisedButton(
      child: new Text("Details"),
      onPressed: (){
      Navigator.push(context,
      new MaterialPageRoute(builder: (context) => new Details()));
      }
      )
      ],
      ),
      ),
      ));
      }
      }


      class LoginState extends InheritedWidget{

      LoginState({Key key, Widget child});

      @override
      bool updateShouldNotify(InheritedWidget oldWidget) => true;
      }






      timer dart flutter gesture






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 23 '18 at 10:28







      Nick

















      asked Nov 22 '18 at 9:18









      NickNick

      19511




      19511
























          1 Answer
          1






          active

          oldest

          votes


















          1














          One way to do this would be by using the capabilities of InheritedWidget.



          First create your InheritedWidget:



          class MyInheritedWidget extends InheritedWidget {
          const MyInheritedWidget({
          Key key,
          VoidCallBack handleOnTap,
          Widget child,
          }) : assert(color != null),
          assert(child != null),
          super(key: key, child: child);

          final VoidCallBack handleOnTap;

          static MyInheritedWidget of(BuildContext context) {
          return context.inheritFromWidgetOfExactType(MyInheritedWidget);
          }

          @override
          bool updateShouldNotify(MyInheritedWidget old) => handleOnTap != old.handleOnTap;
          }


          That widget is usefull to retrieve common data between child Widgets and one of their parent in the hierarchy.



          In your main file, create your handler to match a VoidCallBack signature (or change the signature if you want).



          void _handleUserInteraction() {
          // do you stuff to reset your timer
          }


          So you should now wrap your PageView with your InheritedWidget to include it as high in the hierarchy as possible (as close as you main as you can) and give it your handling method



          MyInheritedWidget(child: PageView(), handleOnTap: _handleUserInteraction)


          Finally, in your onTap call your InheritedWidget handler:



          onTap: () {MyInheritedWidget.of(context).handleOnTap}





          share|improve this answer
























          • Thanks for the info Muldec, I red about InheritedWidget, but still I have to clear more than one thing. All my dart file is stateful widget. So, how can I turn my stateful widget to be inherited widget? My PageView in home.dart that also stateful widget. I couldn't find any example how to use both. Any differences between them?

            – Nick
            Nov 23 '18 at 5:13











          • I update my question and try to build a small solution. PageView will be inside Home Page. but before I go further I need to understand basic concepts as I created in my updated code

            – Nick
            Nov 23 '18 at 10:30











          • Thanks @Muldec. I found it and its working now. Here is a link: github.com/flutter/flutter/issues/24673

            – Nick
            Nov 26 '18 at 7:01











          • Glad I could help @Nick The idea is really wrapping your statefullWidget with an InheritedWidget rather than changit it from statefull to Inherited. And that's exactly what you've done in HomeState in your build method. Congrats !

            – Muldec
            Nov 26 '18 at 12:33











          • Thanks @Muldec, I really appreciated.

            – Nick
            Nov 27 '18 at 14:14











          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',
          autoActivateHeartbeat: false,
          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%2f53427476%2fhow-can-i-send-ontab-signal-from-nested-stateful-widget-to-main-dart%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          One way to do this would be by using the capabilities of InheritedWidget.



          First create your InheritedWidget:



          class MyInheritedWidget extends InheritedWidget {
          const MyInheritedWidget({
          Key key,
          VoidCallBack handleOnTap,
          Widget child,
          }) : assert(color != null),
          assert(child != null),
          super(key: key, child: child);

          final VoidCallBack handleOnTap;

          static MyInheritedWidget of(BuildContext context) {
          return context.inheritFromWidgetOfExactType(MyInheritedWidget);
          }

          @override
          bool updateShouldNotify(MyInheritedWidget old) => handleOnTap != old.handleOnTap;
          }


          That widget is usefull to retrieve common data between child Widgets and one of their parent in the hierarchy.



          In your main file, create your handler to match a VoidCallBack signature (or change the signature if you want).



          void _handleUserInteraction() {
          // do you stuff to reset your timer
          }


          So you should now wrap your PageView with your InheritedWidget to include it as high in the hierarchy as possible (as close as you main as you can) and give it your handling method



          MyInheritedWidget(child: PageView(), handleOnTap: _handleUserInteraction)


          Finally, in your onTap call your InheritedWidget handler:



          onTap: () {MyInheritedWidget.of(context).handleOnTap}





          share|improve this answer
























          • Thanks for the info Muldec, I red about InheritedWidget, but still I have to clear more than one thing. All my dart file is stateful widget. So, how can I turn my stateful widget to be inherited widget? My PageView in home.dart that also stateful widget. I couldn't find any example how to use both. Any differences between them?

            – Nick
            Nov 23 '18 at 5:13











          • I update my question and try to build a small solution. PageView will be inside Home Page. but before I go further I need to understand basic concepts as I created in my updated code

            – Nick
            Nov 23 '18 at 10:30











          • Thanks @Muldec. I found it and its working now. Here is a link: github.com/flutter/flutter/issues/24673

            – Nick
            Nov 26 '18 at 7:01











          • Glad I could help @Nick The idea is really wrapping your statefullWidget with an InheritedWidget rather than changit it from statefull to Inherited. And that's exactly what you've done in HomeState in your build method. Congrats !

            – Muldec
            Nov 26 '18 at 12:33











          • Thanks @Muldec, I really appreciated.

            – Nick
            Nov 27 '18 at 14:14
















          1














          One way to do this would be by using the capabilities of InheritedWidget.



          First create your InheritedWidget:



          class MyInheritedWidget extends InheritedWidget {
          const MyInheritedWidget({
          Key key,
          VoidCallBack handleOnTap,
          Widget child,
          }) : assert(color != null),
          assert(child != null),
          super(key: key, child: child);

          final VoidCallBack handleOnTap;

          static MyInheritedWidget of(BuildContext context) {
          return context.inheritFromWidgetOfExactType(MyInheritedWidget);
          }

          @override
          bool updateShouldNotify(MyInheritedWidget old) => handleOnTap != old.handleOnTap;
          }


          That widget is usefull to retrieve common data between child Widgets and one of their parent in the hierarchy.



          In your main file, create your handler to match a VoidCallBack signature (or change the signature if you want).



          void _handleUserInteraction() {
          // do you stuff to reset your timer
          }


          So you should now wrap your PageView with your InheritedWidget to include it as high in the hierarchy as possible (as close as you main as you can) and give it your handling method



          MyInheritedWidget(child: PageView(), handleOnTap: _handleUserInteraction)


          Finally, in your onTap call your InheritedWidget handler:



          onTap: () {MyInheritedWidget.of(context).handleOnTap}





          share|improve this answer
























          • Thanks for the info Muldec, I red about InheritedWidget, but still I have to clear more than one thing. All my dart file is stateful widget. So, how can I turn my stateful widget to be inherited widget? My PageView in home.dart that also stateful widget. I couldn't find any example how to use both. Any differences between them?

            – Nick
            Nov 23 '18 at 5:13











          • I update my question and try to build a small solution. PageView will be inside Home Page. but before I go further I need to understand basic concepts as I created in my updated code

            – Nick
            Nov 23 '18 at 10:30











          • Thanks @Muldec. I found it and its working now. Here is a link: github.com/flutter/flutter/issues/24673

            – Nick
            Nov 26 '18 at 7:01











          • Glad I could help @Nick The idea is really wrapping your statefullWidget with an InheritedWidget rather than changit it from statefull to Inherited. And that's exactly what you've done in HomeState in your build method. Congrats !

            – Muldec
            Nov 26 '18 at 12:33











          • Thanks @Muldec, I really appreciated.

            – Nick
            Nov 27 '18 at 14:14














          1












          1








          1







          One way to do this would be by using the capabilities of InheritedWidget.



          First create your InheritedWidget:



          class MyInheritedWidget extends InheritedWidget {
          const MyInheritedWidget({
          Key key,
          VoidCallBack handleOnTap,
          Widget child,
          }) : assert(color != null),
          assert(child != null),
          super(key: key, child: child);

          final VoidCallBack handleOnTap;

          static MyInheritedWidget of(BuildContext context) {
          return context.inheritFromWidgetOfExactType(MyInheritedWidget);
          }

          @override
          bool updateShouldNotify(MyInheritedWidget old) => handleOnTap != old.handleOnTap;
          }


          That widget is usefull to retrieve common data between child Widgets and one of their parent in the hierarchy.



          In your main file, create your handler to match a VoidCallBack signature (or change the signature if you want).



          void _handleUserInteraction() {
          // do you stuff to reset your timer
          }


          So you should now wrap your PageView with your InheritedWidget to include it as high in the hierarchy as possible (as close as you main as you can) and give it your handling method



          MyInheritedWidget(child: PageView(), handleOnTap: _handleUserInteraction)


          Finally, in your onTap call your InheritedWidget handler:



          onTap: () {MyInheritedWidget.of(context).handleOnTap}





          share|improve this answer













          One way to do this would be by using the capabilities of InheritedWidget.



          First create your InheritedWidget:



          class MyInheritedWidget extends InheritedWidget {
          const MyInheritedWidget({
          Key key,
          VoidCallBack handleOnTap,
          Widget child,
          }) : assert(color != null),
          assert(child != null),
          super(key: key, child: child);

          final VoidCallBack handleOnTap;

          static MyInheritedWidget of(BuildContext context) {
          return context.inheritFromWidgetOfExactType(MyInheritedWidget);
          }

          @override
          bool updateShouldNotify(MyInheritedWidget old) => handleOnTap != old.handleOnTap;
          }


          That widget is usefull to retrieve common data between child Widgets and one of their parent in the hierarchy.



          In your main file, create your handler to match a VoidCallBack signature (or change the signature if you want).



          void _handleUserInteraction() {
          // do you stuff to reset your timer
          }


          So you should now wrap your PageView with your InheritedWidget to include it as high in the hierarchy as possible (as close as you main as you can) and give it your handling method



          MyInheritedWidget(child: PageView(), handleOnTap: _handleUserInteraction)


          Finally, in your onTap call your InheritedWidget handler:



          onTap: () {MyInheritedWidget.of(context).handleOnTap}






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 22 '18 at 15:16









          MuldecMuldec

          4719




          4719













          • Thanks for the info Muldec, I red about InheritedWidget, but still I have to clear more than one thing. All my dart file is stateful widget. So, how can I turn my stateful widget to be inherited widget? My PageView in home.dart that also stateful widget. I couldn't find any example how to use both. Any differences between them?

            – Nick
            Nov 23 '18 at 5:13











          • I update my question and try to build a small solution. PageView will be inside Home Page. but before I go further I need to understand basic concepts as I created in my updated code

            – Nick
            Nov 23 '18 at 10:30











          • Thanks @Muldec. I found it and its working now. Here is a link: github.com/flutter/flutter/issues/24673

            – Nick
            Nov 26 '18 at 7:01











          • Glad I could help @Nick The idea is really wrapping your statefullWidget with an InheritedWidget rather than changit it from statefull to Inherited. And that's exactly what you've done in HomeState in your build method. Congrats !

            – Muldec
            Nov 26 '18 at 12:33











          • Thanks @Muldec, I really appreciated.

            – Nick
            Nov 27 '18 at 14:14



















          • Thanks for the info Muldec, I red about InheritedWidget, but still I have to clear more than one thing. All my dart file is stateful widget. So, how can I turn my stateful widget to be inherited widget? My PageView in home.dart that also stateful widget. I couldn't find any example how to use both. Any differences between them?

            – Nick
            Nov 23 '18 at 5:13











          • I update my question and try to build a small solution. PageView will be inside Home Page. but before I go further I need to understand basic concepts as I created in my updated code

            – Nick
            Nov 23 '18 at 10:30











          • Thanks @Muldec. I found it and its working now. Here is a link: github.com/flutter/flutter/issues/24673

            – Nick
            Nov 26 '18 at 7:01











          • Glad I could help @Nick The idea is really wrapping your statefullWidget with an InheritedWidget rather than changit it from statefull to Inherited. And that's exactly what you've done in HomeState in your build method. Congrats !

            – Muldec
            Nov 26 '18 at 12:33











          • Thanks @Muldec, I really appreciated.

            – Nick
            Nov 27 '18 at 14:14

















          Thanks for the info Muldec, I red about InheritedWidget, but still I have to clear more than one thing. All my dart file is stateful widget. So, how can I turn my stateful widget to be inherited widget? My PageView in home.dart that also stateful widget. I couldn't find any example how to use both. Any differences between them?

          – Nick
          Nov 23 '18 at 5:13





          Thanks for the info Muldec, I red about InheritedWidget, but still I have to clear more than one thing. All my dart file is stateful widget. So, how can I turn my stateful widget to be inherited widget? My PageView in home.dart that also stateful widget. I couldn't find any example how to use both. Any differences between them?

          – Nick
          Nov 23 '18 at 5:13













          I update my question and try to build a small solution. PageView will be inside Home Page. but before I go further I need to understand basic concepts as I created in my updated code

          – Nick
          Nov 23 '18 at 10:30





          I update my question and try to build a small solution. PageView will be inside Home Page. but before I go further I need to understand basic concepts as I created in my updated code

          – Nick
          Nov 23 '18 at 10:30













          Thanks @Muldec. I found it and its working now. Here is a link: github.com/flutter/flutter/issues/24673

          – Nick
          Nov 26 '18 at 7:01





          Thanks @Muldec. I found it and its working now. Here is a link: github.com/flutter/flutter/issues/24673

          – Nick
          Nov 26 '18 at 7:01













          Glad I could help @Nick The idea is really wrapping your statefullWidget with an InheritedWidget rather than changit it from statefull to Inherited. And that's exactly what you've done in HomeState in your build method. Congrats !

          – Muldec
          Nov 26 '18 at 12:33





          Glad I could help @Nick The idea is really wrapping your statefullWidget with an InheritedWidget rather than changit it from statefull to Inherited. And that's exactly what you've done in HomeState in your build method. Congrats !

          – Muldec
          Nov 26 '18 at 12:33













          Thanks @Muldec, I really appreciated.

          – Nick
          Nov 27 '18 at 14:14





          Thanks @Muldec, I really appreciated.

          – Nick
          Nov 27 '18 at 14:14


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53427476%2fhow-can-i-send-ontab-signal-from-nested-stateful-widget-to-main-dart%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

          404 Error Contact Form 7 ajax form submitting

          How to know if a Active Directory user can login interactively

          TypeError: fit_transform() missing 1 required positional argument: 'X'