How to Generate UUIDs in Flutter

Generate UUIDs in Flutter with the Dart uuid package for random v4 identifiers and for v7 identifiers when your package version exposes that API.

Recommendation: use UUID v4 for client-generated random IDs and UUID v7 when you want sortable identifiers across mobile and backend systems.

How to generate UUID v4 in Flutter

// pub add uuid
import 'package:uuid/uuid.dart';

const uuid = Uuid();
final id = uuid.v4();
print(id);

How to generate UUID v7 in Flutter

// pub add uuid
import 'package:uuid/uuid.dart';

const uuid = Uuid();
final id = uuid.v7();
print(id);

Native support notes

  • Flutter apps typically rely on a Dart package rather than a platform-level built-in UUID generator.
  • Keep your package version pinned when documenting UUID v7 support.
  • Use the same UUID generation strategy on mobile and backend services when IDs cross system boundaries.

Practical notes

  • UUID v4 is useful for offline-first mobile flows where random IDs are sufficient.
  • UUID v7 is often easier to debug because creation time is reflected in sort order.
  • See v4 vs v7 before standardizing on one format.

Frequently Asked Questions

Most Flutter apps use a Dart package such as uuid instead of a framework-built-in API.

Choose v7 when your app benefits from time ordering, especially when syncing records to a backend or writing to ordered storage, and pin a package version that explicitly supports uuid.v7().

Learn more

These articles expand on related concepts, formats and practical considerations.

By using this site, you agree to our Privacy Policy and Terms of Service. You are not permitted to use the GUIDs (also known as UUIDs) generated by this site or use any other content, services and information available if you do not agree to these terms.
Disclaimer: All information is provided for general educational and technical reference only. While we aim to keep the content accurate, current and aligned with published standards, no guarantees are made regarding completeness, correctness or suitability for any specific use case.
GUID specifications, best practices, security guidance, database behavior and ecosystem conventions (including cloud platforms and identifier formats) may change over time or differ by implementation. Examples, recommendations and comparisons are illustrative and may not apply universally.
This content should not be considered legal, security, compliance or architectural advice. Before making critical design, security or production decisions, always consult the latest official standards and vendor-specific documentation.
Always evaluate behavior in your own environment.
Standards Compliance: The GUIDs generated by this site conform to RFC 4122 and RFC 9562 specifications whenever possible, using cryptographically secure random number generation.