GithubHelp home page GithubHelp logo

Comments (3)

ayham95 avatar ayham95 commented on August 22, 2024

ok.. I don't think that named routes are supported but i'll make sure to check and fix the problem

from custom-navigator.

zgramming avatar zgramming commented on August 22, 2024

thank's for your fast response , i hope you can adding supported pushNamed to give a different choise routed.

from custom-navigator.

shyam1s15 avatar shyam1s15 commented on August 22, 2024

previous , i want say thank's to make great plugin . I have problem navigate from Page-Testing1 to Detail-Page-Testing1 , I already read the documentation but not found about using pushNamed.

I get error like this after i press button to navigate from Page-Testing1 to Detail-Page-Testing1

Log Error


════════ Exception caught by gesture ═══════════════════════════════════════════
The following assertion was thrown while handling a gesture:
Could not find a generator for route RouteSettings("/detail-page-testing1", null) in the _CustomNavigatorState.

Generators for routes are searched for in the following order:
 1. For the "/" route, the "home" property, if non-null, is used.
 2. Otherwise, the "routes" table is used, if it has an entry for the route.
 3. Otherwise, onGenerateRoute is called. It should return a non-null value for any valid route not handled by "home" and "routes".
 4. Finally if all else fails onUnknownRoute is called.
Unfortunately, onUnknownRoute was not set.
When the exception was thrown, this was the stack
#0      _CustomNavigatorState._onUnknownRoute.<anonymous closure> 
package:custom_navigator/custom_navigator.dart:158
#1      _CustomNavigatorState._onUnknownRoute 
package:custom_navigator/custom_navigator.dart:170
#2      NavigatorState._routeNamed 
package:flutter/…/widgets/navigator.dart:1644
#3      NavigatorState.pushNamed 
package:flutter/…/widgets/navigator.dart:1683
#4      PageTesting1.build.<anonymous closure> 
package:klenger_burger/screens/homescreen.dart:124
...
Handler: "onTap"
Recognizer: TapGestureRecognizer#4f977
    debugOwner: GestureDetector
    state: possible
    won arena
    finalPosition: Offset(177.3, 238.7)
    finalLocalPosition: Offset(82.3, 18.0)
    button: 1
    sent tap down
════════════════════════════════════════════════════════════════════════════════

Custom


class HomeScreenCustom extends StatefulWidget {
  final List<BottomNavigationBarItem> itemMenuBottomNavigation;
  final List<Widget> screenBottomNavigation;
  final Function(int) onTapItemBottomNavigation;
  HomeScreenCustom({
    @required this.onTapItemBottomNavigation,
    @required this.screenBottomNavigation,
    @required this.itemMenuBottomNavigation,
  });
  @override
  _HomeScreenCustomState createState() => _HomeScreenCustomState();
}

class _HomeScreenCustomState extends State<HomeScreenCustom> {
  @override
  Widget build(BuildContext context) {
    return CustomScaffold(
      scaffold: Scaffold(
        bottomNavigationBar: BottomNavigationBar(
          items: widget.itemMenuBottomNavigation,
        ),
      ),

      // Children are the pages that will be shown by every click
      // They should placed in order such as
      // `page 0` will be presented when `item 0` in the [BottomNavigationBar] clicked.
      children: widget.screenBottomNavigation,

      // Called when one of the [items] is tapped.
      onItemTap: widget.onTapItemBottomNavigation,
    );
  }

  // final _items = [
  //   BottomNavigationBarItem(icon: Icon(Icons.home), title: Text('home')),
  //   BottomNavigationBarItem(icon: Icon(Icons.event), title: Text('events')),
  //   BottomNavigationBarItem(
  //       icon: Icon(Icons.save_alt), title: Text('downloads')),
  // ];
}

HomeScreenCustom

 @override
  Widget build(BuildContext context) {
    return HomeScreenCustom(
      itemMenuBottomNavigation: [
        BottomNavigationBarItem(icon: Icon(Icons.home), title: Text('home')),
        BottomNavigationBarItem(icon: Icon(Icons.event), title: Text('events')),
      ],
      screenBottomNavigation: <Widget>[
        PageTesting1(),
        PageTesting2(),
      ],
      onTapItemBottomNavigation: (index) {},
    );
  }
}

class PageTesting1 extends StatelessWidget {
  static const routeNamed = "/page-testing1";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: FlatButton(
          onPressed: () =>
              Navigator.of(context).pushNamed(DetailPageTesting1.routeNamed),
          child: Text('Detail Testing 1'),
        ),
      ),
    );
  }
}

class DetailPageTesting1 extends StatelessWidget {
  static const routeNamed = "/detail-page-testing1";
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Text('Detail Testing 1'),
      ),
    );
  }
}

class PageTesting2 extends StatelessWidget {
  static const routeNamed = "/page-testing2";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: FlatButton(
          onPressed: () =>
              Navigator.of(context).pushNamed(DetailPageTesting2.routeNamed),
          child: Text('Detail Testing 2'),
        ),
      ),
    );
  }
}

class DetailPageTesting2 extends StatelessWidget {
  static const routeNamed = "/detail-page-testing2";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Text('Detail Testing 2'),
      ),
    );
  }
}

If i make mistake or i miss something in documentation, please correct me.

Thank's

Oh Hey there, may be i have found a quick fix for your solution which i have used in my app

try passing context your screen

example:

Home(context, some_other_data)

Store it in your Home

Home(this._saveContext) : assert( _saveContext!=null )

Use it for your next screen

Navigator.of(widget._saveContext).pushName('secondScreen')

please correct me if there is an issue

from custom-navigator.

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.