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

패키지 상세v0.3.1

flutter_guid

C# Guid를 에뮬레이션합니다. 새 UUID를 생성하고 클래스에 Guid 유형의 변수를 추가합니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
3.2천
좋아요
20
Pub 점수
135

패키지 설치

flutter pub add flutter_guid

패키지 개요

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

flutter_guid는 C# Guid 기능을 모방하는 Dart 패키지로, Flutter 애플리케이션 내에서 UUID(일반적으로 고유한 식별자)를 생성하고 관리할 수 있게 해줍니다. 새로운 고유 식별자를 생성하기 위한 Guid 클래스를 제공하며 사용자 정의 클래스에 Guid 타입 변수를 추가할 수 있습니다. 이 패키지는 Android, iOS, Web, macOS, Windows, Linux 등 모든 주요 플랫폼을 지원하여 일관된 식별자 생성이 필요한 크로스플랫폼 앱에 이상적입니다. 데이터 동기화, 세션 추적, 또는 데이터베이스 키 관리와 같은 시나리오에서는 유일성과 신뢰성이 중요한 경우 특히 유용합니다.

사용 사례

  • 데이터베이스 레코드에 고유 ID 생성
  • 장치 간 사용자 세션 추적
  • 클라이언트 간 데이터 동기화
  • 보안 토큰 생성
  • 상태 관리에서 엔티티 식별자 관리

주요 기능

  • 크로스 플랫폼 UUID 생성
  • C# Guid와 유사한 API 설계
  • 사용자 정의 클래스에서 Guid 형식 지원
  • 불변이고 직렬화 가능한 Guid 개체
  • pub.dev를 통한 간편한 통합

적합한 대상

  • 전역 고유 식별자가 필요한 앱
  • 백엔드 통합형 플러터 앱
  • 동기화 요구 사항이 있는 데이터 중심 애플리케이션
  • C# Guid 패턴에 익숙한 개발자
  • 다양한 플랫폼 간에 일관된 ID 생성이 필요한 프로젝트

고려 사항

  • UUID 표준에 대한 이해가 필요합니다
  • 암호 키 생성에 적합하지 않습니다
  • 간단한 사용 사례에 대해 소량의 오버헤드를 추가할 수 있습니다
  • 식별자 생성에 한정되며 암호화 또는 해시는 포함되지 않음

원본 README

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

flutter_guid

A flutter package that emulates the C# type Guid. Use this package to:

  1. Generate new UUIDs.
  2. Add variables of type Guid to your classes.
  3. Compare two 'Guid' variables safely against each other.
  4. Guarantee validity of data when working with UUID values.

Getting Started

Installing

Install from https://pub.dev/packages/flutter_guid#-installing-tab- , "flutter_guid's installation page on pub.dev"

Usage
Add to your class.
import 'package:flutter_guid/flutter_guid.dart';

class Employee{
  final Guid id;
  final Guid departmentId;

  Employee({this.id, this.departmentId});
}
Initialize Guid values

// initialize a guid from a string
final accountsDepartmentId = new Guid("41e879aa-859c-4bda-b77b-37b7e07c6674");

 // Generate a guid on the fly (Uses the superb package 'https://pub.dev/packages/uuid').
final employeeId = Guid.newGuid;

Compare Guids
// initialize a guid from a lowercase string
final accountsDepartmentIdLowerCase = new Guid("41e879aa-859c-4bda-b77b-37b7e07c6674");

// initialize a guid with same string, but UPPERCASE
final accountsDepartmentIdUpperCase = new Guid("41E879AA-859C-4BDA-B77B-37B7E07C6674");

// performs case-insensitive comparison and evaluates to 'true'
final equal = accountsDepartmentIdUpperCase == accountsDepartmentIdLowerCase;

Getting the UUID value contained in the GUID
final Guid accountsDepartmentIdLowerCase = new Guid("41e879aa-859c-4bda-b77b-37b7e07c6674");

// this works.
String uuidString = accountsDepartmentIdLowerCase.value;

// this also works.
uuidString = accountsDepartmentIdLowerCase.toString();

Testing

Basic Testing

Clone the repo and run flutter test

Testing With Coverage Information (Linux only)
  1. Ensure you have lcov installed and setup on your system (http://ltp.sourceforge.net/coverage/lcov.php).
  2. Ensure the run-tests script in the project root is executable (chmod +x ./run-tests.sh).
  3. Execute the run-tests script in the project root ./run-tests.sh.
  4. Navigate into directory ./coverage/html/ (relative to project root).
  5. Open index.html to view coverage information.
Coverage Information On Other Systems

It is unlikely that I'll be porting the run-tests.sh script to other systems, my reason mostly being that I don't frequently use any other OS and would not want to pick a sub-optimal tool for coverage generation (also laziness probably is a factor).

Anyhow, it should be fairly straight-forward to do the porting if you so wish.

The run-tests.sh consists of all of two lines:

  1. flutter test --coverage
  2. genhtml ./coverage/lcov.info -o ./coverage/html

The first line is platform independent and generates the file ./coverage/lcov.info (again relative to project root). On Linux, we can consume the coverage info contained in this file via the lcov tool. On Windows and other platforms, there exists also tools that would be able to similarly consume the coverage information and produce human friendly output.

In essense, port the script to desired platform by

  1. Keeping the first line 'as is'.
  2. Finding a tool to process the ./coverage/lcov.info file.
  3. Profit!

카테고리

의존성

의존성 목록 2 개

소스 저장소

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

아직 데이터가 없습니다.