Reputation: 7569
I have a bottom tabbar in my app for navigation. I have a listview in one tab that when clicked will take me to the details view of that item. However, I'd like to maintain the tabbar and appbar (maybe changing the title of the AppBar, etc).
Here's how I'm accomplishing the navigation:
Navigator.pushNamed(context, LocationDetails.routeName);
I don't want a transition effect for the AppBar or TabBar (ie I don't want them to slide with the Widget).
Thanks in advance!
Upvotes: 1
Views: 318
Reputation: 9129
The best way to proceed is to set a bool to be either true or false when a cell in your ListView is pressed. Then under your WidgetBuild write a ternary operator that is bool == true
? View 1 : View 2. Examples
bool viewState == true;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
backgroundColor: Colors.black87,
),
body: viewState == true ? Container(
child: new RaisedButton(onpressed:
(){setState ((){viewState == false}); // Changed code
),
) : new ListView(
child: new Center( // Changed code
child: new ListTile(onpressed: (){
setState((){viewState == true}
}),
),
),
);
}
Upvotes: 3