You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
healthcare-frontend/lib/common/splash_screen.dart

85 lines
1.9 KiB

1 year ago
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:healthcare_user/common/dashboard.dart';
import 'package:healthcare_user/common/settings.dart';
import 'package:healthcare_user/common/signup.dart';
1 year ago
void main() async{
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
//FirebaseMessaging.onBackgroundMessage(_messageHandler);
runApp(new Splash());
}
class Splash extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Water Management',
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new SplashScreen(),
);
}
}
class SplashScreen extends StatefulWidget {
const SplashScreen({ super.key });
@override
State<SplashScreen> createState() => _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen> {
Widget _defaultHome = new SignUp();
void loginCheck()async{
bool _result = await AppSettings.isSigIn();
if (_result) {
await AppSettings.loadDataFromMemory();
AppSettings.fcmId=await AppSettings.getData('FCM_TOKEN', 'STRING');
// await AppSettings.getProfile();
_defaultHome = new Dashboard();
}
}
@override
void initState() {
loginCheck();
super.initState();
Future.delayed(
const Duration(seconds: 5),
1 year ago
() => Navigator.push(
context,
MaterialPageRoute(builder: (context) => _defaultHome),
));
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: <Widget>[
Container(
decoration: const BoxDecoration(
image: DecorationImage(image: AssetImage("images/splashscreen.png"), fit: BoxFit.fill,),
1 year ago
),
),
],
)
);
}
}