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

패키지 상세v2.1.1

properties

Dart에서 속성 파일(그리고 그 이상)을 관리하기 위한 간단한 라이브러리

AndroidiOSmacOSWindowsLinux
30일 다운로드
92.4만
좋아요
9
Pub 점수
140

패키지 설치

flutter pub add properties

패키지 개요

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

properties 패키지는 구성 및 로컬라이제이션에 일반적으로 사용되는 속성 파일을 관리하기 위해 설계된 가벼운 Dart 라이브러리입니다. 표준 .properties 형식의 키-값 쌍을 읽고 쓰며 파싱하는 것을 지원하며, 주석 처리와 인코딩을 다루는 추가 유틸리티도 제공합니다. 이 라이브러리는 플랫폼에 구애받지 않으며 Android, iOS, macOS, Windows, Linux에서 원활하게 작동합니다. 외부 종속성이 없이 간단하고 구조화된 설정 저장이 필요한 애플리케이션에 적합합니다.

사용 사례

  • .properties 파일에서 앱 구성 로드 중
  • 현지화 문자열 관리
  • 환경별 설정 저장
  • 구성 데이터 파싱 및 쓰기
  • 일반 텍스트 형식의 키-값 쌍 처리

주요 기능

  • 표준 .properties 파일 형식을 지원합니다
  • 주석이 있는 키-값 쌍을 읽고 쓰기
  • 크로스 플랫폼 호환성
  • 일반적인 작업을 위한 간단한 API
  • UTF-8 인코딩 및 줄 바꿈 처리

적합한 대상

  • 구성 파일이 필요한 소규모에서 중규모 앱
  • 로컬라이제이션 워크플로우
  • 환경 기반 구성
  • 다중 플랫폼에서의 Dart 프로젝트
  • 최소 종속성을 선호하는 개발자

고려 사항

  • 복잡한 중첩 구성에 적합하지 않습니다
  • 평탄한 키-값 구조로 제한됨
  • 내장된 검증 또는 스키마 지원 없음
  • 대규모 데이터 관리보다는 간단한 사용 사례에 최적

원본 README

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

Properties

Properties is a simple library to manage properties files (and something more) in Dart.

The project aim is to provide a simple and lightweight implementation of properties file management for Dart adding some useful but not so common features. Code and usage are very straightforward, just have a look at the Getting Started section below.

To know something more about the released version have a look at the CHANGELOG to find the version that works best for you.

Getting started

The best way to get immediately started is to have a look at the unit tests provided along with the source code.

Anyway you can go on reading this quick intro.

Using Properties you can:

  • create a new properties instance from file
Properties p = Properties.fromFile(filepath);
  • get a property out of it
String value = p.get('test.key.1');

..optionally providing a default value..

String defval = p.get('test.key.X', defval:'value X');

..or a default key..

String defkey = p.get('test.key.X', defkey:'test.key.1');
  • get an int, a double or a bool value
int anInt = p.getInt('test.key.integer');
double aDouble = p.getDouble('test.key.double');
bool aBool = p.getBool('test.key.bool');
  • get a list
List<String> list = p.getList('test.key.listofvalues');
  • add a brand new property, choosing whether to overwrite an existing entry or not
bool added = p.add('test.key.3', 'value 3', true);

and then listen to "property added" or "property updated" events

p.onAdd.listen((AddEvent e) {
        eventType = e.type;
        key = e.key;
        value = e.value;
});
  • export the content as a JSON sting, optionally choosing to export key having a given prefix and/or suffix
String jsonexport = p.toJSON([prefix, suffix]);
  • filter and extract property entries that matches custom conditions
Map<String,String> filtered = p.every((s) => s.startsWith('test'));

Running Tests

To run the tests just run the test/properties_test.dart file.

Some Limits

Output on file is not supported (yet!).

카테고리

의존성

의존성 목록 1 개

소스 저장소

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