Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- void main() {
- runApp(MyApp());
- }
- class MyApp extends StatelessWidget {
- // This widget is the root of your application.
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- title: 'Flutter Demo',
- theme: ThemeData(
- primarySwatch: Colors.blue,
- visualDensity: VisualDensity.adaptivePlatformDensity,
- ),
- home: Navigator(
- initialRoute: SplashPage.routeName,
- pages: [
- MaterialPage(
- key: ValueKey(SplashPage.routeName),
- child: SplashPage(),
- ),
- MaterialPage(
- key: ValueKey(HomePage.routeName),
- child: HomePage(),
- ),
- MaterialPage(
- key: ValueKey(LoginPage.routeName),
- child: LoginPage(),
- ),
- MaterialPage(
- key: ValueKey(RegistryPage.routeName),
- child: RegistryPage(),
- )
- ],
- onPopPage: (route, result) {
- if (!route.didPop(result)) {
- return false;
- }
- return true;
- },
- ),
- );
- }
- }
- class SplashPage extends StatelessWidget {
- static const routeName = "splash";
- final String title;
- SplashPage({
- Key key,
- this.title,
- }) : super(key: key);
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- title: Text("Splash"),
- centerTitle: true,
- ),
- body: Center(
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- FlatButton(
- color: Colors.red,
- splashColor: Colors.green,
- onPressed: () {
- Navigator.pushNamed(
- context,
- LoginPage.routeName,
- );
- },
- child: Text("LoginPage"),
- ),
- FlatButton(
- color: Colors.red,
- splashColor: Colors.green,
- onPressed: () {
- Navigator.pushNamed(
- context,
- HomePage.routeName,
- );
- },
- child: Text("HomePage"),
- ),
- ],
- ),
- ),
- );
- }
- }
- class LoginPage extends StatelessWidget {
- static const routeName = "login";
- final String title;
- LoginPage({
- Key key,
- this.title,
- }) : super(key: key);
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- leading: IconButton(
- icon: Icon(Icons.arrow_back, color: Colors.black),
- onPressed: () => Navigator.of(context).pop(),
- ),
- title: Text("Login"),
- centerTitle: true,
- ),
- body: Center(
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- FlatButton(
- color: Colors.red,
- splashColor: Colors.green,
- onPressed: () {
- Navigator.pushNamed(
- context,
- RegistryPage.routeName,
- );
- },
- child: Text("RegistryPage"),
- ),
- FlatButton(
- color: Colors.red,
- splashColor: Colors.green,
- onPressed: () {
- Navigator.pushNamed(
- context,
- HomePage.routeName,
- );
- },
- child: Text("HomePage"),
- ),
- ],
- ),
- ),
- );
- }
- }
- class RegistryPage extends StatelessWidget {
- static const routeName = "registry";
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- leading: IconButton(
- icon: Icon(Icons.arrow_back, color: Colors.black),
- onPressed: () => Navigator.of(context).pop(),
- ),
- title: Text("Registry"),
- centerTitle: true,
- ),
- body: Center(
- child: FlatButton(
- color: Colors.red,
- splashColor: Colors.green,
- onPressed: () {
- Navigator.pushNamed(
- context,
- LoginPage.routeName,
- );
- },
- child: Text("LoginPage"),
- ),
- ),
- );
- }
- }
- class HomePage extends StatelessWidget {
- static const routeName = "home";
- final String title;
- HomePage({
- Key key,
- this.title,
- }) : super(key: key);
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- leading: IconButton(
- icon: Icon(Icons.arrow_back, color: Colors.black),
- onPressed: () => Navigator.of(context).pop(),
- ),
- title: Text("Home"),
- centerTitle: true,
- ),
- body: Center(
- child: FlatButton(
- color: Colors.red,
- splashColor: Colors.green,
- onPressed: () {
- Navigator.pop(context);
- },
- child: Text("HomePage"),
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement