Created
April 8, 2024 08:01
-
-
Save eEQK/9c8f887f324018bceb11c7c7406c0ba3 to your computer and use it in GitHub Desktop.
instant back transition minimal example
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(const MyApp()); | |
class MyApp extends StatelessWidget { | |
const MyApp({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Demo', | |
debugShowCheckedModeBanner: false, | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: const Home(), | |
); | |
} | |
} | |
class Home extends StatelessWidget { | |
const Home({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar(), | |
body: TextButton( | |
onPressed: () => Navigator.of(context).push( | |
PageRouteBuilder( | |
transitionDuration: Duration.zero, | |
reverseTransitionDuration: Duration.zero, | |
pageBuilder: (context, animation, secondaryAnimation) => | |
const Page(), | |
), | |
), | |
child: const Text('go to page'), | |
), | |
); | |
} | |
} | |
class Page extends StatelessWidget { | |
const Page({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar(), | |
body: const Text('page'), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment