Flutter WidgetsApp路由相关属性注释翻译。MaterialApp, CupertinoApp

Flutter WidgetsApp路由相关属性注释翻译。MaterialApp, CupertinoApp,第1张

/// {@template flutter.widgets.widgetsApp.navigatorKey}
  /// A key to use when building the [Navigator].
  /// 创建[Navigator]时会用到的一个key
  ///
  /// If a [navigatorKey] is specified, the [Navigator] can be directly
  /// manipulated without first obtaining it from a [BuildContext] via
  /// [Navigator.of]: from the [navigatorKey], use the [GlobalKey.currentState]
  /// getter.
  /// 如果[navigatorKey]是已指定的,
  /// 则[Navigator]不需要通过[BuildContext]来首次获取,就可以直接 *** 作
  /// [Navigator.of]:通过[navigatorKey],使用[GlobalKey.currentState] getter方法
  ///
  /// If this is changed, a new [Navigator] will be created, losing all the
  /// application state in the process; in that case, the [navigatorObservers]
  /// must also be changed, since the previous observers will be attached to the
  /// previous navigator.
  /// 如果navigatorKey被改变,新的[Navigator]将会被创建,所有正在进行的应用状态将会丢失;
  /// 因为前一个[navigatorObservers]关联了前一个navigator,所以[navigatorObservers]也必须被改变。
  ///
  /// The [Navigator] is only built if [onGenerateRoute] is not null; if it is
  /// null, [navigatorKey] must also be null.
  /// 只有[onGenerateRoute]不为空,[Navigator]才会被创建;
  /// 如果[onGenerateRoute]为空,[navigatorKey]一样也必须为空
  ///
  /// {@endtemplate}
  final GlobalKey? navigatorKey;

  /// {@template flutter.widgets.widgetsApp.onGenerateRoute}
  /// The route generator callback used when the app is navigated to a
  /// named route.
  /// 触发于应用导航到一个命名路由时,的路由生成器回调
  ///
  /// If this returns null when building the routes to handle the specified
  /// [initialRoute], then all the routes are discarded and
  /// [Navigator.defaultRouteName] is used instead (`/`). See [initialRoute].
  /// 当创建用于处理具体的[initialRoute]的路由时,若返回空,
  /// 之后所有的路由会被丢弃,同时[Navigator.defaultRouteName]会被使用,而不是(`/`)。
  /// 具体查阅[initialRoute]
  ///
  /// During normal app operation, the [onGenerateRoute] callback will only be
  /// applied to route names pushed by the application, and so should never
  /// return null.
  /// 处于正常的app *** 作时,[onGenerateRoute]回调只会应用于命名路由的push *** 作,
  /// 由此,[onGenerateRoute]不会返回空
  ///
  /// This is used if [routes] does not contain the requested route.
  /// [onGenerateRoute]用于当[routes]不包含【the requested route】时
  ///
  /// The [Navigator] is only built if routes are provided (either via [home],
  /// [routes], [onGenerateRoute], or [onUnknownRoute]); if they are not,
  /// [builder] must not be null.
  /// {@endtemplate}
  /// [Navigator]只会创建当路由提供(或者通过[home]),
  /// [routes],[onGenerateRoute], or [onUnknownRoute]);
  /// 如果以上未提供,[builder]必须不为空
  ///
  /// If this property is not set, either the [routes] or [home] properties must
  /// be set, and the [pageRouteBuilder] must also be set so that the
  /// default handler will know what routes and [PageRoute]s to build.
  /// 如果这个属性未设置,则[routes] or [home]必须设置,
  /// 并且[pageRouteBuilder]也需要设置
  /// 好让默认处理其知道路由和[PageRoute]s创建
  ///
  final RouteFactory? onGenerateRoute;

  /// {@template flutter.widgets.widgetsApp.onGenerateInitialRoutes}
  /// The routes generator callback used for generating initial routes if
  /// [initialRoute] is provided.
  /// 触发于当[initialRoute]有提供,生成初始路由时的路由生成器回调
  ///
  /// If this property is not set, the underlying
  /// [Navigator.onGenerateInitialRoutes] will default to
  /// [Navigator.defaultGenerateInitialRoutes].
  /// 如果该属性未设置,会默认为[Navigator.defaultGenerateInitialRoutes]
  ///
  /// {@endtemplate}
  ///
  final InitialRouteListFactory? onGenerateInitialRoutes;

  /// The [PageRoute] generator callback used when the app is navigated to a
  /// named route.
  /// [PageRoute]生成器回调,触发于app导航到命名路由
  ///
  /// This callback can be used, for example, to specify that a [MaterialPageRoute]
  /// or a [CupertinoPageRoute] should be used for building page transitions.
  final PageRouteFactory? pageRouteBuilder;

  /// {@template flutter.widgets.widgetsApp.routeInformationParser}
  /// A delegate to parse the route information from the
  /// [routeInformationProvider] into a generic data type to be processed by
  /// the [routerDelegate] at a later stage.
  /// 一个用于解析路由信息(信息来自[routeInformationProvider])的代理,
  /// 该代理将路由信息解析成范型数据类型,
  /// 以便[routerDelegate]在之后的阶段处理
  ///
  /// This object will be used by the underlying [Router].
  /// 该对象会被潜在的[Router]使用
  ///
  /// The generic type `T` must match the generic type of the [routerDelegate].
  /// 该范型'T'必须匹配[routerDelegate]的范型
  ///
  /// See also:
  ///
  ///  * [Router.routeInformationParser]: which receives this object when this
  ///    widget builds the [Router].
  /// {@endtemplate}
  final RouteInformationParser? routeInformationParser;

  /// {@template flutter.widgets.widgetsApp.routerDelegate}
  /// A delegate that configures a widget, typically a [Navigator], with
  /// parsed result from the [routeInformationParser].
  /// 一个配置widget的代理(特别是一个[Navigator]),
  /// 带有[routeInformationParser]的解析结果。
  ///
  /// This object will be used by the underlying [Router].
  /// 这个对象会被潜在的[Router]使用
  ///
  /// The generic type `T` must match the generic type of the
  /// [routeInformationParser].
  /// 范型类型'T'必须匹配[routeInformationParser]的范型类型
  ///
  /// See also:
  ///
  ///  * [Router.routerDelegate]: which receives this object when this widget
  ///    builds the [Router].
  ///    [Router.routerDelegate]: 当这个widget创建[Router]时,会收到这个对象
  /// {@endtemplate}
  final RouterDelegate? routerDelegate;

  /// {@template flutter.widgets.widgetsApp.backButtonDispatcher}
  /// A delegate that decide whether to handle the Android back button intent.
  /// 决定是否处理安卓返回按钮intent的代理
  ///
  /// This object will be used by the underlying [Router].
  /// 这个对象会被潜在的[Router]所使用
  ///
  /// If this is not provided, the widgets app will create a
  /// [RootBackButtonDispatcher] by default.
  /// 如果未提供本属性,widgets app会默认创建一个[RootBackButtonDispatcher]
  ///
  /// See also:
  ///
  ///  * [Router.backButtonDispatcher]: which receives this object when this
  ///    widget builds the [Router].
  /// {@endtemplate}
  final BackButtonDispatcher? backButtonDispatcher;

  /// {@template flutter.widgets.widgetsApp.routeInformationProvider}
  /// A object that provides route information through the
  /// [RouteInformationProvider.value] and notifies its listener when its value
  /// changes.
  /// 提供路由信息的对象。
  /// 当值改变时,通过[RouteInformationProvider.value]和通知者的监听者可以拿到路由信息
  ///
  /// This object will be used by the underlying [Router].
  ///
  /// If this is not provided, the widgets app will create a
  /// [PlatformRouteInformationProvider] with initial route name equal to the
  /// [dart:ui.PlatformDispatcher.defaultRouteName] by default.
  /// 若未提供本属性,widgets app会默认创建[PlatformRouteInformationProvider]
  /// [PlatformRouteInformationProvider]自带有与
  /// [dart:ui.PlatformDispatcher.defaultRouteName]相同的初始路由名
  ///
  /// See also:
  ///
  ///  * [Router.routeInformationProvider]: which receives this object when this
  ///    widget builds the [Router].
  /// {@endtemplate}
  final RouteInformationProvider? routeInformationProvider;



/// The application's top-level routing table.
  /// 应用顶层路由表
  ///
  /// When a named route is pushed with [Navigator.pushNamed], the route name is
  /// looked up in this map. If the name is present, the associated
  /// [widgets.WidgetBuilder] is used to construct a [PageRoute] specified by
  /// [pageRouteBuilder] to perform an appropriate transition, including [Hero]
  /// animations, to the new route.
  /// 当一个命名路由被push([Navigator.pushNamed])时,命名路由会查找这个map。
  /// 如果命名存在,关联的[widgets.WidgetBuilder]会被用来构建一个[PageRoute]
  /// 具体由[pageRouteBuilder]来执行一个合适的转场动画(包括[Hero]动画),跳转到新路由
  ///
  /// {@template flutter.widgets.widgetsApp.routes}
  /// If the app only has one page, then you can specify it using [home] instead.
  /// 如果app只有一个页面,可以用[home]代替
  ///
  /// If [home] is specified, then it implies an entry in this table for the
  /// [Navigator.defaultRouteName] route (`/`), and it is an error to
  /// redundantly provide such a route in the [routes] table.
  /// 如果[home]是指定的,则表明一个实体以[Navigator.defaultRouteName]、路由(`/`)存在本表中。
  /// 并且若以相同的路由在本表中提供,则是一个冗余错误。
  ///
  /// If a route is requested that is not specified in this table (or by
  /// [home]), then the [onGenerateRoute] callback is called to build the page
  /// instead.
  /// 如果请求的路由未指定,则作为替代,[onGenerateRoute]回调会调用来创建页面。
  ///
  /// The [Navigator] is only built if routes are provided (either via [home],
  /// [routes], [onGenerateRoute], or [onUnknownRoute]); if they are not,
  /// [builder] must not be null.
  /// 只有提供了本属性[routes](或者通过[home], [routes], [onGenerateRoute], or [onUnknownRoute]),
  /// [Navigator]才会被创建。如果上述都没提供,则[builder]必须不为空
  /// {@endtemplate}
  ///
  /// If the routes map is not empty, the [pageRouteBuilder] property must be set
  /// so that the default route handler will know what kind of [PageRoute]s to
  /// build.
  /// 如果路由表不为空,[pageRouteBuilder]属性必须设置,
  /// 好让默认路由handler知道要创建哪种[PageRoute]s
  final Map? routes;

					
										


					

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/990269.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)