import 'dart:async'; import 'dart:convert'; import 'package:bbyyy/beans/login_information_bean_entity.dart'; import 'package:bbyyy/https/my_request.dart'; import 'package:bbyyy/my_tools/easy_loading/easy_loading.dart'; import 'package:bbyyy/my_tools/my_cookie.dart'; import 'package:bbyyy/my_tools/my_tools.dart'; import 'package:bbyyy/paegs/login_page/login_page.dart'; import 'package:bbyyy/paegs/root_page/root_page.dart'; import 'package:flutter/material.dart'; class WelcomePage extends StatefulWidget { @override _WelcomePageState createState() => _WelcomePageState(); } class _WelcomePageState extends State { @override void initState() { super.initState(); EasyLoading.instance ..displayDuration = const Duration(milliseconds: 1500) ..indicatorType = EasyLoadingIndicatorType.ring ..loadingStyle = EasyLoadingStyle.light ..maskType = EasyLoadingMaskType.black ..indicatorSize = 45.0 ..radius = 10.0 ..textPadding = EdgeInsets.all(0) ..contentPadding = EdgeInsets.fromLTRB(20, 12, 20, 12) ..userInteractions = false; Timer(Duration(seconds: 1), () { if (MyCookie().getLoginInformation() == null || MyCookie().getLoginInformation().data == null || MyCookie().getLoginInformation().data.token.isEmpty || MyCookie().getLoginInformation().data.token == '') { MyTools().toPage(context, LoginPage(), (then) {}, noBack: true); } else { checkLogin((r, hE) { if (!hE) { String token = MyCookie().getToken(); LoginInformationBeanEntity loginInformation = LoginInformationBeanEntity() .fromJson(json.decode(r.data.toString())); loginInformation.data.token = token; MyCookie().saveLoginInformationBeanEntity(loginInformation); MyTools().toPage(context, RootPage(), (then) {}, noBack: true); } else { MyTools().toPage(context, LoginPage(), (then) {}, noBack: true); } }, (e) {}); } }); } @override Widget build(BuildContext context) { return Scaffold( body: Stack( children: [ Image.asset( 'images/we_bg.png', fit: BoxFit.cover, height: MediaQuery.of(context).size.height, width: MediaQuery.of(context).size.width, ), Image.asset( 'images/we_logo.png', height: 118, width: 118, ) ], alignment: Alignment.center, ), ); } }