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

패키지 상세v1.2.2

stringr

Dart용 포괄적인 문자열 조작 플러그인입니다. 라틴어, 비라틴어 및 그래프엠 클러스터 모두에서 작업을 처리합니다! VocaJs에서 영감을 받은 기능

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
7.3만
좋아요
20
Pub 점수
160

패키지 설치

flutter pub add stringr

패키지 개요

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

Stringr은 라틴어, 비라틴어 및 그래프엠 클러스터 처리를 정밀하게 지원하는 고급 문자열 조작을 위한 포괄적인 Dart 패키지입니다. Voca.js에서 영감을 받아 다양한 스크립트에서 텍스트를 변환하고 분석하기 위한 풍부한 메서드 세트를 제공합니다. 강력한 문자열 작업이 필요한 국제화 애플리케이션에 적합하며, 복잡한 유니코드 문자를 정확하게 처리합니다. 이 패키지는 모든 주요 플랫폼의 Flutter 앱에 원활하게 통합됩니다.

사용 사례

  • 국제화된 텍스트 처리
  • 텍스트 정규화 및 정리
  • 문자열 변환 유틸리티
  • 다국어 콘텐츠 처리
  • 데이터 검증 및 정제
  • 그래프임 클러스터 인식 작업

주요 기능

  • 라틴 및 비라틴 문자 스크립트 지원
  • 글자 클러스터 인식
  • Voca.js를 영감으로 한 API 설계
  • 크로스 플랫폼 호환성
  • 유니코드 안전한 문자열 작업
  • 텍스트 조작을 위한 광범위한 메서드 세트

적합한 대상

  • 다국어 지원이 필요한 앱
  • 강력한 문자열 도구가 필요한 개발자
  • 텍스트 분석을 포함하는 프로젝트
  • 글로벌 대상 사용자를 위한 플러터 앱
  • 유니코드가 풍부한 데이터를 사용하는 팀

고려 사항

  • 간단한 문자열 작업에 오버헤드를 추가할 수 있습니다
  • Unicode 및 그래프엠에 대한 이해 필요
  • 기본 사용법 외에 문서가 제한적
  • 고성능 대량 작업에 최적화되지 않음
  • 중간에서 복잡한 문자열 요구 사항에 가장 적합

원본 README

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

stringr

pub package codecov License: MIT

A comprehensive string manipulation library for Dart and Flutter. Inspired by VocaJS, stringr provides powerful string operations that work seamlessly with Latin, non-Latin, and Unicode strings.

Features

  • Case Conversion - camelCase, snake_case, kebab-case, Title Case, PascalCase
  • Unicode Support - Full support for non-Latin scripts, diacritics, and grapheme clusters
  • Smart Word Detection - Uses regex patterns instead of simple whitespace splitting
  • Null Safety - Fully null-safe and compatible with Dart 3.0+
  • Zero Dependencies - Only depends on the characters package for grapheme support

Installation

Add to your pubspec.yaml:

dependencies:
  stringr: ^1.2.0

Quick Start

import 'package:stringr/stringr.dart';

void main() {
  // Case conversions
  print('hello world'.toCamelCase);        // helloWorld
  print('hello world'.toSnakeCase);        // hello_world
  print('hello world'.toKebabCase);        // hello-world
  print('hello world'.toPascalCase);       // HelloWorld

  // Smart word extraction
  print('XMLHttpRequest'.camelCase());     // xmlHttpRequest
  print('/path/to/file'.camelCase());      // pathToFile
  print('2infinity&beyond'.words());       // [2, infinity, beyond]
}

Unicode & Non-Latin Support

stringr shines with complex Unicode strings:

// Non-Latin scripts
print('полет птицы'.kebabCase());          // полет-птицы
print('La variété française'.prune(12));   // La variété

// Diacritics and latinization
print('café'.latinize());                  // cafe
print('anglikonų šiurkščios'.latinize());  // anglikonu siurkscios

// Grapheme-aware operations
print('café'.countGrapheme());             // 4 (not 5!)
print('👨‍👩‍👧‍👦'.reverse());                      // 👨‍👩‍👧‍👦 (family emoji stays intact)

API Overview

Case Manipulation
Method Description Example
camelCase() Convert to camelCase 'foo bar' → 'fooBar'
snakeCase() Convert to snake_case 'foo bar' → 'foo_bar'
kebabCase() Convert to kebab-case 'foo bar' → 'foo-bar'
titleCase() Capitalize each word 'foo bar' → 'Foo Bar'
capitalize() Capitalize first char 'foo' → 'Foo'
swapCase() Toggle case 'FoO' → 'fOo'
String Chopping
Method Description Example
truncate(n) Truncate to n chars 'hello world' → 'hello...'
prune(n) Truncate without breaking words 'hello world' → 'hello'
first(n) Get first n chars 'hello' → 'hel'
last(n) Get last n chars 'hello' → 'llo'
slice(start, end) Extract substring 'hello' → 'ell'
Counting
Method Description Example
countGrapheme() Count visible characters 'café' → 4
countOccurrences(s) Count substring occurrences 'banana'.countOccurrences('a') → 3
countWords() Count words 'hello world' → 2
countWhere(fn) Count matching chars Custom predicate
Manipulation
Method Description Example
reverse() Reverse (grapheme-aware) 'hello' → 'olleh'
slugify() URL-friendly slug 'Hello World!' → 'hello-world'
latinize() Remove diacritics 'café' → 'cafe'
insert(s, i) Insert at position 'hllo'.insert('e', 1) → 'hello'
Escaping
Method Description
escapeHtml() Escape HTML entities
unescapeHtml() Unescape HTML entities
escapeRegExp() Escape regex special chars

Why stringr?

Most string libraries fail with complex Unicode. stringr handles:

  • Grapheme clusters: 'café' is 4 characters, not 5
  • Surrogate pairs: Emoji and special symbols work correctly
  • Non-Latin scripts: Cyrillic, Greek, accented Latin, and more
  • Smart word detection: 'XMLHttpRequest' → ['XML', 'Http', 'Request']

Contributing

Contributions are welcome! Please read our Contributing Guide for details.

Project Health

License

MIT License - see LICENSE for details.

카테고리

의존성

의존성 목록 1 개

소스 저장소

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

순위