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,
|
Key? key,
|
||||||
required FlutterFormInputController controller,
|
required FlutterFormInputController controller,
|
||||||
Widget? label,
|
Widget? label,
|
||||||
|
this.decoration,
|
||||||
|
this.textAlignVertical,
|
||||||
|
this.expands = false,
|
||||||
|
this.maxLines,
|
||||||
|
this.maxLength,
|
||||||
}) : super(key: key, controller: controller, label: label);
|
}) : super(key: key, controller: controller, label: label);
|
||||||
|
|
||||||
|
final InputDecoration? decoration;
|
||||||
|
final TextAlignVertical? textAlignVertical;
|
||||||
|
final bool expands;
|
||||||
|
final int? maxLines;
|
||||||
|
final int? maxLength;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
String Function(String, {List<String>? params}) _ =
|
String Function(String, {List<String>? params}) _ =
|
||||||
|
@ -21,54 +32,20 @@ class FlutterFormInputPlainText extends FlutterFormInputWidget {
|
||||||
|
|
||||||
super.registerController(context);
|
super.registerController(context);
|
||||||
|
|
||||||
return TextFormField(
|
InputDecoration inputDecoration = decoration ??
|
||||||
initialValue: controller.value,
|
InputDecoration(
|
||||||
onSaved: (value) => controller.onSaved(value),
|
label: label ?? const Text("Plain text"),
|
||||||
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);
|
|
||||||
|
|
||||||
return TextFormField(
|
return TextFormField(
|
||||||
initialValue: controller.value,
|
initialValue: controller.value,
|
||||||
onSaved: (value) => controller.onSaved(value),
|
onSaved: (value) => controller.onSaved(value),
|
||||||
validator: (value) => controller.onValidate(value, _),
|
validator: (value) => controller.onValidate(value, _),
|
||||||
decoration: InputDecoration(
|
decoration: inputDecoration,
|
||||||
hintText: hint,
|
textAlignVertical: textAlignVertical,
|
||||||
floatingLabelBehavior: FloatingLabelBehavior.never,
|
expands: expands,
|
||||||
isDense: true,
|
maxLines: maxLines,
|
||||||
border: const OutlineInputBorder(
|
maxLength: maxLength,
|
||||||
borderSide: BorderSide(color: Color(0xFF979797)),
|
|
||||||
),
|
|
||||||
focusedBorder: const OutlineInputBorder(
|
|
||||||
borderSide: BorderSide(color: Color(0xFF979797)),
|
|
||||||
),
|
|
||||||
fillColor: Colors.white,
|
|
||||||
filled: true,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,40 +53,37 @@ class FlutterFormInputPlainTextWhiteWithBorder extends FlutterFormInputWidget {
|
||||||
/// Input for a multi line plain text field [FlutterForm].
|
/// Input for a multi line plain text field [FlutterForm].
|
||||||
///
|
///
|
||||||
/// Standard controller is [FlutterFormInputPlainTextController].
|
/// Standard controller is [FlutterFormInputPlainTextController].
|
||||||
///
|
///
|
||||||
/// Hint can be set to set a hint inside the field.
|
/// Hint can be set to set a hint inside the field.
|
||||||
///
|
///
|
||||||
/// MaxCharacters can be set to set a maximum amount of characters.
|
/// MaxCharacters can be set to set a maximum amount of characters.
|
||||||
class FlutterFormInputMultiLine extends FlutterFormInputWidget {
|
class FlutterFormInputMultiLine extends StatelessWidget {
|
||||||
const FlutterFormInputMultiLine({
|
const FlutterFormInputMultiLine({
|
||||||
Key? key,
|
Key? key,
|
||||||
required FlutterFormInputController controller,
|
required this.controller,
|
||||||
Widget? label,
|
this.label,
|
||||||
this.hint,
|
this.hint,
|
||||||
this.maxCharacters,
|
this.maxCharacters,
|
||||||
}) : super(key: key, controller: controller, label: label);
|
}) : super(key: key);
|
||||||
|
|
||||||
|
final FlutterFormInputController controller;
|
||||||
|
final Widget? label;
|
||||||
|
|
||||||
final String? hint;
|
final String? hint;
|
||||||
final int? maxCharacters;
|
final int? maxCharacters;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context) {
|
||||||
String Function(String, {List<String>? params}) _ =
|
|
||||||
getTranslator(context, ref);
|
|
||||||
|
|
||||||
super.registerController(context);
|
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextFormField(
|
child: FlutterFormInputPlainText(
|
||||||
|
label: label,
|
||||||
|
controller: controller,
|
||||||
textAlignVertical: TextAlignVertical.top,
|
textAlignVertical: TextAlignVertical.top,
|
||||||
expands: true,
|
expands: true,
|
||||||
maxLines: null,
|
maxLines: null,
|
||||||
maxLength: maxCharacters,
|
maxLength: maxCharacters,
|
||||||
initialValue: controller.value,
|
|
||||||
onSaved: (value) => controller.onSaved(value),
|
|
||||||
validator: (value) => controller.onValidate(value, _),
|
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: hint,
|
hintText: hint,
|
||||||
floatingLabelBehavior: FloatingLabelBehavior.never,
|
floatingLabelBehavior: FloatingLabelBehavior.never,
|
||||||
|
|
Loading…
Reference in a new issue