splash page operation update.

hmxc
小赖 4 years ago
parent a897a6380a
commit a8bf223e3b

@ -3,14 +3,11 @@ import 'package:akuCommunity/provider/sign_up_provider.dart';
import 'package:akuCommunity/provider/user_provider.dart';
import 'package:akuCommunity/utils/developer_util.dart';
import 'package:akuCommunity/utils/hive_store.dart';
import 'package:amap_location_fluttify/amap_location_fluttify.dart';
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:fluwx/fluwx.dart';
import 'package:get/get.dart';
import 'package:hive/hive.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:provider/provider.dart';
import 'package:akuCommunity/provider/cart.dart';
import 'package:flutter_picker/flutter_picker.dart';
@ -19,9 +16,6 @@ import 'package:flutter_localizations/flutter_localizations.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Hive.initFlutter();
await HiveStore.init();
AmapLocation.instance.init(iosKey: 'ios key');
DeveloperUtil.setDev(true);
runApp(MyApp());
}

@ -2,9 +2,12 @@ import 'package:akuCommunity/pages/tab_navigator.dart';
import 'package:akuCommunity/provider/user_provider.dart';
import 'package:akuCommunity/utils/hive_store.dart';
import 'package:akuCommunity/utils/logger/logger_view.dart';
import 'package:amap_location_fluttify/amap_location_fluttify.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:hive/hive.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:provider/provider.dart';
import 'package:velocity_x/velocity_x.dart';
@ -17,8 +20,21 @@ class SplashPage extends StatefulWidget {
}
class _SplashPageState extends State<SplashPage> {
///
Future _originOp() async {
//HiveStore
await Hive.initFlutter();
await HiveStore.init();
//AMap
AmapLocation.instance.init(iosKey: 'ios key');
}
Future _initOp() async {
//ensure call _originOp first.
await _originOp();
final userProvider = Provider.of<UserProvider>(context, listen: false);
//app init delay 2 second
await Future.delayed(Duration(seconds: 2));
if (HiveStore.appBox.get('login') ?? false) {
await userProvider.setLogin(HiveStore.appBox.get('token'));

@ -1,4 +1,5 @@
import 'package:akuCommunity/pages/sign/sign_in_page.dart';
import 'package:akuCommunity/provider/user_provider.dart';
import 'package:akuCommunity/utils/logger/logger_data.dart';
import 'package:akuCommunity/utils/network/base_list_model.dart';
import 'package:akuCommunity/utils/network/base_model.dart';
@ -8,6 +9,7 @@ import 'package:dio/dio.dart';
import 'package:akuCommunity/constants/api.dart';
import 'package:get/get.dart' hide Response;
import 'package:logger/logger.dart';
import 'package:provider/provider.dart';
class NetUtil {
Dio _dio;
@ -144,8 +146,10 @@ class NetUtil {
}
_parseRequestError(BaseModel model, {bool showMessage = false}) {
if (!model.status&&model.message=='登录失效,请登录'){
final userProvider = Provider.of<UserProvider>(Get.context, listen: false);
if (!model.status && model.message == '登录失效,请登录') {
Get.offAll(SignInPage());
userProvider.logout();
}
if (!model.status || showMessage) {
BotToast.showText(text: model.message);

Loading…
Cancel
Save