import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', home: MyHomePage(), ); } } class MyHomePage extends StatefulWidget { MyHomePage({Key key}) : super(key: key); @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State { @override Widget build(BuildContext context) { return Material( child: Center( child: ElevatedButton( child: Text('Forward', style: TextStyle(fontSize: 120.0)), onPressed: () { Navigator.push(context, MaterialPageRoute( builder: (BuildContext context) { return Material( color: Colors.green, child: Center( child: ElevatedButton( child: Text('Backward', style: TextStyle(fontSize: 120.0)), onPressed: () { Navigator.of(context).pop(); }, ), ), ); }, )); }, ), ), ); } }