패키지, 저장소 및 앱 카테고리 검색

패키지 상세v1.0.0

uri

URI를 빌드하고 파싱하기 위한 유틸리티로, RFC 6570에서 정의한 URI 템플릿을 분석하는 기능도 포함합니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
48.4만
좋아요
26
Pub 점수
145

패키지 설치

flutter pub add uri

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

uri 패키지는 Dart 애플리케이션에서 URI를 생성하고 파싱하며 조작하는 데 도움이 되는 유틸리티를 제공합니다. RFC 6570 호환 URI 템플릿 파싱을 지원하여 변수를 포함한 동적 URL 생성이 가능합니다. 모든 주요 플랫폼에서 사용할 수 있도록 설계되었으며 HTTP 클라이언트 및 웹 서비스 통합에 원활하게 통합됩니다. 이 패키지는 Google에서 유지보수되며 Flutter 및 Dart 프로젝트에서 복잡한 URI 작업을 처리하기 위한 가볍고 신뢰할 수 있는 솔루션을 제공합니다.

사용 사례

  • 동적 API URL 만들기
  • URI에서 쿼리 매개변수 파싱하기
  • 변수를 사용한 URI 템플릿 확장
  • 상대 및 절대 URI 처리
  • HTTP 클라이언트와의 통합
  • URI 구조 검증

주요 기능

  • RFC 6570 URI 템플릿 지원
  • 강력한 구문 분석 및 구성
  • 크로스 플랫폼 호환성
  • 경량이고 효율적
  • 쿼리 문자열 조작을 지원합니다
  • 사용자 정의 URI 로직을 위한 확장 가능

적합한 대상

  • API 클라이언트
  • 웹 서비스 통합
  • URL 라우팅 시스템
  • 데이터 가져오기 파이프라인
  • 백엔드 통신 계층
  • HTTP 상호작용 테스트

고려 사항

  • 특수 문자에 대한 인코딩을 수동으로 처리해야 합니다
  • 구문을 초과한 전체 URL 검증을 위한 것이 아님
  • URI 수준 작업에 국한되며, 완전한 HTTP 요청은 아님
  • 내장된 캐시 또는 재시도 메커니즘이 없음
  • 템플릿 구문의 올바른 사용에 달려 있음
  • 완전한 HTTP 워크플로를 위해 http 패키지와 함께 사용해야 할 수 있습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

ci

Utilities for working with URIs in Dart, mostly parsing and generating URIs.

UriPattern

UriPattern is an interface for classes that match and parse URIs, much like the Pattern is for Strings. It defines the methods bool matches(Uri uri) and UriMatch match(Uri uri).

UriMatch

UriMatch is the result of UriPattern.match(). It contains the parameters parsed out of a URI and the "rest" of the URI left over after parsing, which is useful for parsing a single URI with multiple relative URI patterns that form a hierarchy.

UriTemplate

UriTemplate is an implementation of RFC 6570 URI Templates. 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:

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

URI templates are strings made up of fixed and variable parts. The variable parts are described with expressions, which are places within single curly-braces: { and }.

Expressions consist of an optional operator and a comma-separated list of variable specifications_. Variable specifications consist of a variable name and an optional modifier. The operator applies to the whole expression and controls how reserved characters are expanded, the prefix and separator, if any, applied to the expansion, and whether to expand the variable as a key/value pair. Modifiers apply to each variable in the expression and allow truncating the value, or "exploding" list and maps into multiple key/value pairs.

Examples
  • http://example.com/~{username}/
  • http://example.com/dictionary/{term:1}/{term}
  • http://example.com/search{?q,lang}
Operators

URI template expansions does more than simple variable replacement, it has facilities for generating paths, fragments, query strings and more. To control the expansion, expressions can use one of the supported operators:

Operator Description
none Simple string expansion
+ Reserved string expansion
# Fragment expansion
. Label expansion, dot-prefixed
/ Path segments, slash-prefixed
; Path-style parameters, semicolon-prefixed
? Form-style query, ampersand-separated
& Form-style query continuation
Modifiers

Modifiers control

Modifier Description
none Default expansion
:n Prefix: use only the first n characters of the value
* "Explode" the lists and maps into key/value pairs

UriParser

UriParser parses URIs according to a UriTemplate, extracting parameters based on the variables defined in the template.

Since URI Templates are not designed to be parsable, only a restricted subset of templates can be used for parsing.

Parsable templates have the following restrictions over expandable templates:

  • URI components must come in order: scheme, host, path, query, fragment. There can only be one of each component.
  • Path expressions can only contain one variable.
  • Multiple expressions must be separated by a literal.
  • Only the following operators are supported: none, +, #, ?, &
  • Default and + operators are not allowed in query or fragment components.
  • Queries can only use the ? or & operator.
  • The ? operator can only be used once.
  • Fragments can only use the # operator

UriBuilder

UriBuilder is mutable container of URI components for incrementally building Uris.

카테고리

의존성

의존성 목록 2 개

소스 저장소

이 패키지를 사용하는 프로젝트