LCOV - code coverage report
Current view: top level - src/vroute_elements - vpage.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 14 14 100.0 %
Date: 2021-04-29 14:25:52 Functions: 0 0 -

          Line data    Source code
       1             : part of '../main.dart';
       2             : 
       3             : class VPage extends VRouteElementBuilder {
       4             :   /// The path (relative or absolute) or this [VRouteElement]
       5             :   ///
       6             :   /// If the path of a subroute is exactly matched, this will be used in
       7             :   /// the route but might be covered by another [VRouteElement._rootVRouter]
       8             :   /// The value of the path ca have three form:
       9             :   ///     * starting with '/': The path will be treated as a route path,
      10             :   ///       this is useful to take full advantage of nested routes while
      11             :   ///       conserving the freedom of path naming
      12             :   ///     * not starting with '/': The path corresponding to this route
      13             :   ///       will be the path of the parent route + this path. If this is used
      14             :   ///       directly in the [VRouter] routes, a '/' will be added anyway
      15             :   ///     * be null: In this case this path will match the parent path
      16             :   ///
      17             :   /// Note we use the package [path_to_regexp](https://pub.dev/packages/path_to_regexp)
      18             :   /// so you can use naming such as /user/:id to get the id (see [VRouteElementData.pathParameters]
      19             :   /// You can also use more advance technique using regexp directly in your path, for example
      20             :   /// '.*' will match any route, '/user/:id(\d+)' will match any route starting with user
      21             :   /// and followed by a digit. Here is a recap:
      22             :   /// |     pattern       | matched path |      [VRouter.pathParameters]
      23             :   /// | /user/:username |  /user/evan  |         { username: 'evan' }
      24             :   /// | /user/:id(\d+)  |  /user/123   |             { id: '123' }
      25             :   /// |     .*          |  every path  |             -
      26             :   final String? path;
      27             : 
      28             :   /// A name for the route which will allow you to easily navigate to it
      29             :   /// using [VRouter.of(context).pushNamed]
      30             :   ///
      31             :   /// Note that [name] should be unique w.r.t every [VRouteElement]
      32             :   final String? name;
      33             : 
      34             :   /// Alternative paths that will be matched to this route
      35             :   ///
      36             :   /// Note that path is match first, then every aliases in order
      37             :   final List<String> aliases;
      38             : 
      39             :   /// A boolean to indicate whether this can be a valid [VRouteElement] of the [VRoute] if no
      40             :   /// [VRouteElement] in its [stackedRoute] is matched
      41             :   ///
      42             :   /// This is mainly useful for [VRouteElement]s which are NOT [VRouteElementWithPage]
      43             :   final bool mustMatchStackedRoute;
      44             : 
      45             :   final List<VRouteElement> stackedRoutes;
      46             : 
      47             :   /// Function which returns a page that will wrap [widget]
      48             :   ///   - key and name should be given to your [Page]
      49             :   ///   - child should be placed as the last child in [Route]
      50             :   final Page Function(LocalKey key, Widget child, String? name) pageBuilder;
      51             : 
      52             :   /// The widget which will be displayed for this [VRouteElement]
      53             :   /// inside the given page
      54             :   final Widget widget;
      55             : 
      56             :   /// A LocalKey that will be given to the page which contains the given [widget]
      57             :   ///
      58             :   /// This key mostly controls the page animation. If a page remains the same but the key is changes,
      59             :   /// the page gets animated
      60             :   /// The key is by default the value of the current [path] (or [aliases]) with
      61             :   /// the path parameters replaced
      62             :   ///
      63             :   /// Do provide a constant [key] if you don't want this page to animate even if [path] or
      64             :   /// [aliases] path parameters change
      65             :   final LocalKey? key;
      66             : 
      67           2 :   VPage({
      68             :     required this.path,
      69             :     required this.pageBuilder,
      70             :     required this.widget,
      71             :     this.stackedRoutes = const [],
      72             :     this.key,
      73             :     this.name,
      74             :     this.aliases = const [],
      75             :     this.mustMatchStackedRoute = false,
      76             :   });
      77             : 
      78           2 :   @override
      79           2 :   List<VRouteElement> buildRoutes() => [
      80           2 :         VPath(
      81           2 :           path: path,
      82           2 :           aliases: aliases,
      83           2 :           mustMatchStackedRoute: mustMatchStackedRoute,
      84           2 :           stackedRoutes: [
      85           2 :             VPageBase(
      86           2 :               pageBuilder: pageBuilder,
      87           2 :               widget: widget,
      88           2 :               key: key,
      89           2 :               name: name,
      90           2 :               stackedRoutes: stackedRoutes,
      91             :             ),
      92             :           ],
      93             :         )
      94             :       ];
      95             : }

Generated by: LCOV version 1.14