Created
January 22, 2024 20:39
-
-
Save jonahwilliams/cbe39b54ed31a188231675669e30ac1f to your computer and use it in GitHub Desktop.
page transition gif
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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