Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update example in README file and add it to the example directory #59

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ UriMatch is the result of `UriPattern.match()`. It contains the parameters parse
UriTemplate is an implementation of [RFC 6570 URI Templates][rfc6570]. URI Templates are useful for generating URIs from data. UriTemplates are created from a template string, and then expanded with data to generate a URI:

```dart
var template = UriTemplate("http://example.com/~{user}/");
String fredUri = template.expand({'user': 'fred'});
final template = UriTemplate('http://example.com/~{user}/');
final fredUri = template.expand({'user': 'fred'});
print(fredUri); // prints: http://example.com/~fred/
```

Expand Down
11 changes: 11 additions & 0 deletions example/example.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:uri/uri.dart';

void main() {
final template = UriTemplate('http://example.com/~{user}/');
final fredUri = template.expand({'user': 'fred'});
print(fredUri); // prints: http://example.com/~fred/
}