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.widget] 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 : final Page Function(LocalKey key, Widget child) pageBuilder; 48 : 49 : final Widget widget; 50 : 51 : final LocalKey? key; 52 : 53 2 : VPage({ 54 : required this.path, 55 : required this.pageBuilder, 56 : required this.widget, 57 : this.stackedRoutes = const [], 58 : this.key, 59 : this.name, 60 : this.aliases = const [], 61 : this.mustMatchStackedRoute = false, 62 : }); 63 : 64 2 : @override 65 2 : List<VRouteElement> buildRoutes() => [ 66 2 : VPath( 67 2 : path: path, 68 2 : name: name, 69 2 : aliases: aliases, 70 2 : mustMatchStackedRoute: mustMatchStackedRoute, 71 2 : stackedRoutes: [ 72 2 : VPageBase( 73 2 : pageBuilder: pageBuilder, 74 2 : widget: widget, 75 2 : key: key, 76 2 : stackedRoutes: stackedRoutes, 77 : ), 78 : ], 79 : ) 80 : ]; 81 : }