flutter_random_password 1.1.0 copy "flutter_random_password: ^1.1.0" to clipboard
flutter_random_password: ^1.1.0 copied to clipboard

A lightweight Dart package for generating random passwords combining lowercase, uppercase, numbers, and symbols.

A lightweight, dependency-free Dart package for generating random passwords made up of lowercase letters, uppercase letters, numbers, and symbols.

Features #

  • Generates a random password of any requested length.
  • Mixes up to four character sets — lowercase, uppercase, numbers, symbols — chosen randomly per character.
  • Each character set can be individually enabled or disabled.
  • Generates a random numeric PIN of any custom length (minimum 1, no upper bound).
  • Zero external dependencies (uses only dart:math).
  • Simple, single-method API.

Platform support #

This package is written in pure Dart — it has no Flutter SDK dependency and no platform channels, native code, or dart:io/dart:html usage. As a result it works identically on every platform supported by Dart and Flutter:

Platform Supported
Android
iOS
Web
Windows
macOS
Linux
Server / CLI (pure Dart)

Because it only depends on dart:math, it can also be used in plain Dart projects (backend, CLI tools, scripts) that don't depend on Flutter at all.

Getting started #

Requires Dart SDK ^3.11.5 (or a Flutter SDK that bundles it).

Add the package to your pubspec.yaml:

dependencies:
  flutter_random_password: ^1.0.1

Then run:

dart pub get
# or, in a Flutter project:
flutter pub get

Then import it:

import 'package:flutter_random_password/flutter_random_password.dart';

Usage #

import 'package:flutter_random_password/flutter_random_password.dart';

void main() {
  final pass = RandomPass();

  // Generate a 12-character random password using all character sets.
  final password = pass.generate(total: 12);
  print(password); // e.g. "aB3!kZ9$mQ2#"

  // Generate a numeric-only 6-digit PIN.
  final pin = pass.generate(
    total: 6,
    hasAlphabet: false,
    hasAlphabetUpper: false,
    hasSymbol: false,
  );
  print(pin); // e.g. "482913"
}

Or generate a numeric-only PIN of any custom length (minimum 1, no upper bound):

final pin = pass.generatePin(total: 4);
print(pin); // e.g. "8421"

final longPin = pass.generatePin(total: 20);
print(longPin); // e.g. "48291037561928374615"

See example/flutter_random_password_example.dart for a runnable example that generates 100 passwords of varying length (6–17 characters).

API #

RandomPass implements FlutterRandomPasswordBase:

abstract class FlutterRandomPasswordBase {
  String generate({
    required int total,
    bool hasAlphabet,
    bool hasNumeric,
    bool hasAlphabetUpper,
    bool hasSymbol,
  });

  String generatePin({required int total});
}

generate(...) returns a random password exactly total characters long, built from the enabled character sets:

Parameter Default Character set
total Password length (required)
hasAlphabet true Lowercase a-z
hasAlphabetUpper true Uppercase A-Z
hasNumeric true Digits 0-9
hasSymbol true Symbols !@#$%^&*()_+-={}|[]\:";'>?<,./`~

Throws an ArgumentError if:

  • total is 0 or negative, or
  • every has* flag is false (no character set left to draw from).

generatePin(...) returns a random numeric PIN exactly total digits long, drawn from 0-9.

Parameter Default Character set
total PIN length (required); minimum 1, no upper bound

Throws an ArgumentError if total is less than 1.

Additional information #

  • Package name is historical (flutter_random_password) but the package itself has no Flutter dependency — it works in any pure Dart project.
  • Character composition per generated character is random and independent, so a password is not guaranteed to contain at least one character from every set (e.g. a short password could end up all digits by chance).
  • Uses dart:math's default (non-seeded) Random, which is not cryptographically secure. Do not use this package to generate secrets such as encryption keys, tokens, or anything requiring cryptographic-strength randomness.
  • Contributions and issues are welcome via the project repository.

License #

Licensed under the MIT License © 2026 znd3v (zendevv.com).

1
likes
160
points
38
downloads

Documentation

API reference

Publisher

verified publisherzendevv.com

Weekly Downloads

A lightweight Dart package for generating random passwords combining lowercase, uppercase, numbers, and symbols.

Repository (GitHub)
View/report issues

License

MIT (license)

More

Packages that depend on flutter_random_password