패키지, 저장소 및 앱 카테고리 검색

GitHub 저장소samieruashovo/flutter_faker_plus

flutter_faker_plus

samieruashovo/flutter_faker_plus open-source repository details.

flutter_faker_plus 프로젝트 이미지
스타
0
포크
0
최근 푸시(UTC)
2025. 12. 13.
프로젝트 상태
활성

원본 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 ↗