A library for Dart that generates fake data

Last update: May 16, 2022

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();
  // [email protected]

  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

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.

GitHub

https://github.com/drager/faker
Comments
  • 1. Add vehicles

    Connection with issue(s)

    No open issue to add Vehicles. I needed it for a personal project and figured it was worth sharing.

    Testing and Review Notes

    Running unit tests should cover all cases

    Reviewed by kalebhermes at 2021-03-17 01:18
  • 2. adding FakerDataProvider

    Connected to #30

    hey @drager I made a few changes. just adding the feature of accepting a FakerDataProvider to the Faker class. right now FakerDataProvider only accepts a LoremDataProvider.

    also added a FakerDataProviderFa which does provide farsi lorem text. review the code if it looks ok let me know to do the same job with the other parts like address, person, etc.

    Reviewed by easazade at 2020-12-03 13:51
  • 3. Sugestion: seed for random generator

    Currently I don't see if there is a way to set a seed for the random generator. Something like in the python library 'faker' would be nice:

    from faker import Faker fake = Faker() Faker.seed(4321)

    Can't seem to find if the Random() function has a method to set it's seed?

    Reviewed by fflori4n at 2020-04-30 22:24
  • 4. Test Fails for restaurant

    When I run the test/runner.dart, a test fails for restaurant names. Maybe the regex is not working correctly for 'Applebee’s International, Inc.' case.

    Tests Log:

    00:00 +18 -1: food should be able to generate restaurant [E]
    
      Expected: match '^([\w\s\'-])+$'
        Actual: 'Applebee’s International, Inc.'
      
    
      package:test_api/src/frontend/expect.dart 154:30              fail
      package:test_api/src/frontend/expect.dart 148:3               _expect
      package:test_api/src/frontend/expect.dart 60:3                expect
      test/specs/food.dart 9:7                                      main.<fn>.<fn>
      package:test_api/src/backend/declarer.dart 172:27             Declarer.test.<fn>.<fn>.<fn>
      ===== asynchronous gap ===========================
      dart:async/zone.dart 1064:19                                  _CustomZone.registerBinaryCallback
      dart:async-patch/async_patch.dart 82:23                       _asyncErrorWrapperHelper
      package:test_api/src/backend/invoker.dart                     Invoker.waitForOutstandingCallbacks.<fn>
      dart:async/zone.dart 1126:13                                  _rootRun
      dart:async/zone.dart 1023:19                                  _CustomZone.run
      dart:async/zone.dart 1518:10                                  _runZoned
      dart:async/zone.dart 1465:12                                  runZoned
      package:test_api/src/backend/invoker.dart 243:5               Invoker.waitForOutstandingCallbacks
      package:test_api/src/backend/declarer.dart 170:33             Declarer.test.<fn>.<fn>
      dart:async/zone.dart 1126:13                                  _rootRun
      dart:async/zone.dart 1023:19                                  _CustomZone.run
      dart:async/zone.dart 1518:10                                  _runZoned
      dart:async/zone.dart 1465:12                                  runZoned
      package:test_api/src/backend/declarer.dart 169:13             Declarer.test.<fn>
      package:test_api/src/backend/invoker.dart 400:25              Invoker._onRun.<fn>.<fn>.<fn>.<fn>
      dart:async/future.dart 176:37                                 new Future.<fn>
      package:stack_trace/src/stack_zone_specification.dart 209:15  StackZoneSpecification._run
      package:stack_trace/src/stack_zone_specification.dart 119:48  StackZoneSpecification._registerCallback.<fn>
      dart:async/zone.dart 1122:38                                  _rootRun
      dart:async/zone.dart 1023:19                                  _CustomZone.run
      dart:async/zone.dart 925:7                                    _CustomZone.runGuarded
      dart:async/zone.dart 965:23                                   _CustomZone.bindCallbackGuarded.<fn>
      package:stack_trace/src/stack_zone_specification.dart 209:15  StackZoneSpecification._run
      package:stack_trace/src/stack_zone_specification.dart 119:48  StackZoneSpecification._registerCallback.<fn>
      dart:async/zone.dart 1126:13                                  _rootRun
      dart:async/zone.dart 1023:19                                  _CustomZone.run
      dart:async/zone.dart 949:23                                   _CustomZone.bindCallback.<fn>
      dart:async-patch/timer_patch.dart 23:15                       Timer._createTimer.<fn>
      dart:isolate-patch/timer_impl.dart 384:19                     _Timer._runTimers
      dart:isolate-patch/timer_impl.dart 418:5                      _Timer._handleMessage
      dart:isolate-patch/isolate_patch.dart 174:12                  _RawReceivePortImpl._handleMessage
      ===== asynchronous gap ===========================
      dart:async/zone.dart 1047:19                                  _CustomZone.registerCallback
      dart:async/zone.dart 964:22                                   _CustomZone.bindCallbackGuarded
      dart:async/timer.dart 54:45                                   new Timer
      dart:async/timer.dart 91:9                                    Timer.run
      dart:async/future.dart 174:11                                 new Future
      package:test_api/src/backend/invoker.dart 399:21              Invoker._onRun.<fn>.<fn>.<fn>
      dart:async/zone.dart 1126:13                                  _rootRun
      dart:async/zone.dart 1023:19                                  _CustomZone.run
      dart:async/zone.dart 1518:10                                  _runZoned
      dart:async/zone.dart 1465:12                                  runZoned
      package:test_api/src/backend/invoker.dart 387:9               Invoker._onRun.<fn>.<fn>
      package:test_api/src/backend/invoker.dart 438:15              Invoker._guardIfGuarded
      package:test_api/src/backend/invoker.dart 386:7               Invoker._onRun.<fn>
      package:stack_trace/src/chain.dart 101:24                     Chain.capture.<fn>
      dart:async/zone.dart 1126:13                                  _rootRun
      dart:async/zone.dart 1023:19                                  _CustomZone.run
      dart:async/zone.dart 1518:10                                  _runZoned
      dart:async/zone.dart 1465:12                                  runZoned
      package:stack_trace/src/chain.dart 99:12                      Chain.capture
      package:test_api/src/backend/invoker.dart 385:11              Invoker._onRun
      package:test_api/src/backend/live_test_controller.dart 197:5  LiveTestController._run
      package:test_api/src/backend/live_test_controller.dart 50:37  _LiveTest.run
      dart:async/future.dart 202:37                                 new Future.microtask.<fn>
      dart:async/zone.dart 1122:38                                  _rootRun
      dart:async/zone.dart 1023:19                                  _CustomZone.run
      dart:async/zone.dart 925:7                                    _CustomZone.runGuarded
      dart:async/zone.dart 965:23                                   _CustomZone.bindCallbackGuarded.<fn>
      dart:async/zone.dart 1126:13                                  _rootRun
      dart:async/zone.dart 1023:19                                  _CustomZone.run
      dart:async/zone.dart 925:7                                    _CustomZone.runGuarded
      dart:async/zone.dart 965:23                                   _CustomZone.bindCallbackGuarded.<fn>
      dart:async/schedule_microtask.dart 43:21                      _microtaskLoop
      dart:async/schedule_microtask.dart 52:5                       _startMicrotaskLoop
      dart:isolate-patch/timer_impl.dart 393:30                     _Timer._runTimers
      dart:isolate-patch/timer_impl.dart 418:5                      _Timer._handleMessage
      dart:isolate-patch/isolate_patch.dart 174:12                  _RawReceivePortImpl._handleMessage
    
    Reviewed by igorgoncalves at 2020-03-18 15:53
  • 5. Adds Image faker

    Connection with issue(s)

    Resolve issue #19

    Testing and Review Notes

    Generates a url to a image random image. The size of image is determined by width and height paramters. You can choose the image categories related by the keywords parameter separeted by comma .

    Example:

       faker.image.image(width: 1200, height: 900, keywords: 'nature,people');
    

    Result: https://source.unsplash.com/1200x900?nature,people

    To Do

    • [X] double check the original issue to confirm it is fully satisfied
    • [X] add testing notes and screenshots in PR description to help guide reviewers
    Reviewed by igorgoncalves at 2020-03-12 17:39
  • 6. Lorem.sentences() returning words instead of sentences

    Hi!

    I just saw that the Lorem.sentences method does not output sentences but words.

    Original

    List<String> sentences(numberOfSentences) {
        return Iterable<int>.generate(numberOfSentences).map((_) => word()).toList();
    }
    

    Expected

    List<String> sentences(num numberOfSentences) {
        return Iterable<int>.generate(numberOfSentences).map((_) => sentence()).toList();
    }
    

    ✌️

    Reviewed by phillippbertram at 2019-12-06 11:56
  • 7. JWT Support

    I'll submit a function to generate fake jwt. Today I use like internal function, but I think this is a useful function. What do you say?

    There's just one thing, this function needs "crypto" package of dev.dart. Is this a problem?

    Reviewed by ivanthz at 2021-03-12 19:49
  • 8. feat(phone-number): implemented phone number support

    Connection with issue(s)

    Resolve issue #33

    Testing and Review Notes

    All previous unit tests should pass. Added a new test for generating phone numbers.

    Reviewed by wim07101993 at 2020-12-17 14:44
  • 9. Sugestion: faker Image

    Based on Faker for PHP, the Image provider get images from lorem pixel or unplash to dowload images by categories.

    Other alternative is place kitten but only for cats photos.

    Exemple img URL: Lorem Pixel: http://lorempixel.com/800/600/ Unplash: https://source.unsplash.com/1600x900/?nature,water

    Faker PHP repository(use lorem pixel): https://github.com/fzaninotto/Faker/blob/master/src/Faker/Provider/Image.php Faker JS repository (use unplash): https://github.com/Marak/faker.js/blob/master/lib/image.js

    Reviewed by igorgoncalves at 2020-02-16 16:22
  • 10. -Swap out unittest and guiness packages for package:test, set env to Dart 2.0

    Hi thanks for taking the time to develop this faker implementation. I'm currently working on an app in flutter and i was using it to fake data in some models.

    I just upgraded my flutter install and sadly it isn't compatible with my current version of flutter. I can't remember my exact errors but the main issue was with the testing dependencies(unittest and guinness). Thankfully a lot of what they provided is available in package:test so I was able to easily port the tests over and remove any dependencies. I also set the environment to Dart 2.0.

    Reviewed by SimplyFaisal at 2018-09-06 00:12
  • 11. Add generics to `randomGenerator.element()`

    This change allows code like this, that would normally cause either cannot find declaration to go to or getter `values` isn't defined for the class Object, to resolve properly:

    var items = [
      {'a': 'foo', 'b': 'bar'},
      {'a': 'zip', 'b': 'zap'}
    ]
    var chosenItem = faker.randomGenerator.element(items).values;
    
    Reviewed by KOGI at 2019-05-06 20:03
  • 12. Ability to generate date with a specific format and add more attribute to person class

    I found this useful,

    • Ability to generate date with a specific format
    • Adding more attributes to a person which includes (Date of birth, Phone Number etc) Was using date and person to generate some data and i found out this is missing

    Thanks for the great library.

    Reviewed by cscoderr at 2022-05-08 02:02
  • 13. Vehicle doesn't use the same random instance as the others

    Relatively minor issue that I noticed today.

    Happened to be using vehicle to generate some reproducible data, however, it looks like the vehicle type doesn't take in the same random instance - which means it produces non-deterministic output.

    Thanks for a great library.

    Reviewed by edwardaux at 2022-04-10 20:40
  • 14. Latitude and Longitude

    It would be nice if Faker had support for creating Latitude and Longitude values.

    Something to this effect should work, with faker being the current instance instead of the global.

    It might sit under faker.address.latitude/faker.address.longitude or even faker.geospatial.latitude/faker.geospatial.longitude ?

    double longitude() {
      return -180 + faker.randomGenerator.decimal() * 180 * 2;
    }
    
    double latitude() {
      return -90 + faker.randomGenerator.decimal() * 90 * 2;
    }
    
    Reviewed by axrs at 2022-03-25 04:11
  • 15. adding the rest of the DataProviders needed to add multi-lingual support for the faker library

    adding the rest of the DataProviders needed to add multi-lingual support for the faker library Connected to #30

    TODO:

    • docs needs to be updated
    • add guide in documents on how to add default localized data for other languages
    • nothing has been tested. some examples or tests needs to be added

    (I can probably do this next Saturday or Sunday)

    Reviewed by easazade at 2021-07-04 11:38

Related

Converts SVG icons to OTF font and generates Flutter-compatible class. Provides an API and a CLI tool.

Fontify The Fontify package provides an easy way to convert SVG icons to OpenType font and generate Flutter-compatible class that contains identifiers

May 1, 2022
Generates utilities to aid in serializing to/from JSON.

Provides Dart Build System builders for handling JSON. json_serializable Package: https://pub.dev/packages/json_serializable Source code The core pack

May 18, 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
Generate random data(string, integer, IPs etc...) using Dart.
Generate random data(string, integer, IPs etc...) using Dart.

Generate random data using Features API provides generation of: Integers in any range of numbers Strings with various characters and length Colors rep

Apr 17, 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
A Dart library to parse Portable Executable (PE) format

pefile A Dart library to parse Portable Executable (PE) format Usage A simple usage example: var pe = pefile.parse('C:\\Windows\\System32\\notepad.exe

Dec 25, 2021
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 Dart Time Machine is a date and time library for Flutter, Web, and Server with support for timezones, calendars, cultures, formatting and parsing.
The Dart Time Machine is a date and time library for Flutter, Web, and Server with support for timezones, calendars, cultures, formatting and parsing.

The Dart Time Machine is a date and time library for Flutter, Web, and Server with support for timezones, calendars, cultures, formatting and parsing.

Oct 8, 2021
A comprehensive, cross-platform path manipulation library for Dart.

A comprehensive, cross-platform path manipulation library for Dart. The path package provides common operations for manipulating paths: joining, split

May 12, 2022
A fast algorithm for finding polygon pole of inaccessibility implemented as a Dart library.

polylabel Dart port of https://github.com/mapbox/polylabel. A fast algorithm for finding polygon pole of inaccessibility implemented as a Dart library

Nov 13, 2021
Dart library for unescaping HTML-encoded strings

html_unescape A Dart library for unescaping HTML-encoded strings. Supports: Named Character References ( ) 2099 of them Decimal Character Referen

Mar 10, 2022
This is a dart library covering nearly 100% of the latest Planning Center public API.

Planning Center API for Dart Planning Center is an online platform for church management. It provides multiple apps for things like check-ins, service

Mar 17, 2022
A JMAP client library in Dart to make JMAP method calls and process the responses

JMAP Dart client A JMAP client library to make JMAP method calls and process the responses. We most notably use it to write the TMail Flutter applicat

May 26, 2022
Library for help you make userbot or bot telegram and support tdlib telegram database and only support nodejs dart and google-apps-script

To-Do telegram client dart ✅️ support multi token ( bot / userbot ) ✅️ support bot and userbot ✅️ support telegram-bot-api local server ✅️ support tel

Apr 30, 2022
A Pure Dart Utility library that checks for an Active Internet connection

This Code comes from https://github.com/komapeb/data_connection_checker * ?? Internet Connection Checker A Pure Dart Utility library that checks for a

May 26, 2022
Dart common utils library. DateUtil, EncryptUtil, JsonUtil, LogUtil, MoneyUtil, NumUtil, ObjectUtil, RegexUtil, TextUtil, TimelineUtil, TimerUtil.
Dart common utils library. DateUtil, EncryptUtil, JsonUtil, LogUtil, MoneyUtil, NumUtil, ObjectUtil,  RegexUtil, TextUtil, TimelineUtil, TimerUtil.

Dart common utils library. DateUtil, EncryptUtil, JsonUtil, LogUtil, MoneyUtil, NumUtil, ObjectUtil, RegexUtil, TextUtil, TimelineUtil, TimerUtil.

May 26, 2022
Reflectable is a Dart library that allows programmers to eliminate certain usages of dynamic reflection by specialization of reflective code to an equivalent implementation using only static techniques

Reflectable is a Dart library that allows programmers to eliminate certain usages of dynamic reflection by specialization of reflective code to an equivalent implementation using only static techniques. The use of dynamic reflection is constrained in order to ensure that the specialized code can be generated and will have a reasonable size.

May 18, 2022
GPT-3 recipe generator for the GPT-3 Makeathon by TUM.AI. Developed by team Taste the data.
GPT-3 recipe generator for the GPT-3 Makeathon by TUM.AI. Developed by team Taste the data.

GPT-3 Makeathon by TUM.AI - Team: Taste the Data Team - Taste the Data: Carmen Heger <@stedomedo> David Stiftl <@stiftlD> Christopher Schütz <@cdschtz

Jan 11, 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