main.dart 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/services.dart';
  3. import 'package:flutterappfuyou/code/version3/YSPerfectChapterInfo.dart';
  4. import 'package:fluwx/fluwx.dart';
  5. import 'package:shared_preferences/shared_preferences.dart';
  6. import 'YSPage.dart';
  7. import 'package:flutter_localizations/flutter_localizations.dart';
  8. import 'code/YSMeans.dart';
  9. import 'code/YSWomanBody.dart';
  10. import 'code/YSlogin.dart';
  11. import 'code/base/YSLocalizationsDelegate.dart';
  12. void main() async{
  13. WidgetsFlutterBinding.ensureInitialized();
  14. SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(statusBarColor: Colors.transparent,statusBarIconBrightness: Brightness.light),);
  15. SystemChrome.setPreferredOrientations([
  16. DeviceOrientation.portraitUp,
  17. DeviceOrientation.portraitDown
  18. ]);
  19. SharedPreferences prefs = await SharedPreferences.getInstance();
  20. String token = prefs.getString('token');
  21. bool isLogin = token==null?false:true;
  22. int chapters = prefs.getInt('chapters')??99;
  23. bool isMeans = prefs.getBool('isMeans')??false;
  24. // bool isFirst = prefs.get('first')??false;
  25. registerWxApi(appId: "wx6a9788c655738c6e",universalLink: "https://xian_muzishouce/app/");
  26. runApp(MyApp(isLogin: isLogin,chapters: chapters,isMeans: isMeans,));
  27. // runApp(MyApp(isLogin: false,));
  28. }
  29. class MyApp extends StatelessWidget {
  30. // This widget is the root of your application.
  31. final bool isLogin;
  32. final bool isMeans;
  33. final int chapters;
  34. const MyApp({Key key, this.isLogin, this.chapters, this.isMeans}) : super(key: key);
  35. @override
  36. Widget build(BuildContext context) {
  37. return MaterialApp(
  38. title: '西安母子手册',
  39. color: Colors.white,
  40. routes: {
  41. 'YSMeans': (v) => YSMeans(),
  42. 'YSBody': (v) => YSWomanBody(),
  43. "YSMeans": (context) => YSMeans(),
  44. },
  45. debugShowCheckedModeBanner: false,
  46. theme: ThemeData(
  47. primaryColor: Color(0xFFDB5278),
  48. visualDensity: VisualDensity.adaptivePlatformDensity,
  49. ),
  50. localeListResolutionCallback:
  51. (List<Locale> locales, Iterable<Locale> supportedLocales) {
  52. return Locale('zh');
  53. },
  54. localeResolutionCallback:
  55. (Locale locale, Iterable<Locale> supportedLocales) {
  56. return Locale('zh');
  57. },
  58. localizationsDelegates: [
  59. ZhCupertinoLocalizations.delegate,
  60. GlobalMaterialLocalizations.delegate,
  61. GlobalWidgetsLocalizations.delegate,
  62. GlobalCupertinoLocalizations.delegate,
  63. ],
  64. supportedLocales: [
  65. const Locale('zh', 'CH'),
  66. const Locale('en', 'US'),
  67. ],
  68. home: isLogin==false?YSLogin():chapters==99?YSPerfectChapterInfo(isFirst: true,):isMeans==false?YSMeans(isFirst: true,):YSPage(),
  69. );
  70. }
  71. }