Created
May 4, 2020 21:21
-
-
Save lesliearkorful/63c5800fe188b54502eb9d2634de74c5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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