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.

111 lines
4.0 KiB

import 'dart:async';
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:fluwx/fluwx.dart';
import 'package:get/get_navigation/src/root/get_material_app.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:project_telephony/providers/phone_num_provider.dart';
import 'package:project_telephony/providers/user_provider.dart';
import 'package:project_telephony/ui/home/call.dart';
import 'package:project_telephony/ui/home/home_page.dart';
import 'package:project_telephony/ui/loading.dart';
import 'package:project_telephony/ui/tab_navigator.dart';
import 'package:project_telephony/utils/developer_util.dart';
import 'package:project_telephony/utils/hive_store.dart';
import 'package:project_telephony/utils/user_tool.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:telephony/telephony.dart';
void main() async {
const buildType = String.fromEnvironment('BUILD_TYPE');
DeveloperUtil.setDev(!(buildType.contains('PRODUCT')));
WidgetsFlutterBinding.ensureInitialized();
// initializeService();
initializeService();
Future.delayed(const Duration(seconds: 1),(){
service.invoke("stopService");
});
// service.invoke("stopService");
// UserTool.userProvider.viewLoading();
await HiveStore.init();
// Workmanager().initialize(
// callbackDispatcher, // The top level function, aka callbackDispatcher
// isInDebugMode: true // If enabled it will post a notification whenever the task is running. Handy for debugging tasks
// );
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final telephony = Telephony.instance;
final prefs = SharedPreferences.getInstance();
Future<void> _Getpermission() async{
await [Permission.sms,Permission.phone,].request();
}
@override
void initState() {
super.initState();
// final service = FlutterBackgroundService();
_Getpermission();
registerWxApi(
appId: "wx3a0b41d12afef4e2",
// universalLink:"http://api.dxbs.vip/ "
);
}
@override
Widget build(BuildContext context) {
return MultiProvider(
providers: [
ChangeNotifierProvider(create: (context) => UserProvider()),
ChangeNotifierProvider(create: (context)=>PhoneNumProvider()),
],
child: MediaQuery(
data: MediaQueryData.fromWindow(WidgetsBinding.instance.window),
child: ScreenUtilInit(
designSize: const Size(750, 1334),
builder: (context, child) {
return AnnotatedRegion<SystemUiOverlayStyle>(
value: const SystemUiOverlayStyle(
statusBarColor: Colors.transparent, //状态栏背景色
statusBarIconBrightness: Brightness.dark),
child: GetMaterialApp(
// get.testmode=true,
debugShowCheckedModeBanner: false,
initialRoute: "/",
routes: {
"/TabNavigator":(context)=>const TabNavigator()
},
home: const Loading(),//const TabNavigator(),
builder: (context, child) {
// ScreenUtil.setContext(context);
return MediaQuery(
//设置文字大小不随系统设置改变
data: MediaQueryData.fromWindow(
WidgetsBinding.instance.window)
.copyWith(textScaleFactor: 1.0),
child: BotToastInit().call(context, child),
);
},
navigatorObservers: [BotToastNavigatorObserver()],
));
},
)),
);
}
}