Pakete, Repositories und App-Kategorien suchen

Paketdetailsv2.0.6

fluri

Fluri ist eine fließende URI-Bibliothek, die dazu entwickelt wurde, die Änderung von URIs einfach zu machen.

AndroidiOSWebmacOSWindowsLinux
30-Tage-Downloads
30.300
Likes
6
Pub-Punkte
140

Paket installieren

flutter pub add fluri

Paketübersicht

Aus öffentlichen Paketdaten erstellte Orientierung.

Fluri ist eine fließende URI-Bibliothek, die entwickelt wurde, um die Manipulation von URIs in Dart- und Flutter-Anwendungen zu vereinfachen. Sie bietet eine intuitive, verkettbare API zum einfachen Erstellen, Ändern und Analysieren von URIs. Entwickler können Pfade, Abfrageparameter und Fragmente nahtlos hinzufügen, während sie sauberen, lesbaren Code beibehalten. Von Workiva entwickelt, unterstützt Fluri alle wichtigen Plattformen wie Android, iOS, Web, macOS, Windows und Linux und ist daher ideal für plattformübergreifende Projekte mit robustem URL-Handling.

Anwendungsfälle

  • Dynamische API-Endpunkte erstellen
  • Analyse und Änderung von URLs zur Laufzeit
  • Komplexe Abfragezeichenfolgen erstellen
  • Umgang mit relativen und absoluten URIs
  • HTTP-Clients mit verschiedenen URLs testen
  • Navigationsschienen mit Parametern verwalten

Hauptmerkmale

  • Fluiddes, verkettbares API
  • Unterstützung für Abfrageparameter-Mutation
  • Einfache Pfad- und Fragmentmanipulation
  • Plattformübergreifende Kompatibilität
  • Immutable URI-Erstellung
  • Robuste Analyse und Serialisierung

Geeignet für

  • Flutter-Entwickler, die eine flexible URI-Verarbeitung benötigen
  • API-Clients, die dynamische Endpunktgenerierung erfordern
  • Apps mit komplexer Routing- oder Deep-Linking-Funktion
  • Teams, die saubere, wartbare URL-Logik priorisieren
  • Projekte für mehrere Plattformen

Hinweise

  • Nicht für die niedrigstufige URL-Analyse vorgesehen
  • Erfordert Verständnis der URI-Struktur
  • Kann für einfache statische URLs Overhead hinzufügen
  • Beschränkt auf URI-spezifische Operationen
  • Am besten in Verbindung mit HTTP-Clients wie dio oder http verwendet

Original-README

Originaler README-Schnappschuss aus dem verknüpften Quell-Repository. Aktuelle Inhalte finden Sie im Repository.

fluri

Pub Build Status documentation

Examples/Usage

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:

var uri = 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:

var query = 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';

var fluri = 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';

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

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

Fluri also supports multi-value parameters. To access the query parameters as Map<String, List<String>>, use queryParametersAll (just like the Uri class):

var fluri = Fluri('/resource?format=json&format=text');
print(fluri.queryParameters); // {'format': 'text'}
print(fluri.queryParametersAll); // {'format': ['json', 'text']}

To set a single query parameter to multiple values:

var fluri = Fluri('/resource');
fluri.setQueryParam('format', ['json', 'text']);
print(fluri.queryParametersAll); // {'format': ['json', 'text']}

Using setQueryParam will always replace existing values:

var fluri = Fluri('/resource');
fluri.setQueryParam('format', ['json', 'text']);
fluri.setQueryParam('format', ['binary', 'text']);
print(fluri.queryParametersAll); // {'format': ['binary', 'text']}

You can use the queryParametersAll setter to set the entire query with multi-value param support:

var fluri = Fluri('/resource');
fluri.queryParametersAll = {'format': ['json', 'text'], 'count': ['5']}
print(fluri.queryParametersAll); // {'format': ['json', 'text'], 'count': ['5']}

Again, if you need to preserve existing query parameters, you can use the updateQuery method to do so. Set mergeValues: true and any values that you provide will be merged with existing values:

var fluri = Fluri('/resource?format=json');
fluri.updateQuery({'format': ['binary', 'text'], 'count': '5'}, mergeValues: true);
print(fluri.queryParametersAll); // {'format': ['binary', 'json', 'text'], 'count': ['5']}

Kategorien

Quell-Repository

Projekte, die dieses Paket verwenden