-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
when click bottom navigation icon, navigator does not direct push to that screen. #3
Comments
Can you please elaborate more about what you want to achieve? |
So you want multiple views on each menu item to stay active? |
yes |
the problem is when i switch one menu item to other menu item, the page under other menu item does not open directly, until it pops the all routes of first menu item |
Oh, ok ok that’s a valid point. |
i tried both, but the problem is same. |
Ok, no problem man. I’ll push a fix right away. |
yes please, i am working on production app and the problem need to be fixed as soon as possible |
Solved! Use CustomScaffold i uploaded v0.3.0 |
`
import 'package:capp/scopped-model/main_model.dart';
import 'package:capp/screens/about_papertale_screen.dart';
import 'package:capp/screens/dashboard_screen.dart';
import 'package:custom_navigator/custom_navigator.dart';
import 'package:flutter/material.dart';
class HomeScreen extends StatefulWidget {
final MainModel model;
HomeScreen({this.model});
@OverRide
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State {
GlobalKey navigatorKey = GlobalKey();
int _currentIndex = 0;
@OverRide
Widget build(BuildContext context) {
final tabpages = [
DashboardScreen(
model: widget.model,
),
AboutPaperTaleScreen(
model: widget.model,
),
AboutPaperTaleScreen(
model: widget.model,
),
];
return Scaffold(
bottomNavigationBar: BottomNavigationBar(
backgroundColor: Colors.white,
currentIndex: _currentIndex,
unselectedItemColor: Theme.of(context).primaryColor.withOpacity(0.5),
selectedItemColor: Theme.of(context).primaryColor,
items: _items,
onTap: (index) {
// if (index == 0) {
navigatorKey.currentState.maybePop();
// }
setState(() {
_currentIndex = index;
});
},
),
body: CustomNavigator(
navigatorKey: navigatorKey,
home: tabpages[_currentIndex],
pageRoute: PageRoutes.materialPageRoute,
),
);
}
final _items = [
BottomNavigationBarItem(
icon: Icon(Icons.home),
title: Text(''),
),
BottomNavigationBarItem(
icon: Icon(Icons.info_outline),
title: Text(''),
),
BottomNavigationBarItem(
icon: Icon(Icons.settings),
title: Text(''),
),
];
}
`
when click on bottom bar icon, navigator pop the route but i want to direct push to desired screen
The text was updated successfully, but these errors were encountered: