typed_deep_links 0.1.0 copy "typed_deep_links: ^0.1.0" to clipboard
typed_deep_links: ^0.1.0 copied to clipboard

Type-safe, router-agnostic deep links with generated URI parsing and building.

example/example.dart

import 'package:typed_deep_links/typed_deep_links.dart';

part 'example.g.dart';

@DeepLink('/orders/')
final class OrderLink {
  const OrderLink({required this.id, this.source});

  final int id;

  @QueryParameter()
  final String? source;
}

@DeepLink('/products/:slug')
final class ProductLink {
  const ProductLink(this.slug, {this.preview = false});

  final String slug;

  @QueryParameter()
  final bool preview;
}

void main() {
  final link = DeepLinks.parse(Uri.parse('/orders/42?source=email'));

  switch (link) {
    case OrderLink(:final id, :final source):
      print('Open order $id from $source');
    case ProductLink(:final slug):
      print('Open product $slug');
  }

  final uri = const OrderLink(id: 42, source: 'notification').toUri();
  print(uri); // /orders/42?source=notification
}
0
likes
0
points
188
downloads

Publisher

verified publisherpinz.dev

Weekly Downloads

Type-safe, router-agnostic deep links with generated URI parsing and building.

Repository (GitHub)
View/report issues

Topics

#deep-linking #code-generation #routing #uri #flutter

License

unknown (license)

Dependencies

analyzer, build, meta, source_gen

More

Packages that depend on typed_deep_links