Skip to content

Instantly share code, notes, and snippets.

@LOG-TAG

LOG-TAG/main.dart

Created Dec 6, 2019
Embed
What would you like to do?
Intro splash Home router runApp
import 'package:flutter/material.dart';
import 'package:gohype/home/home.dart';
import 'package:gohype/home/intro_screen.dart' ;
import 'package:gohype/signin/signinpage.dart';
import 'package:logger/logger.dart';
import 'home/intro_screen.dart';
import 'package:shared_preferences/shared_preferences.dart';
void main() async {
String mLoginInfo;
String introflag;
var logger = Logger();
// Set default home.
Widget _defaultHome = new IntroScreen();
final prefs = await SharedPreferences.getInstance();
// read
introflag = prefs.getString("INTRO_FLAG") ?? '';
mLoginInfo = prefs.getString("LOGIN_INFO_PHONE") ?? '';
if(mLoginInfo!="" && mLoginInfo!=null)
{
_defaultHome= new Home();
logger.d("inside home");
}
else
{
logger.d("inside not logged in");
if(introflag!=null && introflag!="") {
_defaultHome = new SignInUI();
logger.d("1SignInUI");
}
else{
_defaultHome=new IntroScreen();
logger.d("1IntroScreen");
}
}
// Run app!
runApp(new MaterialApp(
title: 'App',
home: _defaultHome,
routes: <String, WidgetBuilder>{
// Set routes for using the Navigator.
'/home': (BuildContext context) => new MyApp(),
'/login': (BuildContext context) => new SignInUI(),
'/intro': (BuildContext context) => new IntroScreen(),
},
));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment