Fake class
A comprehensive, full-featured fake data generator utility (Fake) designed for
unit testing, widget testing, mock models, UI placeholders, network simulation,
and in-memory/disk temporary image and file creation.
Usage Example:
import 'package:flutter_prakash_core/fp_core.dart';
// 1. Mock User Data & Profiles
final name = Fake.fullName;
final email = Fake.email;
final avatar = Fake.avatarUrl();
final bio = Fake.paragraph;
final socials = Fake.socialLink('github');
// 2. Mock Media & Files
final placeholderUrl = Fake.imageUrl(width: 600, height: 400);
final memoryBytes = await Fake.imageMemory(color: Colors.red);
final transparentBytes = Fake.transparentImageMemory();
final tempFile = await Fake.imageFile(filename: 'profile.png');
// 3. Mock Collections & Lists
final mockUsers = Fake.list((i) => {
'id': Fake.id,
'name': Fake.fullName,
'email': Fake.email,
'price': Fake.price(min: 10, max: 99),
}, count: 5);
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- address → String
-
Generates a fake street address.
no setter
- boolean → bool
-
Generates a random boolean.
no setter
- city → String
-
Generates a fake city name.
no setter
- country → String
-
Generates a fake country.
no setter
- creditCardNumber → String
-
Generates a fake credit card number.
no setter
- email → String
-
Generates a fake email address.
no setter
- firstName → String
-
Generates a fake first name.
no setter
- fullName → String
-
Generates a fake full name.
no setter
- id → String
-
Generates a fake UUID v4.
no setter
- jobTitle → String
-
Generates a fake job title.
no setter
- lastName → String
-
Generates a fake last name.
no setter
-
latLng
→ Map<
String, double> -
Generates fake geographical coordinates
(latitude, longitude).no setter - paragraph → String
-
Generates a fake paragraph of text.
no setter
- phoneNumber → String
-
Generates a fake phone number.
no setter
- sentence → String
-
Generates fake sentence text.
no setter
- url → String
-
Generates a fake website URL.
no setter
- username → String
-
Generates a fake username.
no setter
Static Methods
-
avatarUrl(
{int size = 200, String? gender}) → String - Generates an avatar image URL.
-
element<
T> (List< T> items) → T -
Picks a random element from a given
itemslist. -
futureDate(
{int maxDaysAhead = 365}) → DateTime - Generates a fake future DateTime.
-
imageFile(
{String? filename, int width = 100, int height = 100, Color color = Colors.blue}) → Future< File> - Creates a temporary image File on local disk.
-
imageMemory(
{int width = 100, int height = 100, Color color = Colors.blue}) → Future< Uint8List> -
Generates raw
Uint8Listimage bytes in memory (1x1 transparent PNG or colored PNG). -
imageUrl(
{int width = 400, int height = 400, String? category, int? seed}) → String - Generates a placeholder image URL using Unsplash or Picsum.
-
integer(
{int min = 0, int max = 100}) → int -
Generates a random integer within
minandmax. -
list<
T> (T generator(int index), {int count = 10}) → List< T> -
Returns a list generated by calling
generatorcounttimes. -
paragraphs(
[int count = 3]) → List< String> - Generates multiple fake paragraphs.
-
pastDate(
{int maxDaysAgo = 365}) → DateTime - Generates a fake past DateTime.
-
price(
{double min = 5.0, double max = 500.0}) → double - Generates a random double price amount.
- Generates a fake social media link (Twitter, GitHub, LinkedIn, Instagram, etc.).
-
title(
[int wordCount = 4]) → String - Generates a fake title/sentence.
-
transparentImageMemory(
) → Uint8List - Synchronously returns tiny 1x1 transparent PNG bytes for mock Image.memory widgets.