SHARE
TWEET

main

a guest Jan 23rd, 2020 140 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_app/getting_start_page/startPage.dart';
  3. import 'package:flutter_app/navigate_drawer/navigator.dart';
  4. import 'package:flutter_app/page/app_localizations.dart';
  5. import 'package:flutter_localizations/flutter_localizations.dart';
  6.  
  7. //import 'package:flutter_app/page/headline_news/headline_news.dart';
  8. //import 'package:flutter_app/page/instagram_feed/instagram_feed.dart';
  9. //import 'package:flutter_app/page/twitter_feed/twitter_feed.dart';
  10. //import 'package:page_transition/page_transition.dart';
  11.  
  12. //import 'home/home.dart';
  13. import 'package:shared_preferences/shared_preferences.dart';
  14.  
  15. main() async {
  16.   WidgetsFlutterBinding.ensureInitialized();
  17.  
  18.   SharedPreferences prefs = await SharedPreferences.getInstance();
  19.   bool seen = prefs.getBool('seen');
  20.   Widget _mainScreen;
  21.   if (seen == null || seen == false) {
  22.     _mainScreen = StartPage();
  23.   } else {
  24.     _mainScreen = GetPage();
  25.   }
  26.   return runApp(MyApp(_mainScreen));
  27. }
  28.  
  29. class MyApp extends StatelessWidget {
  30. //  Locale locale;
  31.   final Widget _mainScreen;
  32.   MyApp(this._mainScreen);
  33.   @override
  34.   Widget build(BuildContext context) {
  35.     // TODO: implement build
  36.     return MaterialApp(
  37.       localizationsDelegates: [
  38.         // ... app-specific localization delegate[s] here
  39.         AppLocalizations.delegate,
  40.  
  41.         GlobalMaterialLocalizations.delegate,
  42.         GlobalWidgetsLocalizations.delegate,
  43. //        GlobalCupertinoLocalizations.delegate,
  44.       ],
  45.       supportedLocales: [
  46.         const Locale('ar'), // Arabic
  47.         const Locale('en'), // English
  48. //        const Locale.fromSubtags(languageCode: 'zh'), // Chinese *See Advanced Locales below*
  49.         // ... other locales the app supports
  50.       ],
  51.       localeResolutionCallback: (locale, supportedLocales) {
  52.         for (var supportedLocale in supportedLocales) {
  53.           if (supportedLocale.languageCode == locale.languageCode) {
  54.             return supportedLocale;
  55.           }
  56.         }
  57.         return supportedLocales.first;
  58.       },
  59.       title: "testApp",
  60.       theme: ThemeData(
  61.           primaryColor: Colors.red,
  62.           accentColor: Colors.grey,
  63.           accentIconTheme: IconThemeData(color: Colors.white)),
  64.       // ignore: unrelated_type_equality_checks
  65.       home: _mainScreen,
  66. //      onGenerateRoute: (settings) {
  67. //        switch (settings.name) {
  68. //          case '/Home':
  69. ////            return PageTransition(child: Home(openDrawer), type: PageTransitionType.rightToLeft);
  70. //            break;
  71. //          case '/HeadlineNews':
  72. //            return PageTransition(child: HeadlineNews(), type: PageTransitionType.rightToLeft);
  73. //            break;
  74. //          case '/TwitterFeed':
  75. //            return PageTransition(child: TwitterFeed(), type: PageTransitionType.rightToLeft);
  76. //            break;
  77. //          case '/InstagramFeed':
  78. //            return PageTransition(child: InstagramFeed(), type: PageTransitionType.rightToLeft);
  79. //            break;
  80. //          default:
  81. //            return null;
  82. //        }
  83. //      },
  84.     );
  85.   }
  86. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top