random_string
2.3.1, released 5 years ago by an unverified publisher
Generates random ASCII strings, numbers, and alphanumeric sequences for testing purposes.
What it does
Provides functions like randomString, randomNumeric, randomAlpha, and randomAlphaNumeric to create random data. Allows custom random providers, including secure ones, and includes a randomBetween utility with range validation.
AI-written summary of version 2.3.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need quick, non‑cryptographic random strings for tests or mock data
- You want to customize the random source, e.g., using Random.secure
Skip it when
- Cryptographic security is required
- You need locale‑aware or Unicode strings
Strengths
- Zero dependencies
- Simple API
- Customizable random provider
Weaknesses
- Not suitable for security‑critical use
- Limited to ASCII characters
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
import 'package:random_string/random_string.dart';
void main() {
print(randomString(10)); // e.g., aZ9~kL2pQ
print(randomNumeric(4)); // e.g., 3259
print(randomAlpha(5)); // e.g., aRztC
}
Alternatives
Packages that do the same job and could replace random_string.
- random_user_agents
Generate random User-Agent strings for Dart/Flutter apps
72Compare - validators2
String validation and sanitization for Dart.
83Compare - ulid
Lexicographically sortable 128-bit identifier generator.
78Compare - nanoid2
A tiny, secure, URL-friendly, unique string ID generator with a pure Dart API.
74Compare
Works with
Packages commonly used together with random_string: ones it builds on, ones built on it, and its own family.