How do you access the route of a nested navigator defined in a scoped model class to use on another page?












0















I am trying to access the nested route(s) of a nested Navigator that I may call Navigator.pushNamed(context,route) from the root/main page of my app. I have used Scoped Model to help easily access the state of the nested Navigator. However, I do not know how to access the route(s) in that nested Navigator that I may pass it up the widget tree to the root of the App that the Navigator.pushNamed(context,route) method may be called for the nested Navigator from the root of the App. In short I want the control of the Navigator though nested to be at the root of the app and not within its nested widgets using a button at the top of the widget tree which is connected to the nested navigator but not trigger root navigator. I want to call the function in the Scoped model which handles this nested route navigation in the root of the app wrapped with Scoped Model Descendant using "model.()namedFunction"



As you can see I have a function defined in the Scoped Model called "pushNamed" I want it to access the route(s) and call Navigator.pushNamed(context,route) method so that I can access it in a scoped model descendant as model.pushNamed in an onPressed function body of a button at the root of the widget tree



class NestedNavModel extends Model{
static GlobalKey<NavigatorState> socialNavigatorKey;

static Widget nav1 = Navigator(
key: socialNavigatorKey,
initialRoute: 'SocialsFeed/feeder',
onGenerateRoute: (RouteSettings settings) {
WidgetBuilder builder;
switch (settings.name) {
case 'SocialsFeed/feeder':
builder = (BuildContext _) => new SocialsFeederPage();
break;
case 'SocialsFeed/first':
builder = (BuildContext _) => new SocialsProfile();
break;
default:
throw new Exception('Invalid route: ${settings.name}');
}
return new MaterialPageRoute(builder: builder, settings: settings);
}

);

pushNamed(){

}
}









share|improve this question





























    0















    I am trying to access the nested route(s) of a nested Navigator that I may call Navigator.pushNamed(context,route) from the root/main page of my app. I have used Scoped Model to help easily access the state of the nested Navigator. However, I do not know how to access the route(s) in that nested Navigator that I may pass it up the widget tree to the root of the App that the Navigator.pushNamed(context,route) method may be called for the nested Navigator from the root of the App. In short I want the control of the Navigator though nested to be at the root of the app and not within its nested widgets using a button at the top of the widget tree which is connected to the nested navigator but not trigger root navigator. I want to call the function in the Scoped model which handles this nested route navigation in the root of the app wrapped with Scoped Model Descendant using "model.()namedFunction"



    As you can see I have a function defined in the Scoped Model called "pushNamed" I want it to access the route(s) and call Navigator.pushNamed(context,route) method so that I can access it in a scoped model descendant as model.pushNamed in an onPressed function body of a button at the root of the widget tree



    class NestedNavModel extends Model{
    static GlobalKey<NavigatorState> socialNavigatorKey;

    static Widget nav1 = Navigator(
    key: socialNavigatorKey,
    initialRoute: 'SocialsFeed/feeder',
    onGenerateRoute: (RouteSettings settings) {
    WidgetBuilder builder;
    switch (settings.name) {
    case 'SocialsFeed/feeder':
    builder = (BuildContext _) => new SocialsFeederPage();
    break;
    case 'SocialsFeed/first':
    builder = (BuildContext _) => new SocialsProfile();
    break;
    default:
    throw new Exception('Invalid route: ${settings.name}');
    }
    return new MaterialPageRoute(builder: builder, settings: settings);
    }

    );

    pushNamed(){

    }
    }









    share|improve this question



























      0












      0








      0








      I am trying to access the nested route(s) of a nested Navigator that I may call Navigator.pushNamed(context,route) from the root/main page of my app. I have used Scoped Model to help easily access the state of the nested Navigator. However, I do not know how to access the route(s) in that nested Navigator that I may pass it up the widget tree to the root of the App that the Navigator.pushNamed(context,route) method may be called for the nested Navigator from the root of the App. In short I want the control of the Navigator though nested to be at the root of the app and not within its nested widgets using a button at the top of the widget tree which is connected to the nested navigator but not trigger root navigator. I want to call the function in the Scoped model which handles this nested route navigation in the root of the app wrapped with Scoped Model Descendant using "model.()namedFunction"



      As you can see I have a function defined in the Scoped Model called "pushNamed" I want it to access the route(s) and call Navigator.pushNamed(context,route) method so that I can access it in a scoped model descendant as model.pushNamed in an onPressed function body of a button at the root of the widget tree



      class NestedNavModel extends Model{
      static GlobalKey<NavigatorState> socialNavigatorKey;

      static Widget nav1 = Navigator(
      key: socialNavigatorKey,
      initialRoute: 'SocialsFeed/feeder',
      onGenerateRoute: (RouteSettings settings) {
      WidgetBuilder builder;
      switch (settings.name) {
      case 'SocialsFeed/feeder':
      builder = (BuildContext _) => new SocialsFeederPage();
      break;
      case 'SocialsFeed/first':
      builder = (BuildContext _) => new SocialsProfile();
      break;
      default:
      throw new Exception('Invalid route: ${settings.name}');
      }
      return new MaterialPageRoute(builder: builder, settings: settings);
      }

      );

      pushNamed(){

      }
      }









      share|improve this question
















      I am trying to access the nested route(s) of a nested Navigator that I may call Navigator.pushNamed(context,route) from the root/main page of my app. I have used Scoped Model to help easily access the state of the nested Navigator. However, I do not know how to access the route(s) in that nested Navigator that I may pass it up the widget tree to the root of the App that the Navigator.pushNamed(context,route) method may be called for the nested Navigator from the root of the App. In short I want the control of the Navigator though nested to be at the root of the app and not within its nested widgets using a button at the top of the widget tree which is connected to the nested navigator but not trigger root navigator. I want to call the function in the Scoped model which handles this nested route navigation in the root of the app wrapped with Scoped Model Descendant using "model.()namedFunction"



      As you can see I have a function defined in the Scoped Model called "pushNamed" I want it to access the route(s) and call Navigator.pushNamed(context,route) method so that I can access it in a scoped model descendant as model.pushNamed in an onPressed function body of a button at the root of the widget tree



      class NestedNavModel extends Model{
      static GlobalKey<NavigatorState> socialNavigatorKey;

      static Widget nav1 = Navigator(
      key: socialNavigatorKey,
      initialRoute: 'SocialsFeed/feeder',
      onGenerateRoute: (RouteSettings settings) {
      WidgetBuilder builder;
      switch (settings.name) {
      case 'SocialsFeed/feeder':
      builder = (BuildContext _) => new SocialsFeederPage();
      break;
      case 'SocialsFeed/first':
      builder = (BuildContext _) => new SocialsProfile();
      break;
      default:
      throw new Exception('Invalid route: ${settings.name}');
      }
      return new MaterialPageRoute(builder: builder, settings: settings);
      }

      );

      pushNamed(){

      }
      }






      flutter






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 19 at 16:15







      K.chim

















      asked Jan 17 at 18:20









      K.chimK.chim

      13




      13
























          0






          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',
          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%2f54242015%2fhow-do-you-access-the-route-of-a-nested-navigator-defined-in-a-scoped-model-clas%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          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%2f54242015%2fhow-do-you-access-the-route-of-a-nested-navigator-defined-in-a-scoped-model-clas%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

          Liquibase includeAll doesn't find base path

          How to use setInterval in EJS file?

          Petrus Granier-Deferre