123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- import 'dart:io';
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:flutter_alipay/flutter_alipay.dart';
- import 'package:fluwx/fluwx.dart';
- import 'package:flutter_localizations/flutter_localizations.dart';
- import 'package:path_provider/path_provider.dart';
- import 'package:ysairplane2/code/YSWelcome.dart';
- import 'package:ysairplane2/tools/YSTools.dart';
- import 'code/YSTabbar.dart';
- import 'tools/YSLocalizationsDelegate.dart';
- void main() {
- try{
- WidgetsFlutterBinding.ensureInitialized();
- SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(statusBarColor: Colors.transparent,statusBarIconBrightness: Brightness.dark,),);
- SystemChrome.setPreferredOrientations([
- DeviceOrientation.portraitUp,
- DeviceOrientation.portraitDown
- ]);
- _clearCache();
- PaintingBinding.instance.imageCache.clear();
- PaintingBinding.instance.imageCache.maximumSize=2000; //最多2000张
- PaintingBinding.instance.imageCache.maximumSizeBytes = 1000 << 20; //最大200M
- _initFluwx();
- FlutterAlipay.setIosUrlSchema("feijizhifubao");
- checkVersion().then((value){
- runApp(MyApp(isnFirst: value,));
- });
- }catch(e){
- print('===============================$e===============================');
- }
- }
- class MyApp extends StatelessWidget {
- final isnFirst;
- const MyApp({Key key, this.isnFirst}) : super(key: key);
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- debugShowCheckedModeBanner: false,
- theme: ThemeData(
- primaryColor: Color(0xFF0088FF),
- visualDensity: VisualDensity.adaptivePlatformDensity,
- backgroundColor: Color(0xFFF5F6F8),
- ),
- routes: {
- "/home": (BuildContext context) => YSTabbar(),
- },
- localeListResolutionCallback:
- (List<Locale> locales, Iterable<Locale> supportedLocales) {
- return Locale('zh');
- },
- localeResolutionCallback:
- (Locale locale, Iterable<Locale> supportedLocales) {
- return Locale('zh');
- },
- localizationsDelegates: [
- ZhCupertinoLocalizations.delegate,
- GlobalMaterialLocalizations.delegate,
- GlobalWidgetsLocalizations.delegate,
- GlobalCupertinoLocalizations.delegate,
- ],
- supportedLocales: [
- const Locale('zh', 'CH'),
- const Locale('en', 'US'),
- ],
- home: isnFirst==true?YSTabbar():YSWelcome()
- );
- }
- }
- _initFluwx() async {
- await registerWxApi(
- appId: "wx7e62294a5bf6e206",
- doOnAndroid: true,
- doOnIOS: true,
- universalLink: "https://api.s-fly.cn/app/");
- var result = await isWeChatInstalled;
- print("is installed $result");
- }
- void _clearCache() async {
- Directory tempDir = await getTemporaryDirectory();
- //删除缓存目录
- await delDir(tempDir);
- }
- Future<Null> delDir(FileSystemEntity file) async {
- if (file is Directory) {
- final List<FileSystemEntity> children = file.listSync();
- for (final FileSystemEntity child in children) {
- var isHave =await child.exists(); //返回真假
- if(isHave){
- await delDir(child);
- }
- }
- }
- await file.delete();
- }
|