Code Monkey home page Code Monkey logo

Comments (6)

Milad-Akarie avatar Milad-Akarie commented on May 10, 2024 1

@bounty1342 should be fixed in auto_route: 0.4.2, check it out.

from auto_route_library.

bounty1342 avatar bounty1342 commented on May 10, 2024

You should add it to the documentation, I was still adding it to the MaterialApp.

builder: ExtendedNavigator<Router>(
                router: Router(),
                key: MyNavigationService.navKey,
                observers: [HeroController()],
              )

@ResoCoder : might be good to update the tutorial a bit, most is still valid.

from auto_route_library.

Milad-Akarie avatar Milad-Akarie commented on May 10, 2024

Hey, @bounty1342 I'm glad you're liking the package.
passing your own key isn't required anymore, you can easily obtain the current navigation state without context using
ExtendedNavigator.ofRouter<Router>()
It was mentioned in the updated README file

from auto_route_library.

bounty1342 avatar bounty1342 commented on May 10, 2024

My service was using navKey, but I changed it.

Only remaining issue is with onWillPop that is not triggered anymore, any recommendation ?

@override
 Widget build(BuildContext context) {
   return WillPopScope(
     onWillPop: () => _exitApp(context),
   NavigationService navigationProvider =
       Provider.of<NavigationService>(context, listen: false);
   if (!navigationProvider.hasNoRoute()) {
     navigationProvider.navigationBack();
     return Future.value(false);
   }

   return showDialog(
       context: context,
       builder: (BuildContext context) {
         return AlertDialog(
           title: new Text(I18n.of(context).exitApplicationQuestionTitle),
           content: new Text(I18n.of(context).exitApplicationQuestionLbl),
           actions: <Widget>[
             FlatButton(
               onPressed: () => Navigator.of(context).pop(false),
               child: new Text(I18n.of(context).exitApplicationQuestionNoBtn),
             ),
             FlatButton(
               onPressed: () => Navigator.of(context).pop(true),
               child: new Text(I18n.of(context).exitApplicationQuestionYesBtn),
             ),
           ],
         );
       });
 }

from auto_route_library.

Milad-Akarie avatar Milad-Akarie commented on May 10, 2024

@bounty1342 can I see your MaterialApp setup?
also may I ask, why do you need a navigation service if you're gonna Provide it with context?
why not use ExtendedNavigator.of(context)? the ExtendedNavigator state is already provided in the context

from auto_route_library.

bounty1342 avatar bounty1342 commented on May 10, 2024

@Milad-Akarie,

My MaterialApp setup below :

 child: MaterialApp(
              localizationsDelegates: [
                _localeOverrideDelegate,
                const I18nDelegate(),
                GlobalMaterialLocalizations.delegate,
                GlobalWidgetsLocalizations.delegate,
                GlobalCupertinoLocalizations.delegate,
              ],
              supportedLocales: MyI18nDelegate.supportedLocals,
              debugShowCheckedModeBanner: appConfig.debugShowCheckedModeBanner,
              title: appConfig.appName,
              theme: themeService.getTheme(),
              darkTheme: themeService.getThemeDark(),
              builder: ExtendedNavigator<Router>(
                router: Router(),
              )),

I use a MVVM pattern, the services know nothing about the context. This is to enforce between the logic and the UI.

issue #47, seems to be related.

Regards,

from auto_route_library.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.