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(
- routes: {
- SplashPage.routeName: (context) => SplashPage(),
- },
- title: 'Flutter Demo',
- theme: ThemeData(
- primarySwatch: Colors.blue,
- visualDensity: VisualDensity.adaptivePlatformDensity,
- ),
- home: SplashPage(title: 'Flutter Demo Home Page'),
- );
- }
- }
- class SplashPage extends StatelessWidget {
- static const routeName = "splash";
- final String title;
- SplashPage({
- Key key,
- this.title,
- }) : super(key: key);
- @override
- Widget build(BuildContext context) {
- final bool isAuth = false;
- 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.push(
- context, LoginPage(title: "123").createRoute(context));
- },
- child: Text("LoginPage"),
- ),
- FlatButton(
- color: Colors.red,
- splashColor: Colors.green,
- onPressed: () {
- Navigator.push(
- context, HomePage(title: "123").createRoute(context));
- },
- child: Text("HomePage"),
- ),
- ],
- ),
- ),
- );
- }
- }
- class LoginPage extends Page {
- static const routeName = "login";
- final String title;
- LoginPage({
- Key key,
- this.title,
- }) : super(key: key);
- @override
- Route createRoute(BuildContext context) {
- return MaterialPageRoute(
- builder: (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.push(
- context,
- RegistryPage().createRoute(context),
- );
- },
- child: Text("RegistryPage"),
- ),
- FlatButton(
- color: Colors.red,
- splashColor: Colors.green,
- onPressed: () {
- Navigator.push(
- context,
- HomePage().createRoute(context),
- );
- },
- child: Text("HomePage"),
- ),
- ],
- ),
- ),
- );
- },
- );
- }
- }
- class RegistryPage extends Page {
- static const routeName = "registry";
- @override
- Route createRoute(BuildContext context) {
- return MaterialPageRoute(
- builder: (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.push(
- context,
- LoginPage().createRoute(context),
- );
- },
- child: Text("LoginPage"),
- ),
- ),
- );
- },
- );
- }
- }
- class HomePage extends Page {
- static const routeName = "home";
- final String title;
- HomePage({
- Key key,
- this.title,
- }) : super(key: key);
- @override
- Route createRoute(BuildContext context) {
- return MaterialPageRoute(builder: (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"),
- ),
- ),
- );
- });
- }
- }
Add Comment
Please, Sign In to add comment