{"id":15713278,"url":"https://github.com/jonaswanke/flutter_deep_linking","last_synced_at":"2025-05-07T21:44:49.830Z","repository":{"id":51026012,"uuid":"244335296","full_name":"JonasWanke/flutter_deep_linking","owner":"JonasWanke","description":"🧭 Handle all your routing with proper deep links and handle them declaratively!","archived":false,"fork":false,"pushed_at":"2024-09-03T20:56:19.000Z","size":94,"stargazers_count":8,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-31T14:22:16.524Z","etag":null,"topics":["dart","declarative","deep-linking","flutter","navigation","package","routing","uri"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/flutter_deep_linking","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JonasWanke.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"JonasWanke"}},"created_at":"2020-03-02T09:50:12.000Z","updated_at":"2023-09-19T17:36:50.000Z","dependencies_parsed_at":"2024-10-24T10:49:47.528Z","dependency_job_id":"1dfeb522-f9e4-441c-8273-2347619b1e7f","html_url":"https://github.com/JonasWanke/flutter_deep_linking","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonasWanke%2Fflutter_deep_linking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonasWanke%2Fflutter_deep_linking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonasWanke%2Fflutter_deep_linking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonasWanke%2Fflutter_deep_linking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JonasWanke","download_url":"https://codeload.github.com/JonasWanke/flutter_deep_linking/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252961835,"owners_count":21832190,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dart","declarative","deep-linking","flutter","navigation","package","routing","uri"],"created_at":"2024-10-03T21:22:05.141Z","updated_at":"2025-05-07T21:44:49.807Z","avatar_url":"https://github.com/JonasWanke.png","language":"Dart","funding_links":["https://github.com/sponsors/JonasWanke"],"categories":[],"sub_categories":[],"readme":"🧭 Handle all your routing with proper deep links and handle them declaratively!\n\n### What this package is about\n\nThis package takes declaratively defined [`Route`]s and receives a URI during navigation, evaluates those and then returns a [`PageRoute`] for the correct page. This means, you can now benefit from loose coupling and navigate using:\n\n```dart\nNavigator.of(context).pushNamed('/articles/$id')\n```\n\ninstead of hardcoding the corresponding widget everytime:\n\n```dart\nNavigator.of(context)\n  .push(MaterialPageRoute(builder: (_) =\u003e ArticlePage(id)));\n```\n\n\n### What this package is not about\n\nThis package doesn't catch incoming deep links from other apps. For this, I recommend [\u003ckbd\u003euni_links\u003c/kbd\u003e](https://pub.dev/packages/uni_links).\n\nYou can, however, combine both packages. Just forward any received deep links to your `Navigator` and `flutter_deep_linking` takes care of resolving them. This also works with the initial deep link:\n\n```dart\nString initialLink = await getInitialLink(); // from uni_links\nreturn MaterialApp(\n  initialRoute: initialLink,\n  onGenerateRoute: router.onGenerateRoute,   // from flutter_deep_linking\n  // ...\n);\n```\n\n\n## Getting started\n\n### 1. 🧭 Create a [`Router`] containing all your routes:\n\n```dart\nfinal router = Router(\n  routes: [\n    Route(\n      // This matches any HTTP or HTTPS URI pointing to schul-cloud.org.\n      // Due to `isOptional`, this also matches URIs without a scheme or domain,\n      // but not other domains.\n      matcher: Matcher.webHost('schul-cloud.org', isOptional: true),\n      // These nested routes are evaluated only if the above condition matches.\n      routes: [\n        Route(\n          matcher: Matcher.path('courses'),\n          materialBuilder: (_, __) =\u003e CoursesPage(),\n          routes: [\n            // If this route matches, it is used. Otherwise, we fall back to the\n            // outer courses-route.\n            Route(\n              // {courseId} is a parameter matches a single path segment.\n              matcher: Matcher.path('{courseId}'),\n              materialBuilder: (_, RouteResult result) {\n                // You can access the matched parameters using `result[\u003cname\u003e]`.\n                return CourseDetailPage(result['courseId']);\n              },\n            ),\n          ],\n        ),\n        Route(\n          // Matcher.path can also match nested paths.\n          matcher: Matcher.path('user/settings'),\n          materialBuilder: (_, __) =\u003e SettingsPage(),\n        ),\n      ],\n    ),\n    // This route doesn't specify a matcher and hence matches any route.\n    Route(\n      materialBuilder: (_, RouteResult result) =\u003e NotFoundPage(result.uri),\n    ),\n  ],\n);\n```\n\n\u003e **Note:** Flutter also defines classes called `Route` \u0026 `RouteBuilder` which can lead to some confusion. If you import `package:flutter/widgets.dart` in the same file as `flutter_deep_linking`, you can ignore Flutter's `Route` \u0026 `RouteBuilder` with `import 'package:flutter/widgets.dart' hide Route, RouteBuilder;`.\n\n[`Router`] accepts a list of [`Route`]s which are searched top to bottom, depth first. Using [`Matcher`]s you can match parts of the URI. Inner [`Matcher`]s can't access parts of the URI that have already been matched by an outer [`Matcher`].\n\nTo build the actual page, you can specify either of:\n\n- [`Route.builder`]: Takes a [`RouteResult`] and returns an instance of Flutter's [`Route`][widgets.Route].\n- [`Route.materialBuilder`] (Convenience property): Takes a [`BuildContext`] and a [`RouteResult`] and returns a widget, which is then wrapped in [`MaterialPageRoute`].\n\n\n### 2. 🎯 Let your [`Router`] take care of resolving URIs in `MaterialApp` (or `CupertinoApp` or a custom `Navigator`):\n\n```dart\nMaterialApp(\n  onGenerateRoute: router.onGenerateRoute,\n  // ...\n)\n```\n\n\n### 3. 🚀 Use your new routes!\n\nWhen navigating, use `navigator.pushNamed(uriString)` instead of calling `navigator.push(builder)` and benefit from loose coupling!\n\nAnd if you build an app in addition to a website, you can use a package like [uni_links] to receive incoming links and directly forward them to `flutter_deep_linking`.\n\n\n## More information\n\n### [`Matcher`]s\n\nAvailable [`Matcher`]s:\n\n- `Matcher.scheme`: Matches a URI scheme like `https`.\n- `Matcher.webScheme`: Conveniently matches `http` or `https`.\n- `Matcher.host`: Matches a URI host like `schul-cloud.org`.\n- `Matcher.webHost`: Conveniently matches a `webScheme` (see above) and a URI host.\n- `Matcher.path`: Matches a single or multiple URI path segments like `courses/{courseId}`, whereas `courseId` is a placeholder and will match exactly one segment.\n\nYou can also combine [`Matcher`]s within a single [`Route`]:\n\n- `matcher1 \u0026 matcher2` matches both [`Matcher`]s in sequence.\n- `matcher1 | matcher2` evaluates both [`Matcher`]s in sequence and returns the first match.\n\n\n### [`RouteResult`]\n\n[`RouteResult`] most importantly contains:\n\n- `uri`: The initial URI (which can be used, e.g., to access query parameters).\n- `parameters`: A `Map\u003cString, String\u003e` of matched parameters, also accessible via `result[\u003cname\u003e]`.\n- `settings`: The `RouteSettings` that should be forwarded to the generated (Flutter) `Route`.\n\n\n[uni_links]: https://pub.dev/packages/uni_links\n\u003c!-- Flutter --\u003e\n[`MaterialPageRoute`]: https://api.flutter.dev/flutter/material/MaterialPageRoute-class.html\n[`PageRoute`]: https://api.flutter.dev/flutter/widgets/PageRoute-class.html\n[widgets.Route]: https://api.flutter.dev/flutter/widgets/Route-class.html\n\u003c!-- flutter_deep_linking --\u003e\n[`Matcher`]: https://pub.dev/documentation/flutter_deep_linking/latest/flutter_deep_linking/Matcher-class.html\n[`Route`]: https://pub.dev/documentation/flutter_deep_linking/latest/flutter_deep_linking/Route-class.html\n[`Route.builder`]: https://pub.dev/documentation/flutter_deep_linking/latest/flutter_deep_linking/Route/builder.html\n[`Route.materialBuilder`]: https://pub.dev/documentation/flutter_deep_linking/latest/flutter_deep_linking/Route/materialBuilder.html\n[`RouteResult`]: https://pub.dev/documentation/flutter_deep_linking/latest/flutter_deep_linking/RouteResult-class.html\n[`Router`]: https://pub.dev/documentation/flutter_deep_linking/latest/flutter_deep_linking/Router-class.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonaswanke%2Fflutter_deep_linking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonaswanke%2Fflutter_deep_linking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonaswanke%2Fflutter_deep_linking/lists"}