mirror of
https://github.com/Iconica-Development/flutter_input_library.git
synced 2025-05-18 17:03:45 +02:00
Added the ability to set the enabled of textfields
This commit is contained in:
parent
2f0ceff64e
commit
cfc051531a
3 changed files with 42 additions and 26 deletions
|
@ -29,6 +29,7 @@ class DateTimeInputField extends StatefulWidget {
|
||||||
this.validator,
|
this.validator,
|
||||||
required this.timePickerEntryMode,
|
required this.timePickerEntryMode,
|
||||||
required this.style,
|
required this.style,
|
||||||
|
this.enabled = true,
|
||||||
}) : super(
|
}) : super(
|
||||||
key: key,
|
key: key,
|
||||||
);
|
);
|
||||||
|
@ -50,6 +51,7 @@ class DateTimeInputField extends StatefulWidget {
|
||||||
final void Function(String?)? onSaved;
|
final void Function(String?)? onSaved;
|
||||||
final void Function(String?)? onChanged;
|
final void Function(String?)? onChanged;
|
||||||
final TimePickerEntryMode timePickerEntryMode;
|
final TimePickerEntryMode timePickerEntryMode;
|
||||||
|
final bool enabled;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<DateTimeInputField> createState() => _DateInputFieldState();
|
State<DateTimeInputField> createState() => _DateInputFieldState();
|
||||||
|
@ -128,6 +130,7 @@ class _DateInputFieldState extends State<DateTimeInputField> {
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case FlutterFormDateTimeType.range:
|
case FlutterFormDateTimeType.range:
|
||||||
|
if (context.mounted) {
|
||||||
userInput = (await showDateRangePicker(
|
userInput = (await showDateRangePicker(
|
||||||
context: context,
|
context: context,
|
||||||
firstDate: firstDate,
|
firstDate: firstDate,
|
||||||
|
@ -139,8 +142,10 @@ class _DateInputFieldState extends State<DateTimeInputField> {
|
||||||
: '';
|
: '';
|
||||||
}))
|
}))
|
||||||
.toString();
|
.toString();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case FlutterFormDateTimeType.time:
|
case FlutterFormDateTimeType.time:
|
||||||
|
if (context.mounted) {
|
||||||
userInput = await showTimePicker(
|
userInput = await showTimePicker(
|
||||||
initialEntryMode: widget.timePickerEntryMode,
|
initialEntryMode: widget.timePickerEntryMode,
|
||||||
builder: (BuildContext context, Widget? child) {
|
builder: (BuildContext context, Widget? child) {
|
||||||
|
@ -157,6 +162,7 @@ class _DateInputFieldState extends State<DateTimeInputField> {
|
||||||
: MaterialLocalizations.of(context)
|
: MaterialLocalizations.of(context)
|
||||||
.formatTimeOfDay(value, alwaysUse24HourFormat: true));
|
.formatTimeOfDay(value, alwaysUse24HourFormat: true));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return userInput;
|
return userInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,6 +191,7 @@ class _DateInputFieldState extends State<DateTimeInputField> {
|
||||||
focusColor: Theme.of(context).primaryColor,
|
focusColor: Theme.of(context).primaryColor,
|
||||||
label: widget.label ?? const Text("Date"),
|
label: widget.label ?? const Text("Date"),
|
||||||
),
|
),
|
||||||
|
enabled: widget.enabled,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ class FlutterFormInputPassword extends StatefulWidget {
|
||||||
final String? Function(String?)? validator;
|
final String? Function(String?)? validator;
|
||||||
final Function(String?)? onChanged;
|
final Function(String?)? onChanged;
|
||||||
final Function(String?)? onFieldSubmitted;
|
final Function(String?)? onFieldSubmitted;
|
||||||
|
final bool enabled;
|
||||||
|
|
||||||
const FlutterFormInputPassword({
|
const FlutterFormInputPassword({
|
||||||
Key? key,
|
Key? key,
|
||||||
|
@ -24,6 +25,7 @@ class FlutterFormInputPassword extends StatefulWidget {
|
||||||
this.validator,
|
this.validator,
|
||||||
this.onChanged,
|
this.onChanged,
|
||||||
this.onFieldSubmitted,
|
this.onFieldSubmitted,
|
||||||
|
this.enabled = true,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -54,6 +56,7 @@ class _PasswordTextFieldState extends State<FlutterFormInputPassword> {
|
||||||
icon: Icon(obscured ? Icons.visibility_off : Icons.visibility),
|
icon: Icon(obscured ? Icons.visibility_off : Icons.visibility),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
enabled: widget.enabled,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ class FlutterFormInputPlainText extends StatelessWidget {
|
||||||
this.validator,
|
this.validator,
|
||||||
this.onFieldSubmitted,
|
this.onFieldSubmitted,
|
||||||
this.style,
|
this.style,
|
||||||
|
this.enabled = true,
|
||||||
}) : super(
|
}) : super(
|
||||||
key: key,
|
key: key,
|
||||||
);
|
);
|
||||||
|
@ -41,6 +42,7 @@ class FlutterFormInputPlainText extends StatelessWidget {
|
||||||
final Function(String?)? onChanged;
|
final Function(String?)? onChanged;
|
||||||
final Function(String?)? onFieldSubmitted;
|
final Function(String?)? onFieldSubmitted;
|
||||||
final TextStyle? style;
|
final TextStyle? style;
|
||||||
|
final bool enabled;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -64,6 +66,7 @@ class FlutterFormInputPlainText extends StatelessWidget {
|
||||||
maxLines: maxLines,
|
maxLines: maxLines,
|
||||||
maxLength: maxLength,
|
maxLength: maxLength,
|
||||||
keyboardType: keyboardType,
|
keyboardType: keyboardType,
|
||||||
|
enabled: enabled,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,6 +78,7 @@ class FlutterFormInputMultiLine extends StatelessWidget {
|
||||||
this.focusNode,
|
this.focusNode,
|
||||||
this.hint,
|
this.hint,
|
||||||
this.maxCharacters,
|
this.maxCharacters,
|
||||||
|
this.enabled = true,
|
||||||
this.scrollPadding,
|
this.scrollPadding,
|
||||||
this.keyboardType,
|
this.keyboardType,
|
||||||
this.initialValue,
|
this.initialValue,
|
||||||
|
@ -89,6 +93,7 @@ class FlutterFormInputMultiLine extends StatelessWidget {
|
||||||
final FocusNode? focusNode;
|
final FocusNode? focusNode;
|
||||||
final String? hint;
|
final String? hint;
|
||||||
final int? maxCharacters;
|
final int? maxCharacters;
|
||||||
|
final bool enabled;
|
||||||
|
|
||||||
final InputDecoration? decoration;
|
final InputDecoration? decoration;
|
||||||
final EdgeInsets? scrollPadding;
|
final EdgeInsets? scrollPadding;
|
||||||
|
@ -131,6 +136,7 @@ class FlutterFormInputMultiLine extends StatelessWidget {
|
||||||
),
|
),
|
||||||
filled: true,
|
filled: true,
|
||||||
),
|
),
|
||||||
|
enabled: enabled,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in a new issue