Skip to content

Instantly share code, notes, and snippets.

@jonahwilliams
Created January 22, 2024 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonahwilliams/cbe39b54ed31a188231675669e30ac1f to your computer and use it in GitHub Desktop.
Save jonahwilliams/cbe39b54ed31a188231675669e30ac1f to your computer and use it in GitHub Desktop.
page transition gif
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
home: Page1(),
routes: {'/foo': (context) {
return Page2();
}},
)
);
}
class Page1 extends StatefulWidget {
const Page1({super.key});
@override
State<Page1> createState() => _Page1State();
}
class _Page1State extends State<Page1> {
@override
Widget build(BuildContext context) {
return Scaffold(body: Container(
color: Colors.blue,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextButton(onPressed: () {
Navigator.pushNamed(context, '/foo');
}, child: Text('FOO'))
],
)));
}
}
class Page2 extends StatefulWidget {
const Page2({super.key});
@override
State<Page2> createState() => _Page2State();
}
class _Page2State extends State<Page2> {
@override
Widget build(BuildContext context) {
return Scaffold(body: Container(
color: Colors.red,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextButton(onPressed: () {
Navigator.pop(context);
}, child: Text('BACK'))
],
)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment