uri_typed_template 0.7.1 copy "uri_typed_template: ^0.7.1" to clipboard
uri_typed_template: ^0.7.1 copied to clipboard

Build and parse URIs with simple declarations based on Dart extensions.

example/main.dart

import 'package:uri_typed_template/uri_typed_template.dart';

void main() {
  UriArgumentSerializers.instance.add<DateTime>(
    (value) => value.microsecondsSinceEpoch.toString(),
    (value) => DateTime.fromMicrosecondsSinceEpoch(int.parse(value)),
  );

  final template = 'album' / 'id'(int) / 'photos' &
      'theme'<String>('dark') &
      'date'<DateTime>();

  print('Templates: $template');

  final uri = template.build(
    {
      'id': 7,
      'theme': 'light',
      'date': DateTime.now(),
    },
  );
  print('Uri: $uri');

  final match1 = template.match('album/7/photos?theme=light');
  print('Match "${match1.value}": ${match1.toString()}');

  final match2 = template.match('album/photos?theme=light');
  print('Match "${match2.value}": ${match2.toString()}');

  final match3 = template.match('album/true/photos?theme=light');
  print('Match "${match3.value}": ${match3.toString()}');
}
0
likes
40
pub points
0%
popularity

Publisher

unverified uploader

Build and parse URIs with simple declarations based on Dart extensions.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

meta

More

Packages that depend on uri_typed_template