92 lines
3.3 KiB
Dart
92 lines
3.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:news_getx/data/services/config.dart';
|
|
import 'package:news_getx/global.dart';
|
|
import 'package:news_getx/routes/app_pages.dart';
|
|
import 'package:news_getx/theme/app_theme.dart';
|
|
import 'package:news_getx/translations/app_translations.dart';
|
|
import 'package:pull_to_refresh/pull_to_refresh.dart';
|
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
|
import 'package:sentry_flutter/sentry_flutter.dart';
|
|
|
|
Future<void> main() async {
|
|
await Global.init();
|
|
|
|
await SentryFlutter.init(
|
|
(options) {
|
|
options.dsn = "https://acac4fdb2abc486a9f7c64558f27d85e@o4505594886356992.ingest.sentry.io/4505594892124160";
|
|
if (ConfigService.to.isRelease) {
|
|
options.tracesSampleRate = 1.0;
|
|
}
|
|
},
|
|
appRunner: () => runApp(const MyApp()),
|
|
);
|
|
}
|
|
|
|
class MyApp extends StatelessWidget {
|
|
const MyApp({super.key});
|
|
|
|
// This widget is the root of your application.
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ScreenUtilInit(
|
|
designSize: Size(375, 812),
|
|
// 如果不把这歌参数设为true 那么column就不会随着软键盘而变化
|
|
// useInheritedMediaQuery: true,
|
|
builder: (BuildContext context, Widget? child) {
|
|
var app = GetMaterialApp(
|
|
title: 'News',
|
|
debugShowCheckedModeBanner: false,
|
|
theme: AppTheme.light.copyWith(
|
|
appBarTheme: AppBarTheme(
|
|
systemOverlayStyle: SystemUiOverlayStyle(
|
|
statusBarColor: Colors.transparent,
|
|
statusBarBrightness: Brightness.light,
|
|
statusBarIconBrightness: Brightness.dark,
|
|
systemNavigationBarDividerColor: Colors.transparent,
|
|
systemNavigationBarColor: Colors.white,
|
|
systemNavigationBarIconBrightness: Brightness.dark,
|
|
)),
|
|
),
|
|
unknownRoute: AppPages.notFoundRoute,
|
|
initialRoute: AppPages.Initial,
|
|
getPages: AppPages.pages,
|
|
navigatorObservers: [AppPages.observer],
|
|
translations: AppTranslations(),
|
|
// 设置本地化
|
|
localizationsDelegates: [
|
|
GlobalMaterialLocalizations.delegate,
|
|
GlobalWidgetsLocalizations.delegate,
|
|
GlobalCupertinoLocalizations.delegate,
|
|
],
|
|
supportedLocales: ConfigService.to.languages,
|
|
locale: ConfigService.to.locale,
|
|
fallbackLocale: Locale('en', 'US'),
|
|
builder: EasyLoading.init(),
|
|
);
|
|
|
|
return RefreshConfiguration(
|
|
headerBuilder: () => ClassicHeader(),
|
|
footerBuilder: () => ClassicFooter(),
|
|
hideFooterWhenNotFull: true,
|
|
headerTriggerDistance: 80,
|
|
maxOverScrollExtent: 100,
|
|
footerTriggerDistance: 150,
|
|
child: Obx(() {
|
|
// todo 有没有更好的解决方案
|
|
return ConfigService.to.isGrayFilter.isTrue
|
|
? ColorFiltered(
|
|
colorFilter: ColorFilter.mode(Colors.grey, BlendMode.color),
|
|
child: app,
|
|
)
|
|
: app;
|
|
}),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|