faker 1.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 95

faker #

Build Status Coverage Status Faker on pub

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 usage example:

import 'package:faker/faker.dart';

main() {
  var faker = new Faker();

  faker.internet.email();
  // francisco_lebsack@buckridge.com

  faker.internet.ipv6Address();
  // 2450:a5bf:7855:8ce9:3693:58db:50bf:a105

  faker.internet.userName();
  // fiona-ward

  faker.person.name();
  // Fiona Ward

  faker.person.prefix();
  // Mrs.

  faker.person.suffix();
  // Sr.
  
  faker.lorem.sentence();
  // Nec nam aliquam sem et
}

Features and bugs #

Please file feature requests and bugs at the issue tracker.

Copyright (c) 2015 Jesper HÃ¥kansson. See LICENSE for details. Copyright (c) 2013 Emmanuel Oga. Copyright (c) 2012 Daniele Faraglia. Copyright (c) 2007 Benjamin Curtis.

Changelog #

1.1.0 #

  • Added lorem sentences and words
  • Added continents
  • Added generics to randomGenerator.element()

1.0.0 #

  • Make faker compatible with Dart 2.0.

0.0.5 #

  • fix: Remove illegal chars from generated domain words

0.0.4 #

  • Added food generator, includes restaurants, dishes and cuisines

0.0.3 #

  • fix: Type faker constant to Faker

0.0.2 #

  • Added support for guids
  • Added fromPatternToHex method that generates a random set of numbers from a given pattern and return it as hex

0.0.1 #

  • Initial release

example/faker.dart

library faker.example;

import 'package:faker/faker.dart';

main() {
  // Generate some different types of data.
  print(faker.address.country());
  print(faker.company.name());
  print(faker.currency.code());
  print(faker.internet.ipv4Address());
  print(faker.job.title());
  print(faker.person.firstName());
  print(faker.sport.name());

  // Generate a random amount of IP v4 addresses (max 10).
  print(random.amount((_) => faker.internet.ipv4Address(), 10));

  // Generate random boolean.
  print(random.boolean());

  // Generate random decimal.
  print(random.decimal());
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  faker: ^1.1.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:faker/faker.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
91
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
95
Learn more about scoring.

We analyzed this package on Oct 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:faker/faker.dart.

Health suggestions

Format lib/src/data/address/continents.dart.

Run dartfmt to format lib/src/data/address/continents.dart.

Format lib/src/data/lorem/sentences.dart.

Run dartfmt to format lib/src/data/lorem/sentences.dart.

Format lib/src/lorem.dart.

Run dartfmt to format lib/src/lorem.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
Dev dependencies
test ^1.2.0