random_toolkit 0.1.0 copy "random_toolkit: ^0.1.0" to clipboard
random_toolkit: ^0.1.0 copied to clipboard

一个功能强大的Flutter随机数据生成工具包,提供各种类型的随机数据生成功能。

Random Toolkit #

中文文档 | English Documentation

[Random Toolkit Logo]

A powerful pure Dart random data generation toolkit that provides various types of random data generation functionality. Supports Flutter, Dart, and all Dart platforms.

pub package License: MIT

Features #

✨ Pure Dart Package Advantages #

  • 🚀 Cross-platform compatibility: Supports all Dart platforms (Flutter, Web, Server, Desktop)
  • 📦 Lightweight: No native dependencies, small package size
  • 🔧 Easy integration: Simple dependency management, no platform configuration required
  • 🛠️ High performance: Pure Dart implementation, efficient runtime
  • 🔄 Easy maintenance: Unified codebase, simplified maintenance costs

🎲 Basic Random Data #

  • Random integers, floating-point numbers, booleans
  • Random strings (supports custom character sets)
  • UUID generation
  • Array random selection and shuffling

👤 Personal Information Generation #

  • Random names (supports Chinese and English)
  • Random email addresses
  • Random phone numbers (China mainland format)

🎨 Visual Elements #

  • Random colors (Color objects, hexadecimal strings)
  • Material Design colors
  • Random image URLs
  • Random avatar URLs

📍 Geolocation #

  • Random addresses (supports Chinese and English)

⏰ Date & Time #

  • Random dates
  • Random timestamps
  • Custom date ranges

👥 Complete User Information #

  • Generate random user objects containing all information
  • ID, name, email, phone, address, avatar, etc.

Installation #

Add the dependency to your pubspec.yaml file:

dependencies:
  random_toolkit: ^0.1.0

Run flutter pub get to fetch the dependencies.

flutter pub get

Usage #

Import the Package #

In your Dart file, import the random_toolkit package:

import 'package:random_toolkit/random_toolkit.dart';

Starting from version 0.0.9, dot-syntax calls are supported for cleaner code and better IDE intellisense:

import 'package:random_toolkit/random_toolkit.dart';

// Basic random data
int num = random.integer(1, 100);
double dec = random.decimal(0.0, 1.0);
bool flag = random.boolean();
String str = random.string(10);
String id = random.uuid();
String item = random.choice(['A', 'B', 'C']);

// Personal information
String chineseName = random.name();
String englishName = random.name(chinese: false);
String email = random.email();
String cnPhone = random.phoneNumber();
String usPhone = random.phoneNumber(countryCode: 'US');

// Visual elements
Color randomColor = random.color();
String hexColor = random.hexColor();
Color materialColor = random.materialColor();
String imageUrl = random.imageUrl(width: 300, height: 200);
String avatarUrl = random.avatarUrl(size: 100);

// Geolocation
String chineseAddress = random.address();
String englishAddress = random.address(chinese: false);

// Date & Time
DateTime randomDate = random.date(start: DateTime(2020), end: DateTime(2024));
int timestamp = random.timestamp();

// Complete user information
Map<String, dynamic> user = random.user();
Map<String, dynamic> englishUser = random.user(chinese: false);

Using the short alias rt:

// rt is a short alias for random, with identical functionality
int num = rt.integer(1, 100);
String name = rt.name();
Color color = rt.color();
Map<String, dynamic> user = rt.user();

Traditional API (Backward Compatible) #

If you prefer namespace-style calls, the original API is fully preserved:

Basic Random Data Generation #

// Random integer
int randomInt = RandomToolkit.generators.integer(1, 100);

// Random floating-point number
double randomDouble = RandomToolkit.generators.decimal(0.0, 1.0);

// Random boolean
bool randomBool = RandomToolkit.generators.boolean();

// Random string
String randomString = RandomToolkit.generators.string(length: 10);

// UUID generation
String uuid = RandomToolkit.generators.uuid();

// Array random selection
String choice = RandomToolkit.generators.choice(['A', 'B', 'C']);

Personal Information Generation #

// Random names (supports Chinese and English)
String chineseName = RandomToolkit.person.name(chinese: true);
String englishName = RandomToolkit.person.name(chinese: false);

// Random email
String email = RandomToolkit.person.email();

// Random phone numbers (supports China and US formats)
String cnPhone = RandomToolkit.person.phoneNumber(countryCode: 'CN');
String usPhone = RandomToolkit.person.phoneNumber(countryCode: 'US');

Visual Elements #

// Random color
Color randomColor = RandomToolkit.visual.color();

// Hexadecimal color string
String hexColor = RandomToolkit.visual.hexColor();

// Material Design color
Color materialColor = RandomToolkit.visual.materialColor();

// Random image URL
String imageUrl = RandomToolkit.visual.imageUrl(width: 300, height: 200);

// Random avatar URL
String avatarUrl = RandomToolkit.visual.avatarUrl(size: 100);

Geolocation #

// Random addresses (supports Chinese and English)
String chineseAddress = RandomToolkit.location.address(chinese: true);
String englishAddress = RandomToolkit.location.address(chinese: false);

Date & Time #

// Random date
DateTime randomDate = RandomToolkit.dateTime.date(
  start: DateTime(2020, 1, 1),
  end: DateTime(2024, 12, 31),
);

// Random timestamp
int timestamp = RandomToolkit.dateTime.timestamp();

Complete User Information #

// Generate random users (supports Chinese and English)
Map<String, dynamic> chineseUser = RandomToolkit.userGenerator.generate(chinese: true);
Map<String, dynamic> englishUser = RandomToolkit.userGenerator.generate(chinese: false);

Example Application #

Check out the complete example application in the example folder to learn how to use all features in real projects.

cd example
flutter run

Platform Support #

  • ✅ Android
  • ✅ iOS
  • ✅ Web
  • ✅ Windows
  • ✅ macOS
  • ✅ Linux

Version Requirements #

  • Flutter: >= 2.5.0
  • Dart: >= 2.19.6

Contributing #

Contributions are welcome! Feel free to submit Issues and Pull Requests.

  1. Fork this project
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License #

This project is licensed under the MIT License - see the LICENSE file for details.

Changelog #

See CHANGELOG.md for version update history.

0
likes
140
points
121
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

一个功能强大的Flutter随机数据生成工具包,提供各种类型的随机数据生成功能。

Homepage
Repository
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on random_toolkit