PasswordFormBox constructor

PasswordFormBox({
  1. Key? key,
  2. AutovalidateMode? autovalidateMode,
  3. bool enabled = true,
  4. String? initialValue,
  5. FormFieldSetter<String>? onSaved,
  6. String? restorationId,
  7. FormFieldValidator<String>? validator,
  8. PasswordRevealMode revealMode = PasswordRevealMode.peek,
  9. FocusNode? focusNode,
  10. bool autofocus = false,
  11. bool readOnly = false,
  12. bool? showCursor,
  13. String obscuringCharacter = '•',
  14. TextEditingController? controller,
  15. double cursorWidth = 2.0,
  16. double? cursorHeight,
  17. Radius cursorRadius = const Radius.circular(2.0),
  18. Color? cursorColor,
  19. VoidCallback? onEditingComplete,
  20. ValueChanged<String>? onFieldSubmitted,
  21. Color? highlightColor,
  22. Color? errorHighlightColor,
  23. String? placeholder,
  24. TextStyle? placeholderStyle,
  25. Widget? leadingIcon,
})

Creates a FormField that contains a PasswordBox.

When a controller is specified, initialValue must be null (the default). If controller is null, then a TextEditingController will be constructed automatically and its text will be initialized to initialValue or the empty string.

For documentation about the various parameters, see the PasswordBox class and PasswordBox.new, the constructor.

Implementation

PasswordFormBox({
  super.key,
  super.autovalidateMode,
  super.enabled,
  super.initialValue,
  super.onSaved,
  super.restorationId,
  super.validator,
  PasswordRevealMode revealMode = PasswordRevealMode.peek,
  FocusNode? focusNode,
  bool autofocus = false,
  bool readOnly = false,
  bool? showCursor,
  String obscuringCharacter = '•',
  super.controller,
  double cursorWidth = 2.0,
  double? cursorHeight,
  Radius cursorRadius = const Radius.circular(2.0),
  Color? cursorColor,
  VoidCallback? onEditingComplete,
  ValueChanged<String>? onFieldSubmitted,
  Color? highlightColor,
  Color? errorHighlightColor,
  String? placeholder,
  TextStyle? placeholderStyle,
  Widget? leadingIcon,
}) : super(builder: (FormFieldState<String> field) {
        assert(debugCheckHasFluentTheme(field.context));
        final theme = FluentTheme.of(field.context);
        void onChangedHandler(String value) {
          field.didChange(value);
        }

        return UnmanagedRestorationScope(
          bucket: field.bucket,
          child: FormRow(
            padding: EdgeInsets.zero,
            error: (field.errorText == null) ? null : Text(field.errorText!),
            child: PasswordBox(
              revealMode: revealMode,
              focusNode: focusNode,
              autofocus: autofocus,
              readOnly: readOnly,
              showCursor: showCursor,
              obscuringCharacter: obscuringCharacter,
              controller: controller,
              cursorColor: cursorColor,
              cursorHeight: cursorHeight,
              cursorRadius: cursorRadius,
              cursorWidth: cursorWidth,
              enabled: enabled,
              onEditingComplete: onEditingComplete,
              onSubmitted: onFieldSubmitted,
              onChanged: onChangedHandler,
              highlightColor: (field.errorText == null)
                  ? highlightColor
                  : errorHighlightColor ??
                      Colors.red.defaultBrushFor(theme.brightness),
              placeholder: placeholder,
              placeholderStyle: placeholderStyle,
              leadingIcon: leadingIcon,
            ),
          ),
        );
      });