Search categories, packages and repositories

Package detailsv2.0.1

mock_data

Generate random data using Dart. Can be used to create random strings, integers, names, colors, IPs, UUIDs, URLs and dates.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
2.3K
Likes
29
Pub points
160

Install package

flutter pub add mock_data

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The mock_data package generates random, realistic test data in Dart. It provides utilities to create random strings, integers, names, colors, IP addresses, UUIDs, URLs, and dates, making it ideal for simulating real-world data during development and testing. The package is lightweight and easy to integrate, supporting all major platforms including Android, iOS, Web, macOS, Windows, and Linux. It's particularly useful for populating UIs with placeholder content or testing data-handling logic without relying on external sources.

Use cases

  • Populating UI prototypes with sample data
  • Testing data parsing and display logic
  • Generating fake user profiles
  • Simulating API responses
  • Creating randomized test datasets
  • Filling forms with dummy input

Key features

  • Supports multiple data types (strings, numbers, dates, etc.)
  • Cross-platform compatibility
  • Simple, intuitive API
  • Generates realistic-looking values
  • Easy integration via Flutter pub
  • No external dependencies

Suitable for

  • Developers creating mockups
  • Testers needing randomized inputs
  • Teams building prototype apps
  • Frontend developers prototyping UIs
  • Anyone needing quick fake data

Considerations

  • Not suitable for production data generation
  • Randomness may not be cryptographically secure
  • Limited customization options for specific formats
  • Does not support complex data structures out of the box
  • Best used in development/testing environments only

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

Mock Data Logo
Build Status License Version
Generate random data using Dart

Features

API provides generation of:

  • Integers in any range of numbers
  • Strings with various characters and length
  • Colors represented with needed color space
  • Dates between different moments in time
  • Names such as John or Mary
  • UUIDv4 and Timestamp-first UUIDs
  • URLs with many fragments
  • IPv4 and IPv6
  • Locations as either random points or in specified radius

Usage

A simple usage example:

import 'package:mock_data/mock_data.dart';

main() {

  mockName();           // Generate male or female first name. 
  mockName('male');     // Generate male first name. 
  mockName('female');   // Generate female first name. 

  mockInteger(1, 6);    // Generate integer in range from 1 do 6.

  mockString(16);       // Generate string of length 16.
  
  mockIPv4();           // Generate IPv4 represented with 
                        // format(default is '*.*.*.*') as String. 
  
  mockIPv6();           // Generate IPv6, same usage as with IPv4.

  mockColor('hex');     // Generate color represented in hex format.
  mockColor('rgb');     // Generate color represented in RGB format.
  
  mockUUID();           // Generate UUIDv4
  
  mockLocation();       // Generate random location.
  mockLocation(53.55, 108.14, 1000); // Generate random location in 1000 m radius from the specified coordinates.
  
}

These are some basic examples. There are many more methods and they all support tweeking of parameters to suit you in generating random data. By reading examples you can learn more about functionality and usage of mock_data

Contributors
License

MIT

Categories

Source repository

Projects using this package