Skip to content

Instantly share code, notes, and snippets.

@berkanaslan
Created May 28, 2021 06:52
Show Gist options
  • Save berkanaslan/8742c7149d3554b367f3ca9f2f8508ca to your computer and use it in GitHub Desktop.
Save berkanaslan/8742c7149d3554b367f3ca9f2f8508ca to your computer and use it in GitHub Desktop.
class FirstScreen extends StatelessWidget {
static const route = '/first';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('First Screen')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
RaisedButton(
onPressed: () {
Navigator.of(
context,
// BottomNavigationBar ile diğer ekrana git
rootNavigator: false,
).pushNamed(PushedScreen.route);
},
child: Text('BottomNavigationBar ile sayfaya git'),
),
RaisedButton(
onPressed: () {
Navigator.of(
context,
// BottomNavigationBar olmadan diğer ekrana git (Kök dizin)
rootNavigator: true,
).pushNamed(PushedScreen.route);
},
child: Text('BottomNavigationBar olmadan sayfaya git'),
),
],
),
),
);
}
}
class FourthScreen extends StatelessWidget {
static const route = '/extra';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Extra Screen')),
body: Center(
child: RaisedButton(
onPressed: () {
// Push with bottom navigation visible
Navigator.of(
context,
rootNavigator: true,
).pushNamed(SimpleScreen.route);
},
child: Text('Go to Simple Page'),
),
),
);
}
}
class PushedScreen extends StatelessWidget {
static const route = '/first/pushed';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Pushed Screen')),
body: Center(
child: Text('Hello world!'),
),
);
}
}
class SecondScreen extends StatelessWidget {
static const route = '/second';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Second Screen')),
body: ListView.builder(
controller: NavigationProvider.of(context)
.screens[SECOND_SCREEN]
.scrollController,
itemBuilder: (context, index) {
return ListTile(
title: Text('Item: $index'),
);
},
),
);
}
}
class SimpleScreen extends StatelessWidget {
static const route = '/extra/simple';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Simple Screen"),
),
);
}
}
class ThirdScreen extends StatelessWidget {
static const route = '/third';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Third Screen')),
body: Center(
child: FlutterLogo(
size: 128,
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment