Comments (3)
ok.. I don't think that named routes are supported but i'll make sure to check and fix the problem
from custom-navigator.
thank's for your fast response , i hope you can adding supported pushNamed to give a different choise routed.
from custom-navigator.
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)
- Use a different navigator widget
- How to keep the state of the detail page when we change another tab? HOT 4
- Bottom Bar show on all pages HOT 1
- How to navigate for entering 3 times or more deeper using bottom navigation bar where bottom navigation bar will be not hide HOT 4
- How to preserve page state when a new page is opened HOT 4
- How not to use your navigator after i already wrap it?
- Issue regarding popping pages HOT 4
- Can't selected item color
- BottomNavigationBar currentIndex not work in CustomScaffold HOT 3
- Pop CustomScaffold to naviagate to another route
- way to make routes be above the bottom bar manually
- custom_navigator
- Bottom navigator colors not working
- The non-abstract class '_CustomNavigatorState' is missing implementations HOT 13
- Same GlobalKey on all pages
- Can we manage Navigation stack using for all tabs using the Custom-scaffold?
- app is close on pressing android Back button
- Migrate to null safety HOT 4
- Error while Creating build
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from custom-navigator.