-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ebf5974
commit 85884fd
Showing
8 changed files
with
104 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import 'dart:math'; | ||
|
||
import 'package:faker/faker.dart' show Faker, Internet; | ||
|
||
class PostFaker { | ||
static Map<String, dynamic> posts() { | ||
return { | ||
'data': List.generate(10, (index) => post()), | ||
}; | ||
} | ||
|
||
static Map<String, dynamic> post() { | ||
final faker = Faker(); | ||
|
||
// Random values for width, quality, and random suffix | ||
final random = Random(); | ||
|
||
// Constructing thumbnail URL with random parameters | ||
const imageUrl = 'https://fakeimg.pl/600x400'; | ||
const thumbUrl = '$imageUrl/400'; | ||
const fullUrl = imageUrl; | ||
final rawUrl = imageUrl.replaceFirst(RegExp(r'w=\d+'), 'w=2400'); | ||
final smallUrl = imageUrl.replaceFirst(RegExp(r'w=\d+'), 'w=400'); | ||
final regularUrl = imageUrl.replaceFirst(RegExp(r'w=\d+'), 'w=1080'); | ||
final smallS3Url = imageUrl.replaceFirst(RegExp(r'w=\d+'), 'w=400'); | ||
|
||
return { | ||
'uuid': faker.guid.guid(), | ||
'created_at': faker.date.dateTime().toIso8601String(), | ||
'updated_at': faker.date.dateTime().toIso8601String(), | ||
'color': faker.internet.color(), | ||
'description': faker.lorem.sentence(), | ||
'urls': { | ||
'thumb': thumbUrl, | ||
'full': fullUrl, | ||
'raw': rawUrl, | ||
'small': smallUrl, | ||
'regular': regularUrl, | ||
'small_s3': smallS3Url, | ||
}, | ||
'likes': faker.randomGenerator.integer(1000), | ||
'author': { | ||
'uuid': faker.guid.guid(), | ||
'name': faker.person.name(), | ||
'username': faker.person.name(), | ||
'first_name': faker.person.firstName(), | ||
'last_name': faker.person.lastName(), | ||
'avatar': faker.internet.httpsUrl(), | ||
'updated_at': faker.date.dateTime().toIso8601String(), | ||
'twitter_username': faker.person.name(), | ||
'bio': faker.lorem.sentence(), | ||
'total_likes': faker.randomGenerator.integer(1000), | ||
'total_photos': faker.randomGenerator.integer(1000), | ||
'instagram_username': faker.person.name(), | ||
}, | ||
'views': faker.randomGenerator.integer(1000), | ||
'downloads': faker.randomGenerator.integer(1000), | ||
}; | ||
} | ||
} | ||
|
||
extension XInternet on Internet { | ||
String color() { | ||
final random = Random(); | ||
const hexDigits = '0123456789ABCDEF'; | ||
String color = ''; | ||
for (int i = 0; i < 6; i++) { | ||
color += hexDigits[random.nextInt(16)]; | ||
} | ||
return color; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters