diff --git a/lib/src/faker.dart b/lib/src/faker.dart index 7bf85f6..89fffbb 100644 --- a/lib/src/faker.dart +++ b/lib/src/faker.dart @@ -7,7 +7,6 @@ import 'conference.dart'; import 'currency.dart'; import 'food.dart'; import 'guid.dart'; -import 'image.dart'; import 'internet.dart'; import 'job.dart'; import 'person.dart'; @@ -23,7 +22,6 @@ class Faker { final Currency currency; final Food food; final Guid guid; - final Image image; final Internet internet; final Job job; final Lorem lorem; @@ -39,7 +37,6 @@ class Faker { currency = const Currency(), food = const Food(), guid = const Guid(), - image = const Image(), internet = const Internet(), job = const Job(), lorem = const Lorem(), diff --git a/lib/src/internet.dart b/lib/src/internet.dart index a39b71e..1be855d 100644 --- a/lib/src/internet.dart +++ b/lib/src/internet.dart @@ -1,7 +1,4 @@ -import '../faker.dart'; import 'data/person/firstnames.dart'; -import 'data/user_agent/user_agent.dart'; -import 'data/user_agent/user_agent_data.dart'; import 'data/person/lastnames.dart'; import 'random_generator.dart'; @@ -152,25 +149,4 @@ class Internet { /// faker.internet.password(); /// ``` String password({int length = 10}) => random.string(length, min: length); - - /// Generates an User Agent from Predefined Dictionary - /// with the given [osName] if provided. - /// if not provided [osName] is an empty String or [''] - /// - /// Example: - /// ```dart - /// faker.internet.userAgent(); - /// faker.internet.userAgent(osName:'ios'); - /// ``` - String userAgent({String osName = ''}) => random - .element(UserAgents.fromJson(userAgentDatas) - .userAgents - .map((e) => e) - .where( - (element) => - element.osName.toLowerCase().contains(osName.toLowerCase()), - ) - .toList()) - .userAgent - .toString(); } diff --git a/lib/src/random_generator.dart b/lib/src/random_generator.dart index c3c91b5..d35db9f 100644 --- a/lib/src/random_generator.dart +++ b/lib/src/random_generator.dart @@ -4,6 +4,7 @@ var _rng = Random(); const random = RandomGenerator(); + class RandomGenerator { const RandomGenerator(); @@ -91,4 +92,14 @@ class RandomGenerator { String fromPatternToHex(List pattern) => element(pattern).splitMapJoin('#', onMatch: (_) => numbers(16, 1).map((number) => number.toRadixString(16)).join()); + + /// Sets [ seed ] as the seed of random generator [_rng]. + /// + /// Example: + /// ```dart + /// faker.RandomGenerator.setSeed(1); + /// ``` + void setSeed(int seed){ + _rng = Random(seed); + } }