A library for Dart that generates fake data

Overview

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.

Comments
  • Add vehicles

    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

    opened by kalebhermes 8
  • adding FakerDataProvider

    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.

    opened by easazade 5
  • Sugestion: seed for random generator

    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?

    enhancement help wanted 
    opened by fflori4n 5
  • Test Fails for restaurant

    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
    
    opened by igorgoncalves 4
  • Adds Image faker

    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
    opened by igorgoncalves 4
  • Lorem.sentences() returning words instead of sentences

    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();
    }
    

    ✌️

    help wanted 
    opened by phillippbertram 4
  • JWT Support

    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?

    opened by ivanthz 3
  • feat(phone-number): implemented phone number support

    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.

    opened by wim07101993 3
  • Sugestion: faker Image

    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

    enhancement help wanted 
    opened by igorgoncalves 3
  • -Swap out unittest and guiness packages for package:test, set env to Dart 2.0

    -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.

    opened by SimplyFaisal 3
  • Soon a release?

    Soon a release?

    Hi @drager,

    I wanted to know if a release is planned soon. I would like to use some features that are not available on the current release (ex: latitude).

    opened by lsaudon 2
  • Multiple fakers in a list

    Multiple fakers in a list

    I am trying to create multiple users with lastName, firstName, email and so on... I have a for loop and call faker each time, but it's creating the same user multiple times. I expected it to create multiple users with different names and so on...

    Code snippet

    for (int i = 0; i < 10; i++){
       var faker = Fake();
      
      users.add(
        Users(
          userid: faker.person.random.string(10),
          name: faker.person.firstName(),
          surname: faker.person.lastName(),
          phone: faker.phoneNumber.us(),
          email: faker.internet.email(),
          username: faker.internet.userName(),
        )
      );
    }
    
    opened by RicardoMudinyane 0
  • Pass RandomGenerator in private in the specific generator.

    Pass RandomGenerator in private in the specific generator.

    RandomGenerator is public in all generator. Is this what is intended?

    So we can do as below, which seems illogical to me. faker.color.random.decimal();

    import 'data/colors/colors.dart';
    import 'random_generator.dart';
    
    class Color {
      const Color(this.random);
    
      final RandomGenerator random;
    
      /// Generates a color name.
      ///
      /// Example:
      /// ```dart
      ///   faker.colors.color();
      /// ```
      String color() => random.element(allColors);
    
      /// Generates a color name from a smaller list of colors.
      ///
      /// Example:
      /// ```dart
      ///   faker.colors.commonColor();
      /// ```
      String commonColor() => random.element(commonColors);
    }
    

    This will be a breaking change, but it is possible to modify it.

    opened by lsaudon 0
  • Ability to generate date with a specific format and add more attribute to person class

    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.

    opened by cscoderr 2
  • 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

    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)

    opened by easazade 2
  • add multi language support

    add multi language support

    it will be great to add support for other languages as well. though I understand that there are alot of languages and comming up with a solution to this problem can be hard.

    one problem is that some languages are RTL (like farsi aka persian) unlike english which is LTR. and developers who make their app RTL first will override the flutter app locale to show the entire app in RTL. because of this showing faker's fake text which are read from left to right (LTR) because they are in english in an app which loaded its entire widget tree in (RTL) is very confusing.

    enhancement help wanted 
    opened by easazade 16
Releases(v2.1.0)
Owner
Jesper Håkansson
🦀
Jesper Håkansson
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

Igor Kharakhordin 88 Oct 28, 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

Google 1.4k Jan 8, 2023
A builder that generates an ArgsParser from a class

Parse command line arguments directly into an annotation class using the Dart Build System. Example Annotate a class with @CliOptions() from package:b

Kevin Moore 43 Oct 30, 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

António Nicolau 30 Dec 29, 2022
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

Dinko Pehar 14 Apr 17, 2022
Destiny is a new, mock-data generator for Dart/Flutter

Destiny is a new, mock-data generator for Dart/Flutter. It uses static methods couched in a destiny namespace as the API.

Aditya Kishore 11 Sep 16, 2022
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

null 4 Sep 12, 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

Bangladesh Coding Soldierz 3 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.

null 2 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

Dart 159 Dec 29, 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

André Sousa 2 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

Filip Hracek 36 Dec 20, 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

null 1 Oct 6, 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

LINAGORA 18 Dec 19, 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

Azka Full Snack Developer:) 73 Jan 7, 2023
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

Rounak Tadvi 61 Nov 25, 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.

null 1.3k Dec 22, 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.

Google 318 Dec 31, 2022
A Open Source Dart Library

A Open Source Dart Library

Debojyoti Singha 2 Apr 19, 2022