voice_formly 0.0.1
voice_formly: ^0.0.1 copied to clipboard
A dart package for building form fields with speech-to-text and built-in validation.
voice_formly #
voice_formly is a customizable Flutter form field widget that adds built-in validation and speech-to-text input support. It simplifies voice-powered form handling and allows users to build accessible and modern form experiences faster.
โจ Features #
- ๐ค Voice input (speech-to-text) for supported fields (text, email, phone, multiline, etc.)
- ๐ก๏ธ Built-in smart validation for common fields (email, number, phone)
- ๐ง Custom validation support
- ๐งพ Multiple field types: text, email, password, phone, date, multiline, number
- ๐จ Easily configurable with styling, hints, borders, icons
- ๐ Integrated date picker for date fields
๐ธ Screenshots #
| Validation Error | Voice Input in Action |
|---|---|
| [assets/form_validation.jpg] | [assets/demo.gif] |
๐ Getting started #
Add the package to your pubspec.yaml:
dependencies:
voice_formly: ^0.0.1
Import it in your Dart file:
import 'package:voice_formly/voice_formly.dart';
๐ก Usage Example #
VoiceFormField(
controller: myController,
fieldId: 'email',
label: 'Email Address',
fieldType: FormFieldType.email,
enableVoice: true,
validator: (value) {
if (value == null || value.isEmpty) return 'Enter your email';
return null;
},
onMicTap: (fieldId) {
print("Mic tapped on field: $fieldId");
},
)
๐งพ VoiceFormField Parameters #
| Parameter | Type | Description |
|---|---|---|
fieldId |
String |
Unique identifier for the field (used with callbacks). |
onMicTap |
Function(String fieldId)? |
Callback function when the mic icon is tapped. |
controller |
TextEditingController |
Controller for managing the text input. |
hint |
String? |
Placeholder or hint shown inside the field. |
height |
int? |
Custom height of the field in logical pixels. |
width |
int? |
Custom width of the field in logical pixels. |
fontSize |
int |
Font size of the input text. |
maxLines |
int? |
Maximum number of lines (useful for multiline fields). |
minLines |
int? |
Minimum number of lines. |
errorMaxLines |
int? |
Maximum number of lines for the error message. |
keyboardType |
TextInputType? |
Keyboard input type (text, email, number, etc.). |
borderColor |
Color |
Border color when the field is focused. |
label |
String? |
Label shown above the field. |
enableVoice |
bool |
Whether to enable voice input functionality. |
suffixIconButton |
IconButton? |
Custom suffix icon at the end of the field. |
autofocus |
bool? |
Whether to autofocus the field on load. |
autocorrect |
bool? |
Whether to enable autocorrect for the input. |
textInputAction |
TextInputAction? |
The action button on the keyboard (e.g., done, next). |
autoValidateMode |
AutovalidateMode? |
Controls when to auto-validate the field (e.g., always, onUserInteraction). |
padding |
EdgeInsets? |
Custom padding inside the form field. |
validator |
String? Function(String?)? |
Custom validation logic. |
fieldType |
FormFieldType |
Determines behavior (e.g., text, email, password, date). |
enabledBorder |
InputBorder? |
Border style when field is enabled. |
border |
InputBorder? |
Default border style. |
focusedErrorBorder |
InputBorder? |
Border style when field has focus and an error. |
focusedBorder |
InputBorder? |
Border style when field is focused. |
errorBorder |
InputBorder? |
Border style when validation fails. |
disabledBorder |
InputBorder? |
Border style when the field is disabled. |
๐ License #
This project is licensed under the MIT License โ see the LICENSE file for details.