示例#1
0
 public MaterialApp(
     Key key = null,
     GlobalKey <NavigatorState> navigatorKey = null,
     Widget home = null,
     Dictionary <string, WidgetBuilder> routes = null,
     string initialRoute          = null,
     RouteFactory onGenerateRoute = null,
     InitialRouteListFactory onGenerateInitialRoutes = null,
     RouteFactory onUnknownRoute = null,
     List <NavigatorObserver> navigatorObservers = null,
     TransitionBuilder builder = null,
     string title = "",
     GenerateAppTitle onGenerateTitle = null,
     Color color         = null,
     ThemeData theme     = null,
     ThemeData darkTheme = null,
     ThemeMode themeMode = ThemeMode.system,
     Locale locale       = null,
     List <LocalizationsDelegate> localizationsDelegates       = null,
     LocaleListResolutionCallback localeListResolutionCallback = null,
     LocaleResolutionCallback localeResolutionCallback         = null,
     List <Locale> supportedLocales               = null,
     bool showPerformanceOverlay                  = false,
     bool checkerboardRasterCacheImages           = false,
     bool checkerboardOffscreenLayers             = false,
     bool debugShowCheckedModeBanner              = true,
     Dictionary <LogicalKeySet, Intent> shortcuts = null,
     Dictionary <LocalKey, ActionFactory> actions = null
     ) : base(key: key)
 {
     supportedLocales = supportedLocales ?? new List <Locale> {
         new Locale("en", "US")
     };
     this.navigatorKey                  = navigatorKey;
     this.home                          = home;
     this.routes                        = routes ?? new Dictionary <string, WidgetBuilder>();
     this.onGenerateInitialRoutes       = onGenerateInitialRoutes;
     this.initialRoute                  = initialRoute;
     this.onGenerateRoute               = onGenerateRoute;
     this.onUnknownRoute                = onUnknownRoute;
     this.navigatorObservers            = navigatorObservers ?? new List <NavigatorObserver>();
     this.builder                       = builder;
     this.title                         = title;
     this.onGenerateTitle               = onGenerateTitle;
     this.color                         = color;
     this.theme                         = theme;
     this.darkTheme                     = darkTheme;
     this.themeMode                     = themeMode;
     this.locale                        = locale;
     this.localizationsDelegates        = localizationsDelegates;
     this.localeListResolutionCallback  = localeListResolutionCallback;
     this.localeResolutionCallback      = localeResolutionCallback;
     this.supportedLocales              = supportedLocales;
     this.showPerformanceOverlay        = showPerformanceOverlay;
     this.checkerboardRasterCacheImages = checkerboardRasterCacheImages;
     this.checkerboardOffscreenLayers   = checkerboardOffscreenLayers;
     this.debugShowCheckedModeBanner    = debugShowCheckedModeBanner;
     this.shortcuts                     = shortcuts;
     this.actions                       = actions;
 }
示例#2
0
        public CupertinoApp(
            Key key = null,
            GlobalKey <NavigatorState> navigatorKey = null,
            Widget home = null,
            CupertinoThemeData theme = null,
            Dictionary <string, WidgetBuilder> routes = null,
            string initialRoute          = null,
            RouteFactory onGenerateRoute = null,
            RouteFactory onUnknownRoute  = null,
            List <NavigatorObserver> navigatorObservers = null,
            TransitionBuilder builder = null,
            string title = "",
            GenerateAppTitle onGenerateTitle = null,
            Color color   = null,
            Locale locale = null,
            List <LocalizationsDelegate <CupertinoLocalizations> > localizationsDelegates = null,
            LocaleListResolutionCallback localeListResolutionCallback = null,
            LocaleResolutionCallback localeResolutionCallback         = null,
            List <Locale> supportedLocales = null,
            bool showPerformanceOverlay    = false
            ) : base(key: key)
        {
            D.assert(title != null);

            supportedLocales = supportedLocales ?? new List <Locale> {
                new Locale("en", "US")
            };
            this.navigatorKey                 = navigatorKey;
            this.home                         = home;
            this.theme                        = theme;
            this.routes                       = routes ?? new Dictionary <string, WidgetBuilder>();
            this.initialRoute                 = initialRoute;
            this.onGenerateRoute              = onGenerateRoute;
            this.onUnknownRoute               = onUnknownRoute;
            this.navigatorObservers           = navigatorObservers ?? new List <NavigatorObserver>();
            this.builder                      = builder;
            this.title                        = title;
            this.onGenerateTitle              = onGenerateTitle;
            this.color                        = color;
            this.locale                       = locale;
            this.localizationsDelegates       = localizationsDelegates;
            this.localeListResolutionCallback = localeListResolutionCallback;
            this.localeResolutionCallback     = localeResolutionCallback;
            this.supportedLocales             = supportedLocales;
            this.showPerformanceOverlay       = showPerformanceOverlay;
        }
示例#3
0
        public WidgetsApp(
            Key key = null,
            GlobalKey <NavigatorState> navigatorKey     = null,
            RouteFactory onGenerateRoute                = null,
            RouteFactory onUnknownRoute                 = null,
            PageRouteFactory pageRouteBuilder           = null,
            List <NavigatorObserver> navigatorObservers = null,
            string initialRoute = null,
            Dictionary <string, WidgetBuilder> routes = null,
            TransitionBuilder builder = null,
            TextStyle textStyle       = null,
            Widget home   = null,
            Locale locale = null,
            List <LocalizationsDelegate> localizationsDelegates       = null,
            LocaleListResolutionCallback localeListResolutionCallback = null,
            LocaleResolutionCallback localeResolutionCallback         = null,
            List <Locale> supportedLocales = null,
            bool showPerformanceOverlay    = false
            ) : base(key)
        {
            routes           = routes ?? new Dictionary <string, WidgetBuilder>();
            supportedLocales = supportedLocales ?? new List <Locale> {
                new Locale("en", "US")
            };
            this.window                       = Window.instance;
            this.home                         = home;
            this.navigatorKey                 = navigatorKey;
            this.onGenerateRoute              = onGenerateRoute;
            this.onUnknownRoute               = onUnknownRoute;
            this.pageRouteBuilder             = pageRouteBuilder;
            this.routes                       = routes;
            this.navigatorObservers           = navigatorObservers ?? new List <NavigatorObserver>();
            this.initialRoute                 = initialRoute;
            this.builder                      = builder;
            this.textStyle                    = textStyle;
            this.locale                       = locale;
            this.localizationsDelegates       = localizationsDelegates;
            this.localeListResolutionCallback = localeListResolutionCallback;
            this.localeResolutionCallback     = localeResolutionCallback;
            this.supportedLocales             = supportedLocales;
            this.showPerformanceOverlay       = showPerformanceOverlay;

            D.assert(
                home == null ||
                !this.routes.ContainsKey(Navigator.defaultRouteName),
                "If the home property is specified, the routes table " +
                "cannot include an entry for \" / \", since it would be redundant."
                );

            D.assert(
                builder != null ||
                home != null ||
                this.routes.ContainsKey(Navigator.defaultRouteName) ||
                onGenerateRoute != null ||
                onUnknownRoute != null,
                "Either the home property must be specified, " +
                "or the routes table must include an entry for \"/\", " +
                "or there must be on onGenerateRoute callback specified, " +
                "or there must be an onUnknownRoute callback specified, " +
                "or the builder property must be specified, " +
                "because otherwise there is nothing to fall back on if the " +
                "app is started with an intent that specifies an unknown route."
                );

            D.assert(
                builder != null ||
                onGenerateRoute != null ||
                pageRouteBuilder != null,
                "If neither builder nor onGenerateRoute are provided, the " +
                "pageRouteBuilder must be specified so that the default handler " +
                "will know what kind of PageRoute transition to build."
                );
        }
示例#4
0
        public WidgetsApp(
            Key key = null,
            GlobalKey <NavigatorState> navigatorKey         = null,
            RouteFactory onGenerateRoute                    = null,
            InitialRouteListFactory onGenerateInitialRoutes = null,
            RouteFactory onUnknownRoute = null,
            List <NavigatorObserver> navigatorObservers = null,
            string initialRoute = null,
            PageRouteFactory pageRouteBuilder = null,
            Widget home = null,
            Dictionary <string, WidgetBuilder> routes = null,
            TransitionBuilder builder = null,
            string title = "",
            GenerateAppTitle onGenerateTitle = null,
            TextStyle textStyle = null,
            Color color         = null,
            Locale locale       = null,
            List <LocalizationsDelegate> localizationsDelegates       = null,
            LocaleListResolutionCallback localeListResolutionCallback = null,
            LocaleResolutionCallback localeResolutionCallback         = null,
            List <Locale> supportedLocales     = null,
            bool showPerformanceOverlay        = false,
            bool checkerboardRasterCacheImages = false,
            bool checkerboardOffscreenLayers   = false,
            bool showSemanticsDebugger         = false,
            bool debugShowWidgetInspector      = false,
            bool debugShowCheckedModeBanner    = true,
            InspectorSelectButtonBuilder inspectorSelectButtonBuilder = null,
            Dictionary <LogicalKeySet, Intent> shortcuts = null,
            Dictionary <LocalKey, ActionFactory> actions = null
            ) : base(key: key)
        {
            routes           = routes ?? new Dictionary <string, WidgetBuilder>();
            supportedLocales = supportedLocales ?? new List <Locale> {
                new Locale("en", "US")
            };
            window = Window.instance;
            D.assert(routes != null);
            D.assert(color != null);
            D.assert(supportedLocales != null && supportedLocales.isNotEmpty());
            this.home                          = home;
            this.navigatorKey                  = navigatorKey;
            this.onGenerateRoute               = onGenerateRoute;
            this.onGenerateInitialRoutes       = onGenerateInitialRoutes;
            this.onUnknownRoute                = onUnknownRoute;
            this.pageRouteBuilder              = pageRouteBuilder;
            this.routes                        = routes;
            this.navigatorObservers            = navigatorObservers ?? new List <NavigatorObserver>();
            this.initialRoute                  = initialRoute;
            this.builder                       = builder;
            this.textStyle                     = textStyle;
            this.locale                        = locale;
            this.localizationsDelegates        = localizationsDelegates;
            this.localeListResolutionCallback  = localeListResolutionCallback;
            this.localeResolutionCallback      = localeResolutionCallback;
            this.supportedLocales              = supportedLocales;
            this.showPerformanceOverlay        = showPerformanceOverlay;
            this.checkerboardOffscreenLayers   = checkerboardOffscreenLayers;
            this.checkerboardRasterCacheImages = checkerboardRasterCacheImages;
            this.showSemanticsDebugger         = showSemanticsDebugger;
            this.debugShowWidgetInspector      = debugShowWidgetInspector;
            this.debugShowCheckedModeBanner    = debugShowCheckedModeBanner;
            this.onGenerateTitle               = onGenerateTitle;
            this.title                         = title;
            this.color                         = color;
            this.inspectorSelectButtonBuilder  = inspectorSelectButtonBuilder;
            this.shortcuts                     = shortcuts;
            this.actions                       = actions;

            D.assert(
                home == null ||
                onGenerateInitialRoutes == null,
                () => "If onGenerateInitialRoutes is specifiied, the home argument will be redundant."
                );
            D.assert(
                home == null ||
                !this.routes.ContainsKey(key: Navigator.defaultRouteName),
                () => "If the home property is specified, the routes table " +
                "cannot include an entry for \" / \", since it would be redundant."
                );

            D.assert(
                builder != null ||
                home != null ||
                this.routes.ContainsKey(key: Navigator.defaultRouteName) ||
                onGenerateRoute != null ||
                onUnknownRoute != null,
                () => "Either the home property must be specified, " +
                "or the routes table must include an entry for \"/\", " +
                "or there must be on onGenerateRoute callback specified, " +
                "or there must be an onUnknownRoute callback specified, " +
                "or the builder property must be specified, " +
                "because otherwise there is nothing to fall back on if the " +
                "app is started with an intent that specifies an unknown route."
                );
            D.assert(
                home != null ||
                routes.isNotEmpty() ||
                onGenerateRoute != null ||
                onUnknownRoute != null
                ||
                builder != null &&
                navigatorKey == null &&
                initialRoute == null &&
                navigatorObservers.isEmpty(), () =>
                "If no route is provided using " +
                "home, routes, onGenerateRoute, or onUnknownRoute, " +
                "a non-null callback for the builder property must be provided, " +
                "and the other navigator-related properties, " +
                "navigatorKey, initialRoute, and navigatorObservers, " +
                "must have their initial values " +
                "(null, null, and the empty list, respectively).");

            D.assert(
                builder != null ||
                onGenerateRoute != null ||
                pageRouteBuilder != null,
                () => "If neither builder nor onGenerateRoute are provided, the " +
                "pageRouteBuilder must be specified so that the default handler " +
                "will know what kind of PageRoute transition to build."
                );
        }