सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।
uuid पैकेज डार्ट के लिए RFC4122 UUID मानकों (v1, v4, v5, v6, v7, v8) का व्यापक कार्यान्वयन प्रदान करता है, जो सुरक्षित और विश्वसनीय रूप से विश्वव्यापी अद्वितीय पहचानकर्ता के उत्पादन और विश्लेषण की अनुमति देता है। यह सभी प्रमुख प्लेटफॉर्म जैसे Android, iOS, Web, macOS, Windows और Linux का समर्थन करता है। यह पैकेज डेटा रिकॉर्ड, सत्र प्रबंधन या वितरित प्रणालियों के लिए अद्वितीय पहचानकर्ता की आवश्यकता वाले एप्लिकेशन के लिए आदर्श है। साफ और स्पष्ट API के साथ, यह Flutter और डार्ट प्रोजेक्ट में एकीकरण को सरल बनाता है।
उपयोग
डेटाबेस रिकॉर्ड्स के लिए अद्वितीय ID जनरेट करना
सत्र टोकन बनाना
वितरित प्रणालियों में संस्थाओं की पहचान करना
सेवाओं के बीच डेटा अखंडता सुनिश्चित करना
ऑफलाइन-प्रथम एप्प स्टेट मैनेजमेंट का समर्थन करता है
मुख्य विशेषताएँ
कई UUID संस्करणों (v1, v4, v5, v6, v7, v8) का समर्थन करता है
प्लेटफॉर्म के अनुकूलता
टिकाऊ पार्सिंग और मान्यता
सरल, लचीला API
RFC4122 संगत
इनके लिए उपयुक्त
Dart का उपयोग करके बैकएंड सेवाएं
Flutter ऐप्स को यूनिक आईडी की जरूरत होती है
उपकरणों के बीच डेटा सिंक्रनाइज़ेशन
सुरक्षा संवेदनशील एप्लिकेशन
मानकीकृत आईडी प्रारूप की आवश्यकता वाले अनुप्रयोग
विचार योग्य बातें
उपयोग के मामले के आधार पर सही UUID संस्करण का चयन सुनिश्चित करें
v1 UUID के गोपनीयता प्रभावों के बारे में सचेत रहें
उपयोगकर्ता इनपुट के विश्लेषण के समय UUID प्रारूप की पुष्टि करें
प्रदर्शन-महत्वपूर्ण मार्गों में उच्च मात्रा में v1 UUID के उत्पादन से बचें
अपडेट चेक करें क्योंकि RFC मानक लगातार विकसित हो रहा है
मूल README
संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।
uuid
Version 4.x.x is a complete redesign of the underlying setup, but tries to be API compatible or similar to 3.x.
Open a command line and cd to your projects root folder
In your pubspec, add an entry for dart-uuid to your dependencies (example below)
pub install
If you wish to run tests, go into packages/dart-uuid/ and run 'dart test'
Pubspec
dependencies:uuid:^4.6.0
import'package:uuid/uuid.dart';
var uuid = Uuid();
Then create some ids ...
// Generate a v1 (time-based) id
uuid.v1(); // -> '6c84fb90-12c4-11e1-840d-7b25c5ee775a'// Generate a v4 (random) id
uuid.v4(); // -> '110ec58a-a0f2-4ac4-8393-c866d813b8d1'// Generate a v5 (namespace-name-sha1-based) id
uuid.v5(Namespace.url.value, 'www.google.com'); // -> 'c74a196f-f19d-5ea9-bffd-a2742432fc9c'
Structural 128-bit parsing
Use the explicit format APIs when the input must be a 128-bit hexadecimal
value but UUID version and variant bits should not be enforced.
uuid.v7() fills everything after the millisecond timestamp with random bits,
so ids created in the same millisecond have no defined order. UuidV7Monotonic
replaces the most significant of those random bits with a 16-bit counter
(RFC 9562 §6.2, Method 1), so ids from one generator sort in creation order
under an ordinary string comparison (or byte comparison if parsed).
import'package:uuid/uuid.dart';
import'package:uuid/v7monotonic.dart';
// Plain v7, both created in the same millisecond. Creation order and sort// order happen to disagree.const uuid = Uuid();
uuid.v7(); // -> '019fcd85-9fac-7f64-8711-97a4665f1adc'
uuid.v7(); // -> '019fcd85-9fac-715d-80d0-556404fa23ea'// Monotonic, also within one millisecond. The counter defines the order.final generator = UuidV7Monotonic();
generator.generate(); // -> '019fcd85-9fb3-7488-a625-f7a830c2dcf7'
generator.generate(); // -> '019fcd85-9fb3-7488-a87c-0c31456d733b'
Import the generator directly; it is not exported from uuid.dart.
Some limits of the monotonic generator:
Ordering only holds within one generator instance. v7 cannot order
concurrent generators against each other without shared state.
Ids strictly increase unless the clock moves backward by more than 10
seconds, which resets ordering to the new clock reading. Ids stay unique
across the reset.
Ids are not secret tokens. The counter increments by exactly +1 within a
millisecond, so an observer holding one id can predict the next. Use v4
if unguessability matters.
Documentation
For documentation, please visit the Documentation page. Examples are included for most functions and classes.
For more complex examples and other usages, please look at the tests.