Skip to main content
1

🌊 Stream Utilities

streamOf<T>({T Function(int index) generator, int count, Duration interval})
Stream<T>
Simulates a live stream of data that emits up to count items with a specified interval between each emission. Ideal for testing StreamBuilder widgets.
// Generates 5 items, emitted every 500 milliseconds.
final priceStream = ExtendGenerator.streamOf<double>(
  (i) => 100.0 + i * 0.5,
  count: 5,
  interval: 500.milliseconds,
);
weightedBool(double chance)
bool
Returns true based on a specific probability chance (0.0 to 1.0). Used for simulating real-world scenarios like transient network errors.
// Returns true approximately 15% of the time
final shouldFail = ExtendGenerator.weightedBool(0.15);
2

🆔 Identifiers & Finance

uuid
String
Generates a Mock UUID (v4 format). Sufficient for UI testing and unique keys, but not cryptographically secure.
final mockId = ExtendGenerator.uuid;
// e.g., "a1b2c3d4-e5f6-7890-1234-567890abcdef"
The generated keys are NOT cryptographically secure.
randomCreditCard({CardType type})
String
Generates a mock credit card number that is valid according to the Luhn checksum algorithm. Ideal for testing form validation logic.
final visaCard = ExtendGenerator.randomCreditCard(type: CardType.visa);
3

📅 Time & Date

randomDate({int daysBack})
DateTime
Generates a random DateTime within the past daysBack (default 365 days). Useful for mock user data or post timestamps.
ExtendGenerator
final postDate = ExtendGenerator.randomDate(daysBack: 30);
4

🎨 General Data

randomColor
Color
Generates a random, fully opaque (alpha=255) color. Ideal for visual debugging and distinguishing containers.
Container(color: ExtendGenerator.randomColor);
randomEmail
String
Generates a mock email address using a random username and common domain names.
final email = ExtendGenerator.randomEmail; // e.g., "a8jkld7d@gmail.com"
clipboardData
Future<String?>
Retrieves the current text content from the system clipboard.
final contents = await ExtendGenerator.clipboardData;