fluri 1.1.1 copy "fluri: ^1.1.1" to clipboard
fluri: ^1.1.1 copied to clipboard

outdatedDart 1 only

Fluri is a fluent URI library built to make URI mutation easy.

fluri #

Pub Build Status codecov.io documentation

Fluri is a fluent URI library for Dart built to make URI mutation easy.

The dart:core.Uri class provides an immutable representation of URIs, which makes it difficult to incrementally build them or update them at a later time. If you wanted to build a long URI from the individual pieces, you would do something like this:

Uri uri = new Uri(
  scheme: 'https',
  host: 'example.com',
  path: 'path/to/resource'
);

If you later wanted to update the path and add a query parameter, you'd have to do this:

uri = uri.replace(
  path: 'new/path',
  query: 'foo=true'
);

Now let's say you want update the query without losing what you already have:

Map query = new Map.from(uri.queryParameters);
query['bar'] = '10';
uri = uri.replace(queryParameters: query);

As you can see, incremental or fluent-style URI mutations become a hassle with the core Uri class.

With fluri, the above interactions are easy:

import 'package:fluri/fluri.dart';

Fluri fluri = new Fluri()
  ..scheme = 'https'
  ..host = 'example.com'
  ..path = 'path/to/resource';

fluri
  ..path = 'new/path'
  ..query = 'foo=true';

fluri.updateQuery({'bar': '10'});

Additional methods like appendToPath and setQueryParam make it easy to build on top of a base URL:

import 'package:fluri/fluri.dart';

Fluri base = new Fluri('https://example.com/base/');

Fluri fluri = new Fluri.from(base)
  ..appendToPath('path/to/resource')
  ..setQueryParam('count', '10');

Development #

This project leverages the dart_dev package for most of its tooling needs, including static analysis, code formatting, running tests, collecting coverage, and serving examples. Check out the dart_dev readme for more information.

4
likes
0
pub points
82%
popularity

Publisher

verified publisherworkiva.com

Fluri is a fluent URI library built to make URI mutation easy.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

More

Packages that depend on fluri