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.

127 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:power_logger/power_logger.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:provider/provider.dart';
import 'package:telephony/telephony.dart';
import 'package:project_telephony/utils/hive_store.dart';
void main() async {
// SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle( //设置状态栏透明
// statusBarColor: Colors.transparent,
// statusBarIconBrightness: Brightness.dark,
// ));
//
// WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized();//设置启动页
// FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
//
// await SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp] );
// FlutterError.onError = (details) {
// LoggerData.addData(details);
// FlutterError.presentError(details);
// };
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;
Future<void> _Getpermission() async{
await [Permission.sms,Permission.phone,].request();
}
@override
void initState() {
super.initState();
// final service = FlutterBackgroundService();
// Future.delayed(const Duration(milliseconds: 0), () async {
// //Hive.initFlutter;
// });
_Getpermission();
HiveStore.init();
registerWxApi(
appId: "wxd930ea5d5a228f5f",universalLink:"https://your.univerallink.com/link/ "
);
}
@override
Widget build(BuildContext context) {
return MultiProvider(
providers: [
ChangeNotifierProvider(create: (context) => UserProvider()),
],
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()],
));
},
)),
);
}
}