import 'dart:async'; import 'package:bot_toast/bot_toast.dart'; import 'package:call_log/call_log.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/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: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(); await HiveStore.init(); // await initializeService(); // 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 { final telephony = Telephony.instance; final prefs = SharedPreferences.getInstance(); Future _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( 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()], )); }, )), ); } }