Skip to content

Instantly share code, notes, and snippets.

@lesliearkorful
Created May 4, 2020 21:21
Show Gist options
  • Save lesliearkorful/63c5800fe188b54502eb9d2634de74c5 to your computer and use it in GitHub Desktop.
Save lesliearkorful/63c5800fe188b54502eb9d2634de74c5 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Splash(),
routes: {
'/login': (_) => Login(),
'/home': (_) => Home(),
},
);
}
}
class Splash extends StatefulWidget {
@override
_SplashState createState() => _SplashState();
}
class _SplashState extends State<Splash> {
@override
void initState() {
super.initState();
Future.delayed(Duration(seconds: 1), () {
final loggedIn = true;
if (loggedIn)
Navigator.pushReplacementNamed(context, '/home');
else
Navigator.pushReplacementNamed(context, '/login');
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
color: Colors.white,
child: Center(child: Text('Welcome')),
),
);
}
}
class Login extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Login', style: Theme.of(context).textTheme.headline4),
),
);
}
}
class Home extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Home', style: Theme.of(context).textTheme.headline4),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment