mirror of
https://github.com/Iconica-Development/flutter_form_wizard.git
synced 2025-05-19 19:03:47 +02:00
Multi line input now uses the standard plain text input
This commit is contained in:
parent
c00dba357e
commit
c9034a723b
1 changed files with 33 additions and 59 deletions
|
@ -12,8 +12,19 @@ class FlutterFormInputPlainText extends FlutterFormInputWidget {
|
|||
Key? key,
|
||||
required FlutterFormInputController controller,
|
||||
Widget? label,
|
||||
this.decoration,
|
||||
this.textAlignVertical,
|
||||
this.expands = false,
|
||||
this.maxLines,
|
||||
this.maxLength,
|
||||
}) : super(key: key, controller: controller, label: label);
|
||||
|
||||
final InputDecoration? decoration;
|
||||
final TextAlignVertical? textAlignVertical;
|
||||
final bool expands;
|
||||
final int? maxLines;
|
||||
final int? maxLength;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
String Function(String, {List<String>? params}) _ =
|
||||
|
@ -21,54 +32,20 @@ class FlutterFormInputPlainText extends FlutterFormInputWidget {
|
|||
|
||||
super.registerController(context);
|
||||
|
||||
return TextFormField(
|
||||
initialValue: controller.value,
|
||||
onSaved: (value) => controller.onSaved(value),
|
||||
validator: (value) => controller.onValidate(value, _),
|
||||
decoration: InputDecoration(
|
||||
label: label ?? const Text("Plain text"),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Input for a plain text with extra styling used in a [FlutterForm].
|
||||
///
|
||||
/// Standard controller is [FlutterFormInputPlainTextController].
|
||||
class FlutterFormInputPlainTextWhiteWithBorder extends FlutterFormInputWidget {
|
||||
const FlutterFormInputPlainTextWhiteWithBorder({
|
||||
Key? key,
|
||||
required FlutterFormInputController controller,
|
||||
Widget? label,
|
||||
this.hint,
|
||||
}) : super(key: key, controller: controller, label: label);
|
||||
|
||||
final String? hint;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
String Function(String, {List<String>? params}) _ =
|
||||
getTranslator(context, ref);
|
||||
|
||||
super.registerController(context);
|
||||
InputDecoration inputDecoration = decoration ??
|
||||
InputDecoration(
|
||||
label: label ?? const Text("Plain text"),
|
||||
);
|
||||
|
||||
return TextFormField(
|
||||
initialValue: controller.value,
|
||||
onSaved: (value) => controller.onSaved(value),
|
||||
validator: (value) => controller.onValidate(value, _),
|
||||
decoration: InputDecoration(
|
||||
hintText: hint,
|
||||
floatingLabelBehavior: FloatingLabelBehavior.never,
|
||||
isDense: true,
|
||||
border: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Color(0xFF979797)),
|
||||
),
|
||||
focusedBorder: const OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Color(0xFF979797)),
|
||||
),
|
||||
fillColor: Colors.white,
|
||||
filled: true,
|
||||
),
|
||||
decoration: inputDecoration,
|
||||
textAlignVertical: textAlignVertical,
|
||||
expands: expands,
|
||||
maxLines: maxLines,
|
||||
maxLength: maxLength,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -76,40 +53,37 @@ class FlutterFormInputPlainTextWhiteWithBorder extends FlutterFormInputWidget {
|
|||
/// Input for a multi line plain text field [FlutterForm].
|
||||
///
|
||||
/// Standard controller is [FlutterFormInputPlainTextController].
|
||||
///
|
||||
///
|
||||
/// Hint can be set to set a hint inside the field.
|
||||
///
|
||||
///
|
||||
/// MaxCharacters can be set to set a maximum amount of characters.
|
||||
class FlutterFormInputMultiLine extends FlutterFormInputWidget {
|
||||
class FlutterFormInputMultiLine extends StatelessWidget {
|
||||
const FlutterFormInputMultiLine({
|
||||
Key? key,
|
||||
required FlutterFormInputController controller,
|
||||
Widget? label,
|
||||
required this.controller,
|
||||
this.label,
|
||||
this.hint,
|
||||
this.maxCharacters,
|
||||
}) : super(key: key, controller: controller, label: label);
|
||||
}) : super(key: key);
|
||||
|
||||
final FlutterFormInputController controller;
|
||||
final Widget? label;
|
||||
|
||||
final String? hint;
|
||||
final int? maxCharacters;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
String Function(String, {List<String>? params}) _ =
|
||||
getTranslator(context, ref);
|
||||
|
||||
super.registerController(context);
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextFormField(
|
||||
child: FlutterFormInputPlainText(
|
||||
label: label,
|
||||
controller: controller,
|
||||
textAlignVertical: TextAlignVertical.top,
|
||||
expands: true,
|
||||
maxLines: null,
|
||||
maxLength: maxCharacters,
|
||||
initialValue: controller.value,
|
||||
onSaved: (value) => controller.onSaved(value),
|
||||
validator: (value) => controller.onValidate(value, _),
|
||||
decoration: InputDecoration(
|
||||
hintText: hint,
|
||||
floatingLabelBehavior: FloatingLabelBehavior.never,
|
||||
|
|
Loading…
Reference in a new issue