Пример #1
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,
            Window window             = null,
            TextStyle textStyle       = null,
            Widget home = null
            ) : base(key)
        {
            D.assert(window != null);
            routes                  = routes ?? new Dictionary <string, WidgetBuilder>();
            this.window             = window;
            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;

            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."
                );
        }
Пример #2
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."
                );
        }
Пример #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,
            GenerateAppTitle onGenerateTitle = null,
            string title = "",
            Color color  = null,
            InspectorSelectButtonBuilder inspectorSelectButtonBuilder = null
            ) : 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;

            this.onGenerateTitle = onGenerateTitle;
            this.title           = title;
            this.color           = color;
            this.inspectorSelectButtonBuilder = inspectorSelectButtonBuilder;

            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."
                );
        }