Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- void main() {
- runApp(MaterialApp(
- debugShowCheckedModeBanner: false,
- title: 'Navigation Basics',
- home: FirstRoute(),
- ));
- }
- class FirstRoute extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- title: Center( child: Text('Первая страница')),
- ),
- body: Center(
- child: ElevatedButton(
- child: Text('Open route'),
- onPressed: () {
- Navigator.push(
- context,
- MaterialPageRoute(builder: (context) => SecondRoute()),
- );
- },
- ),
- ),
- );
- }
- }
- class SecondRoute extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- title: Text("Second Route"),
- ),
- body: Center(
- child: ElevatedButton(
- onPressed: () {
- Navigator.pop(context);
- },
- child: Text('Go back!'),
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement