パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v0.3.1

flutter_guid

C# Guid をエミュレートします。新しい UUID を生成し、クラスに Guid 型の変数を追加します。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
3230
いいね数
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 を通じた簡単な統合

適している対象

  • グローバルに一意の識別子を必要とするアプリ
  • バックエンド統合型Flutterアプリ
  • 同期要件を備えたデータ集約型アプリケーション
  • 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 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。