Skip to content

Instantly share code, notes, and snippets.

@dnfield
Last active November 11, 2022 01:04
Show Gist options
  • Save dnfield/96075efc997ccc9b14396728906de3ec to your computer and use it in GitHub Desktop.
Save dnfield/96075efc997ccc9b14396728906de3ec to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
void main() => runApp(
MaterialApp(
theme: ThemeData(
pageTransitionsTheme: const PageTransitionsTheme(builders: {
TargetPlatform.android: CupertinoPageTransitionsBuilder(),
TargetPlatform.windows: CupertinoPageTransitionsBuilder(),
TargetPlatform.macOS: CupertinoPageTransitionsBuilder(),
TargetPlatform.iOS: CupertinoPageTransitionsBuilder(),
TargetPlatform.linux: CupertinoPageTransitionsBuilder(),
}),
),
routes: <String, WidgetBuilder>{
'/': (context) => Scaffold(
appBar: AppBar(),
body: const Center(
child: Text('Page 1'),
),
drawer: Drawer(
backgroundColor: Colors.red,
child: ListView(
children: <Widget>[
TextButton(
child: const Text('Nav home'),
onPressed: () {},
),
TextButton(
child: const Text('Nav to Page 2'),
onPressed: () {
Navigator.of(context).pushNamed('/2');
},
),
],
),
),
),
'/2': (context) => Scaffold(
appBar: AppBar(),
body: const Center(
child: Text('Page 2'),
),
drawer: Drawer(
backgroundColor: Colors.red,
child: ListView(
children: <Widget>[
TextButton(
child: const Text('Nav home'),
onPressed: () async {
Navigator.of(context).pop();
Navigator.of(context).pop();
},
),
TextButton(
child: const Text('Nav to Page 2'),
onPressed: () {},
),
],
),
),
),
},
),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment