mock_data library

Generate random data using Dart.

List of random data to generate:

  • colors with various color spaces
  • date between different moments in time
  • integers in between range of numbers
  • IPs ~ IPv4 and IPv6
  • name; male or female first name
  • strings of different length and characters
  • url with different parts; routes, GET query parameters and fragments
  • uuid ~ version 4, timestamp-first and null

Inspired by: https://www.npmjs.com/package/mock-data

Properties

R int
final

Functions

distance(double lat1, double lon1, double lat2, double lon2) double
Distance between two locations calculated with Haversine formula.
mockColor([String returnModel = 'rgb']) String
Generate random color from a given model.
mockDate([DateTime? firstMoment, DateTime? secondMoment]) DateTime
Generate random DateTime object in between two moments in time.
mockInteger([int min = 1, int max = 10]) int
Generate random integer in range from min to max, inclusive.
mockIPv4([String format = '*.*.*.*']) String
Generate random IPv4 address.
mockIPv6([String format = '*:*:*:*:*:*:*:*']) String
Generate random IPv6 address.
mockLocation([double? latitude, double? longitude, int? radius]) Map<String, double>
Generate random latitude longitude in radius from centerLat to centerLon, inclusive. If any argument is null, random location will be returned.
mockName([String gender = 'any']) String
Generate random first name.
mockRange<E>(Function mockFunction, int numberOfMocks, {int lengthOfMockedString = 16, String include = '!', int min = 1, int max = 10, String format = '*.*.*.*', String gender = 'any', String returnModel = 'rgb', String scheme = '*', bool withPath = false, dynamic withQuery = false, dynamic withFragment = false, DateTime? firstMoment, DateTime? secondMoment, String uuidType = 'ver4', double centerLat = 55.7520, double centerLon = 37.6175, int radius = 1000}) List<E>
Generic function to generate list of mocks.
mockString([int lengthOfMockedString = 16, String include = '!']) String
Generate random string.
mockUrl([String scheme = '*', bool withPath = false, dynamic withQuery = false, dynamic withFragment = false]) String
Generate random URL from a given parameters.
mockUUID([String uuidType = 'ver4']) String
Generate version 4 based UUID.