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.

126 lines
4.0 KiB

2 years ago
import 'dart:async';
2 years ago
2 years ago
import 'package:bot_toast/bot_toast.dart';
2 years ago
2 years ago
import 'package:flutter/material.dart';
2 years ago
import 'package:flutter/services.dart';
2 years ago
2 years ago
import 'package:flutter_screenutil/flutter_screenutil.dart';
2 years ago
2 years ago
import 'package:fluwx/fluwx.dart';
2 years ago
import 'package:get/get_navigation/src/root/get_material_app.dart';
2 years ago
import 'package:permission_handler/permission_handler.dart';
2 years ago
2 years ago
import 'package:power_logger/power_logger.dart';
2 years ago
import 'package:project_telephony/providers/user_provider.dart';
2 years ago
import 'package:project_telephony/ui/home/call.dart';
2 years ago
import 'package:project_telephony/ui/loading.dart';
2 years ago
2 years ago
import 'package:project_telephony/ui/tab_navigator.dart';
2 years ago
import 'package:provider/provider.dart';
2 years ago
import 'package:shared_preferences/shared_preferences.dart';
2 years ago
import 'package:telephony/telephony.dart';
import 'package:project_telephony/utils/hive_store.dart';
2 years ago
2 years ago
2 years ago
2 years ago
void main() async {
2 years ago
// 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);
// };
2 years ago
WidgetsFlutterBinding.ensureInitialized();
2 years ago
// await initializeService();
2 years ago
2 years ago
// 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
// );
2 years ago
2 years ago
runApp(const MyApp());
2 years ago
}
2 years ago
2 years ago
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
2 years ago
final telephony = Telephony.instance;
2 years ago
final prefs = SharedPreferences.getInstance();
2 years ago
Future<void> _Getpermission() async{
await [Permission.sms,Permission.phone,].request();
}
2 years ago
@override
2 years ago
void initState() {
super.initState();
2 years ago
// final service = FlutterBackgroundService();
2 years ago
_Getpermission();
registerWxApi(
appId: "wx3a0b41d12afef4e2",
2 years ago
// universalLink:"http://api.dxbs.vip/ "
2 years ago
);
2 years ago
}
2 years ago
2 years ago
@override
Widget build(BuildContext context) {
2 years ago
return MultiProvider(
providers: [
ChangeNotifierProvider(create: (context) => UserProvider()),
],
child: MediaQuery(
2 years ago
data: MediaQueryData.fromWindow(WidgetsBinding.instance.window),
2 years ago
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,
2 years ago
initialRoute: "/",
routes: {
"/TabNavigator":(context)=>const TabNavigator()
},
home: Loading(),//const TabNavigator(),
2 years ago
builder: (context, child) {
// ScreenUtil.setContext(context);
return MediaQuery(
//设置文字大小不随系统设置改变
data: MediaQueryData.fromWindow(
2 years ago
WidgetsBinding.instance.window)
2 years ago
.copyWith(textScaleFactor: 1.0),
child: BotToastInit().call(context, child),
);
},
navigatorObservers: [BotToastNavigatorObserver()],
));
},
)),
);
2 years ago
}
}