drager / faker Goto Github PK
View Code? Open in Web Editor NEWA library for Dart that generates fake data.
License: MIT License
A library for Dart that generates fake data.
License: MIT License
if it is .. then do something for the name of @Marak
#Endgame
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.
Publish package on https://pub.dartlang.org.
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?
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).
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;
}
Will you add the DateTime generator?
Not sure whether something is odd with my env, but 1.1.0 pulled from pub, doesn't contain lorem or continents as per release notes.
I found this useful,
Thanks for the great library.
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
Guid and Phone-number have nullable values but the should not be.
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.
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();
}
✌️
Getting a random image with the same keywords and size parameters always returns the same image.
This can be an issue if I need multiple random images with the same search parameters.
The faker.randomGenerator.amount(...)
function returns a dynamic list. It would be better to have a List<T>
here.
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?
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
null-safe
version major release in March 2021.it would be much better if faker.lorem.sentence();
took a parameter and generated sentences according to that .. for example
faker.lorem.sentence(2);
/*
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi tristique lorem quis felis placerat sodales.
*/
It looks like faker.internet.email()
is generating its result by calling domainName()
, which in turn calls domainWord()
, which in turn uses a random element from lastNames
. Some of those last names have special characters that are illegal in email addresses (and domain names). e.g. teresa_buckridge@d'amore.info
was the latest offender I generated.
I think it's good to have special characters in faker data to make sure our systems can properly handle them, but they need to be limited to places where special characters are legal to begin with.
- String domainWord() => random.element(lastnames).toLowerCase()
+ String domainWord() => random
+ .element(lastnames)
+ .toLowerCase()
+ .replaceAll(new RegExp(r'[^a-z0-9\-]'), ''); // -- remove illegal domain characters
Resolve the health suggestions as proposed on https://pub.dartlang.org
The package has an 83% score on health in pub.dev, but can be increased to 100%
It would be nice if there was a random hour generate method with only numbers
Please, add null-safety support.
While using faker, I wanted to generate a DateTime that was in between 2 given dates (Not the years option).
I am creating this issue so I have something to put my PR against 😄
It'd be great if there could be a internet.userAgent()
feature, as this fits quite nicely when faking other things for network requests.
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.
It would be interesting to update to null safe
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(),
)
);
}
this not working
faker.image.avatar();
It would be nice to have phone number support
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.