Skip to content
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

Example With Page Changes #20

Open
yusrenaltair opened this issue Jan 3, 2020 · 2 comments
Open

Example With Page Changes #20

yusrenaltair opened this issue Jan 3, 2020 · 2 comments

Comments

@yusrenaltair
Copy link

I'm a flutter newbie.
I tried with the example you gave, and it worked. But I am confused how to apply with page changes while maintaining the bottom bar, like in TabBarView.
as I know, the function is placed here. thought.

void changePage(int index) {
    setState(() {
      currentIndex = index;
    });
  }

Thank you for your attention.

@CodeDruid13
Copy link

For any one else in future

int currentIndex;
void changePage(int index) {
setState(() {
currentIndex = index;
}); }

This returns the page you want--> Could be a Future,void or whatever you want

Widget callPage(int _selectedBar){
switch (_selectedBar) {
case 0 : return Screen();
case 1 : return Screen();
case 2 : return Screen();
case 3 : return Screen();
break;
default:
}
}

and in your Scaffold the body will be

body: this.callPage(this.currentIndex)

Now Add the bottombar as in the readme and your'e good to go

@iampato
Copy link
Contributor

iampato commented Mar 4, 2021

To avoid rebuilds use an indexstack like so

Widget build(BuildContext context){
    return Scaffold(
        .............
       body: IndexStack(
            index: currentIndex,
            children: [ ...your screens... ],
       ),
       .............
   );
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants