पैकेज, रिपॉज़िटरी और ऐप श्रेणियाँ खोजें

GitHub रिपॉज़िटरीsamieruashovo/flutter_faker_plus

flutter_faker_plus

samieruashovo/flutter_faker_plus open-source repository details.

flutter_faker_plus प्रोजेक्ट कवर
स्टार
0
फ़ोर्क
0
अंतिम पुश (UTC)
13 दिस॰ 2025
प्रोजेक्ट स्थिति
सक्रिय

मूल README

यह अंग्रेज़ी मूल स्नैपशॉट है। नवीनतम सामग्री GitHub पर देखें।

flutter_faker_plus

A comprehensive fake data generator for Flutter/Dart applications.

Mobile Screenshot

🚀 Features

  • User Profiles: Generate random user profiles with:
    • Name
    • Email
    • Phone number
    • Address
    • Date of birth
    • Gender
    • Profile picture URL
    • Bio
  • E-commerce Products: Create random product data including:
    • Product name
    • Price
    • Category
  • Geolocation: Generate random latitude and longitude coordinates.
  • Lorem Ipsum: Added Lorem Ipsum placeholder text.
  • Future Plans:
    • Add image URLs for e-commerce products.
    • Support additional fake data types.
    • Implement a fake QR code generator.

Flutter Faker Data Generator Example

This example demonstrates how to generate fake user, product, and location data using the flutter_faker_plus library in Flutter.


void main() {
  WidgetsFlutterBinding.ensureInitialized();

  // Register all mock routes
  setupMockServer();

  runApp(const FakeDataApp());
}


class FakeDataApp extends StatelessWidget {
  const FakeDataApp({super.key});
  @override
  Widget build(BuildContext context) {
    // Generate fake user, product, and location data using flutter_faker_plus.
    final UserProfile user =
        UserProfile.generate(); // Generate a fake user profile.
    final EcommerceProduct product =
        EcommerceProduct.generate(); // Generate a fake e-commerce product.
    final GeoLocation location =
        GeoLocation.generate(); // Generate a fake geo-location.

    final LoremIpsum loremIpsum = LoremIpsum();
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('Fake Data Generator Example'),
        ),
        body: SingleChildScrollView(
          child: Padding(
            padding: const EdgeInsets.all(16.0),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text('User Profile:', style: TextStyle(fontSize: 20)),
                // Displays a heading for the user profile section.

                Text('Name: ${user.name}'),
                // Displays the generated user's name.

                Text('Email: ${user.email}'),
                // Displays the generated user's email.

                Text('Phone: ${user.phoneNumber}'),
                // Displays the generated user's phone number.

                Text('Address: ${user.address}'),
                // Displays the generated user's address.

                Text('Date of Birth: ${user.dateOfBirth}'),
                // Displays the generated user's date of birth.

                Text('Gender: ${user.gender}'),
                // Displays the generated user's gender.

                Image.network(user.profilePictureUrl),
                // Displays the user's profile picture from a network URL.

                Text('Bio: ${user.bio}'),
                // Displays the generated user's bio.

                SizedBox(height: 20),
                // Adds vertical spacing of 20 pixels.

                Text('E-Commerce Product:', style: TextStyle(fontSize: 20)),
                // Displays a heading for the product section.

                Text('Product: ${product.name}'),
                // Displays the product name.

                Text('Category: ${product.category}'),
                // Displays the product category.

                Text('Price: \$${product.price}'),
                // Displays the product price prefixed with a dollar sign.

                SizedBox(height: 20),
                // Adds vertical spacing of 20 pixels.

                Text('Geo-Location:', style: TextStyle(fontSize: 20)),
                // Displays a heading for the geo-location section.

                Text('Latitude: ${location.latitude}'),
                // Displays the generated latitude.

                Text('Longitude: ${location.longitude}'),
                // Displays the generated longitude.

                SizedBox(height: 20),
                // Adds vertical spacing of 20 pixels.

                Text('Lorem Ipsum:', style: TextStyle(fontSize: 20)),
                Text(
                  loremIpsum.generate(words: 20),
                ),
                SizedBox(height: 5),
                Text(
                  loremIpsum.generate(
                      words: 60, paragraphs: 3, showLoremIpsum: true),
                ),
                SizedBox(
                  height: 600,
                  child: UserPage())
              ],
            ),
          ),
        ),
      ),
    );
  }
}

🧪 Mock API Requests

flutter_faker_plus comes with a mock backend server for testing without a real API.

  1. Setup Mock Server
import 'package:flutter/material.dart';
import 'mock_server.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();

  setupMockServer(); // Register all mock routes

  runApp(const FakeDataApp());
}

  1. ApiService Example
import 'mock_server.dart';

class ApiService {
  final _client = MockHttpClient(mockApi);

  Future<List<Map<String, dynamic>>> getUsers() async {
    final res = await _client.request(method: HttpMethod.get, path: '/users');
    return (res.data as List).map((e) => Map<String, dynamic>.from(e)).toList();
  }

  Future<Map<String, dynamic>> createUser(Map<String, dynamic> payload) async {
    final res = await _client.request(
      method: HttpMethod.post,
      path: '/users',
      body: payload,
    );
    return Map<String, dynamic>.from(res.data);
  }
}
  1. Using Mock Requests in Widgets
final api = ApiService();

FutureBuilder<List<Map<String, dynamic>>>(
  future: api.getUsers(),
  builder: (context, snapshot) {
    if (!snapshot.hasData) return CircularProgressIndicator();
    final users = snapshot.data!;
    return ListView.builder(
      itemCount: users.length,
      itemBuilder: (_, i) {
        final u = users[i];
        return ListTile(
          title: Text(u['name'] ?? 'No Name'),
          subtitle: Text(u['email'] ?? 'noemail@domain.com'),
        );
      },
    );
  },
);
  1. Create New User
await api.createUser({
  'name': 'John Doe',
  'email': 'john.doe@example.com',
});

🛠 Installation

Add flutter_faker_plus to your pubspec.yaml file:

dependencies:
  flutter_faker_plus: ^2.0.0
Samier Uddin Ahammad Shovo GitHub avatar
GitHub लेखक

Samier Uddin Ahammad Shovo ↗

Software Engineer | Flutter | Django | ML/AI

NeosCoderUttara, Dhaka, Bangladesh
भाषाएँDartC++CMakeSwiftCHTMLKotlinObjective-C

इस रिपॉज़िटरी के पैकेज

उपयोग की गई निर्भरताएँ

निर्भरता सूची 4 आइटम

  • flutter{"sdk":"flutter"}
  • intl^0.20.2
  • flutter_testडेवलपमेंट{"sdk":"flutter"}
  • flutter_lintsडेवलपमेंट^5.0.0

अपने प्रोजेक्ट के लिए रिपॉज़िटरी कैसे चुनें?

उपयोग के अनुसार छाँटें, गतिविधि की तुलना करें और अपनाने से पहले मूल प्रोजेक्ट की आवश्यकताएँ जाँचें।

  1. नाम, लेखक या विवरण से खोजें और तकनीकी विषय से परिणाम सीमित करें।
  2. स्टार, फ़ोर्क और हाल के पुश की तुलना करें। स्टार रुचि दर्शाते हैं, गुणवत्ता की गारंटी नहीं।
  3. उपयोग से पहले GitHub पर README, लाइसेंस और Issues जाँचें।

स्रोत और रखरखाव

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗