Generate random data(string, integer, IPs etc...) using Dart.

Last update: Apr 17, 2022

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

GitHub

https://github.com/dinko-pehar/mock_data
Comments
  • 1. Added new color spaces, names and minor bug fix mockname

    Changed the function for throwing exception in mockName funciton. In mockName.

    !('female'.contains(gender))

    cannot be used as then they can input some random words like mal, fem, emal etc Added 35 names in male set and female set. Added 3 new color spaces in mockColor functions. I added those in README.md file. Will added test cases other soon.

    Reviewed by nagasai-b at 2018-12-20 09:37
  • 2. Tests update

    This PR updates tests to be less flaky, fixes some typos and adds a new changelog entry.

    After my previous PR merge I saw that tests failed https://github.com/dinko-pehar/mock_data/runs/2619656817 In logs we can see that it was due to one of mockLocation tests having some conditions which aren't really guaranteed to always get the same result. So I fixed it.

    Along with that I found a few small typos in tests names, etc.

    @dinko-pehar Could you also let me know if you plan to release a null-safety update to pub.dev? Would be good to have it sort of officially available to projects, like the one I am currently working on.

    Reviewed by vbuberen at 2021-06-02 14:50
  • 3. Constraint solver issue using Flutter beta channel

    There seems to be an issue with regards to the constraint solving. Would it be possible to bump down the lower version constraint to 2.0.0?

    The current Dart SDK version is 2.1.0-dev.9.4.flutter-f9ebf21297. Because ~ depends on mock_data >=1.0.1 which requires SDK version >=2.1.0 <3.0.0, version solving failed.

    Reviewed by rcagantas at 2019-01-02 07:06
  • 4. Added mock_currency feature and support for last name in mock_name

    Added mock_currency feature and in mock_name implemented the ability to display a full name. Let me know your thoughts, I will make changes accordingly so that we can merge.

    Reviewed by nagasai-b at 2019-01-09 06:07
  • 5. Null safety

    We use this package on one of projects and would love to see it supporting sound null safety.

    In this PR I did a migration and updated some dev dependencies. Additionally changed major version as it is suggested by Flutter team for null safety migration.

    Reviewed by vbuberen at 2021-05-14 14:45
  • 6. Add notification to Telegram on builds

    It would be nice to have some sort of notification when build is triggered. I have chosen Telegram for this.

    Actions should notify me on Telegram whether the build was successful or if it failed.

    Reviewed by dinko-pehar at 2020-03-13 16:26
  • 7. Improve unit tests

    mockData currently has unit tests, but they are not complete. Complete tests by adding missing tests for some sections, test for throws and generally rethink about improving testing step.

    Reviewed by dinko-pehar at 2020-03-13 16:23

Related

Dart's native integers in custom bitwidth integer format

Dart's native integers in custom bit-width formats like i2, i4, i8, i16, i32, ix and u1, u2, u4, u8, u16, u32, ux...

Apr 21, 2022
generate massive amounts of fake data in dart and flutter

generate massive amounts of fake data in Dart & Flutter Faker.dart is a dart port of the famous faker.js package for the web and NodeJS ?? Usage faker

Mar 28, 2022
A simple Flutter / Dart Utility class for converting complex objects to uri and query string

A simple Flutter / Dart Utility class for converting complex or nested objects to uri and query strings you can follow the the article on how this cla

Jan 6, 2022
An alternative random library for Dart.

Randt Randt library for Dart... Description Use Randt to get a random integer from a list, generate random integer in a specific range and generate ra

Nov 21, 2021
The Flutter code generator for your assets, fonts, colors, … — Get rid of all String-based APIs.
The Flutter code generator for your assets, fonts, colors, … — Get rid of all String-based APIs.

The Flutter code generator for your assets, fonts, colors, … — Get rid of all String-based APIs. Inspired by SwiftGen. Motivation Using asset path str

May 24, 2022
apps random

flutter_app A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if t

Oct 21, 2021
Random color generator for Flutter
Random color generator for Flutter

Random color generator Pub link: https://pub.dartlang.org/packages/random_color This library will generate random colors that are visually pleasing an

Mar 4, 2022
Provides API to generate Dart source code

DartWriter DartWriter provides API to generate Dart source code. It can make your job easier while developing flutter/dart tools. You can also generat

May 7, 2022
A CLI tool to help generate dart classes from json returned from API

Json 2 Dart Command line utility Important note There is already a package called json2dart so this package will be called json2dartc ! This project w

May 23, 2022
Automatically generate usecase classes from your repository class definition in Dart and Flutter
Automatically generate usecase classes from your repository class definition in Dart and Flutter

Repo Case Automatically generate usecase classes from your repository class definition in Dart and Flutter. Check out the official guide on repo_case

May 23, 2022
An http request client, which supports Manageable Requests Cancellation, Request Policy (Timeout and Retry), Easier Multipart Requests, etc.

A wrapper around Dart's http package, which supports Manageable Requests Cancellation, Request Policy (Timeout and Retry), Easier Multipart Requests, Error Handling, etc.

Oct 10, 2021
Generate gherkin automated tests
Generate gherkin automated tests

flutter_gherkin_automated Generate gherkin automated tests Preliminary: integration tests performance vs. development Original flutter_gherkin BDD tes

Mar 4, 2022
A simple command-line application to generate simple folder and file structure for Flutter Applications
A simple command-line application to generate simple folder and file structure for Flutter Applications

Kanza_cli is a simple command line tool to generate folder and file structure for your Flutter apps. To use it, you should do the followings: 1. First

Mar 10, 2022
A Dart package to web scraping data from websites easily and faster using less code lines.

Chaleno A flutter package to webscraping data from websites This package contains a set of high-level functions that make it easy to webscrap websites

Apr 28, 2022
A library for Dart that generates fake data

faker A library for Dart that generates fake data. faker is heavily inspired by the Python package faker, and the Ruby package ffaker. Usage A simple

May 16, 2022
Rocket is a parsing framework for parsing binary data structures using efficient parsing algorithms

rocket Version 0.1.10 (BETA) Rocket is a parsing framework for parsing binary data structures using efficient parsing algorithms. Breaking change: The

Dec 5, 2021
Fetch Data From fakestoreapi.com Api Using Dio
Fetch Data From fakestoreapi.com Api Using Dio

A powerful Http client for Dart, which supports Interceptors, Global configuration, FormData, Request Cancellation, File downloading, Timeout etc

Mar 27, 2022
A Dart build script that downloads the Protobuf compiler and Dart plugin to streamline .proto to .dart compilation.

A Dart build script that downloads the Protobuf compiler and Dart plugin to streamline .proto to .dart compilation.

Nov 17, 2021
Quiver is a set of utility libraries for Dart that makes using many Dart libraries easier and more convenient, or adds additional functionality.

Quiver is a set of utility libraries for Dart that makes using many Dart libraries easier and more convenient, or adds additional functionality.

May 19, 2022