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.

103 lines
3.7 KiB

2 years ago
import 'dart:async';
2 years ago
2 years ago
import 'package:bot_toast/bot_toast.dart';
2 years ago
import 'package:call_log/call_log.dart';
2 years ago
import 'package:flutter/material.dart';
2 years ago
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
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
import 'package:project_telephony/providers/phone_num_provider.dart';
2 years ago
import 'package:project_telephony/providers/user_provider.dart';
2 years ago
import 'package:project_telephony/ui/loading.dart';
2 years ago
import 'package:project_telephony/ui/tab_navigator.dart';
2 years ago
import 'package:project_telephony/utils/developer_util.dart';
2 years ago
import 'package:project_telephony/utils/hive_store.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';
2 years ago
2 years ago
void main() async {
2 years ago
const buildType = String.fromEnvironment('BUILD_TYPE');
DeveloperUtil.setDev(!(buildType.contains('PRODUCT')));
2 years ago
WidgetsFlutterBinding.ensureInitialized();
await HiveStore.init();
2 years ago
// await initializeService();
2 years ago
// Workmanager().initialize(
2 years ago
// 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();
}
2 years ago
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
}
@override
Widget build(BuildContext context) {
2 years ago
return MultiProvider(
providers: [
ChangeNotifierProvider(create: (context) => UserProvider()),
2 years ago
ChangeNotifierProvider(create: (context)=>PhoneNumProvider()),
2 years ago
],
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()
},
2 years ago
home: const 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
}
}