flutter_password_scoring 0.0.2+1 copy "flutter_password_scoring: ^0.0.2+1" to clipboard
flutter_password_scoring: ^0.0.2+1 copied to clipboard

Helper library to score password strength with `dart_zxcvbn` and provide suggestions for improvement.

flutter_password_scoring flutter_password_scoring flutter_password_scoring melos

flutter_password_scoring #

❗ THIS PACKAGE IS STILL WORK IN PROGRESS ❗

Description #

The primary goal of this package is to support dart_zxcvbn in Flutter.

To achieve this and, as much as possible, not block the main thread and avoid dropped frames, we create an Isolate in which the dart_zxcvbn library is initialized and where further user password evaluations take place. Responses from the library are passed to the PasswordScoringBuilder (which acts as a facade for StreamBuilder), and that's where the widget tree is constructed.

Usage #

  1. Declare default handler for scorer isolate somewhere in your code - it has to be global function or static member of some class!

    import 'dart:isolate';
    
    import 'package:dart_zxcvbn/dart_zxcvbn.dart';
    import 'package:dart_zxcvbn_language_common/dart_zxcvbn_language_common.dart';
    import 'package:dart_zxcvbn_language_en/dart_zxcvbn_language_en.dart';
    
    Future<void> handleScoring(SendPort sendPort) async {
      ReceivePort receiverPort = ReceivePort();
      sendPort.send(receiverPort.sendPort);
    
      final langCommon = LanguageCommon();
      final langEn = LanguageEn();
    
      zxcvbn.setOptions(Options(
        dictionary: Dictionary.merge([
          langCommon.dictionary,
          langEn.dictionary,
        ]),
        graphs: langCommon.adjacencyGraphs,
        translations: langCommon.translations,
      ));
    
      // Used to refresh response when locale changes
      String lastPassword = '';
    
      await for (var message in receiverPort) {
        if (message is Locale) {
          zxcvbn.setOptions(Options(
            translations: message.languageCode == 'en'
                ? langEn.translations
                : langCommon.translations,
          ));
        }
    
        lastPassword = message is String ? message : lastPassword;
        if (lastPassword.isNotEmpty) {
          final result = zxcvbn(lastPassword);
    
          sendPort.send(result);
        }
      }
    }
    
  2. Use PasswordScoringBuilder to build your UI

    PasswordScoringBuilder(
      handler: handleScoring,
      loadingPlaceholder: const Center(
        child: CircularProgressIndicator(),
      ),
      builder: (
        BuildContext context,
        Result? data,
        PasswordScoringHelper helper,
      ) {
       return Placeholder();
      },
    );
    
Package Details
dart_zxcvbn README | pub
dart_zxcvbn_language_common README | pub
dart_zxcvbn_language_en README | pub
dart_zxcvbn_language_pl README | pub
flutter_password_scoring README | pub

License #

1
likes
130
pub points
12%
popularity

Publisher

verified publisherinway.dev

Helper library to score password strength with `dart_zxcvbn` and provide suggestions for improvement.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

dart_zxcvbn, flutter

More

Packages that depend on flutter_password_scoring