|
|
@ -1,7 +1,15 @@
|
|
|
|
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
import 'package:project_telephony/ui/tab_navigator.dart';
|
|
|
|
import 'dart:async';
|
|
|
|
import 'dart:async';
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:project_telephony/utils/headers.dart';
|
|
|
|
import 'package:project_telephony/utils/headers.dart';
|
|
|
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import '../constants/environment/environment.dart';
|
|
|
|
|
|
|
|
import '../providers/user_provider.dart';
|
|
|
|
|
|
|
|
import '../utils/hive_store.dart';
|
|
|
|
|
|
|
|
import 'login/login_page.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class Loading extends StatefulWidget {
|
|
|
|
class Loading extends StatefulWidget {
|
|
|
|
Loading({Key? key}) : super(key: key);
|
|
|
|
Loading({Key? key}) : super(key: key);
|
|
|
@ -12,11 +20,27 @@ class Loading extends StatefulWidget {
|
|
|
|
|
|
|
|
|
|
|
|
class _LoadingState extends State<Loading> {
|
|
|
|
class _LoadingState extends State<Loading> {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Future initialAll() async {
|
|
|
|
|
|
|
|
await HiveStore.init();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
void initState() {
|
|
|
|
// TODO: implement initState
|
|
|
|
|
|
|
|
super.initState();
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
final userProvider = Provider.of<UserProvider>(context, listen: false);
|
|
|
|
|
|
|
|
var env = const String.fromEnvironment('ENV', defaultValue: 'dev');
|
|
|
|
|
|
|
|
if (kDebugMode) {
|
|
|
|
|
|
|
|
print('env :$env');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DevEV.instance.setEnvironment( context, environment: env == 'dev',);
|
|
|
|
|
|
|
|
Future.delayed(const Duration(milliseconds: 1000), () async {
|
|
|
|
|
|
|
|
await initialAll();
|
|
|
|
|
|
|
|
if (!await userProvider.init()) {
|
|
|
|
|
|
|
|
await Get.offAll(() => const LoginPage());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
await Get.offAll(() => const TabNavigator());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
Future.delayed(const Duration(seconds: 3),(){
|
|
|
|
Future.delayed(const Duration(seconds: 3),(){
|
|
|
|
//3秒后跳转到其他路由
|
|
|
|
//3秒后跳转到其他路由
|
|
|
|
Navigator.of(context).pushReplacementNamed("/TabNavigator");
|
|
|
|
Navigator.of(context).pushReplacementNamed("/TabNavigator");
|
|
|
|