ajustes de inputs com apenas numeros, mascaras, textos

This commit is contained in:
Reginaldo
2024-02-09 16:14:44 -03:00
parent a94bff8ebd
commit 8cf5569840
10 changed files with 176 additions and 79 deletions

View File

@@ -9,31 +9,36 @@ class CheckBoxSubtitle extends StatelessWidget {
bool checkbox;
var onChanged;
double fontSize;
var ontap;
CheckBoxSubtitle({
this.width = double.infinity,
required this.checkbox,
required this.subtitle,
required this.onChanged,
this.fontSize = 14
this.fontSize = 14,
this.ontap = null
});
@override
Widget build(BuildContext context) {
return Container(
width: width,
child: Row(
children: [
Checkbox(
value: checkbox,
onChanged: onChanged
),
Container(
width: width,
child: TextDefault(text: subtitle,fontSize: fontSize,color: ColorPalette.black54,)
),
],
return GestureDetector(
onTap: ontap,
child: Container(
width: width,
child: Row(
children: [
Checkbox(
value: checkbox,
onChanged: onChanged
),
Container(
width: width,
child: TextDefault(text: subtitle,fontSize: fontSize,color: ColorPalette.black54,maxLines: 2,)
),
],
),
),
);
}

View File

@@ -11,6 +11,8 @@ class CheckBoxTwoSubtitle extends StatelessWidget {
bool checkbox2;
var onChanged1;
var onChanged2;
var ontap1;
var ontap2;
CheckBoxTwoSubtitle({
this.width = double.infinity,
@@ -20,6 +22,8 @@ class CheckBoxTwoSubtitle extends StatelessWidget {
required this.subtitle2,
required this.onChanged1,
required this.onChanged2,
this.ontap1 = null,
this.ontap2 = null,
});
@override
@@ -33,18 +37,24 @@ class CheckBoxTwoSubtitle extends StatelessWidget {
value: checkbox1,
onChanged: onChanged1
),
Container(
width: width/2.5,
child: TextDefault(text: subtitle1,fontSize: 14,color: ColorPalette.black54,)
GestureDetector(
onTap: ontap1,
child: Container(
width: width/2.5,
child: TextDefault(text: subtitle1,fontSize: 14,color: ColorPalette.black54,)
),
),
Spacer(),
Checkbox(
value: checkbox2,
onChanged: onChanged2
),
Container(
width: width/3,
child: TextDefault(text: subtitle2,fontSize: 14,color: ColorPalette.black54)
GestureDetector(
onTap: ontap2,
child: Container(
width: width/3,
child: TextDefault(text: subtitle2,fontSize: 14,color: ColorPalette.black54)
),
),
],
),

View File

@@ -15,6 +15,8 @@ class InputText extends StatelessWidget {
int maxLines;
Color colorBorder;
var onChanged;
int maxLength;
List<TextInputFormatter> inputFormatters;
InputText({
required this.controller,
@@ -27,7 +29,9 @@ class InputText extends StatelessWidget {
this.maxLines = 1,
this.colorBorder = ColorPalette.black54,
this.onChanged = null,
});
this.maxLength = 200,
List<TextInputFormatter>? inputFormatters, // Alteração aqui
}) : inputFormatters = inputFormatters ?? [FormatText()];
@override
Widget build(BuildContext context) {
@@ -39,9 +43,8 @@ class InputText extends StatelessWidget {
keyboardType: textInputType,
maxLines: maxLines,
onChanged: onChanged,
inputFormatters: [
FormatText()
],
maxLength: maxLength,
inputFormatters: inputFormatters,
obscureText: this.obscure,
controller: this.controller,
style: TextStyle(

View File

@@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:rkm/widgets/title_input.dart';
import '../config/color_palette.dart';
import '../controllers/format_txt.dart';
import 'error_default.dart';
import 'input_text.dart';
@@ -20,6 +22,8 @@ class InputWithSubtitle extends StatelessWidget {
int maxLines;
Color colorBorder;
String typeInput;
int maxLength;
List<TextInputFormatter> inputFormatters;
InputWithSubtitle({
required this.subtitle,
@@ -36,8 +40,10 @@ class InputWithSubtitle extends StatelessWidget {
this.maxLines = 1,
this.colorBorder = ColorPalette.white,
required this.onChanged,
this.widthError = 0.7
});
this.widthError = 0.7,
this.maxLength = 200,
List<TextInputFormatter>? inputFormatters, // Alteração aqui
}) : inputFormatters = inputFormatters ?? [FormatText()];
@override
Widget build(BuildContext context) {
@@ -57,6 +63,8 @@ class InputWithSubtitle extends StatelessWidget {
maxLines:maxLines,
colorBorder: colorBorder,
onChanged: onChanged,
maxLength: maxLength,
inputFormatters: inputFormatters,
),
typeInput=='normal'&&(enabled&&mandatory) && (labelInput=='Nome' && splited.length<=1) ?ErrorDefault(widthDefault: widthError,error: errorInput,):Container(),
typeInput!='normal'&&(enabled&&mandatory)&& errorInput!=''?ErrorDefault(widthDefault: widthError,error: errorInput,):Container(),