|
|
|
|
|
|
|
import 'dart:async';
|
|
|
|
|
|
|
|
import 'package:bot_toast/bot_toast.dart';
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:flutter_background_service/flutter_background_service.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:power_logger/power_logger.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/loading.dart';
|
|
|
|
|
|
|
|
import 'package:project_telephony/ui/tab_navigator.dart';
|
|
|
|
import 'package:project_telephony/utils/developer_util.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
import 'package:telephony/telephony.dart';
|
|
|
|
import 'package:project_telephony/utils/hive_store.dart';
|
|
|
|
|
|
|
|
void main() async {
|
|
|
|
const buildType = String.fromEnvironment('BUILD_TYPE');
|
|
|
|
DeveloperUtil.setDev(!(buildType.contains('PRODUCT')));
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
// 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<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: 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()],
|
|
|
|
));
|
|
|
|
},
|
|
|
|
)),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|