keyboard uppercasse and max length for licensePlate
This commit is contained in:
parent
9edd350f13
commit
0b38538d2b
|
@ -5,6 +5,15 @@ import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
||||||
import 'package:hub/shared/utils/limited_text_size.dart';
|
import 'package:hub/shared/utils/limited_text_size.dart';
|
||||||
|
|
||||||
|
class UpperCaseTextFormatter extends TextInputFormatter {
|
||||||
|
@override
|
||||||
|
TextEditingValue formatEditUpdate(
|
||||||
|
TextEditingValue oldValue, TextEditingValue newValue) {
|
||||||
|
return TextEditingValue(
|
||||||
|
text: newValue.text.toUpperCase(), selection: newValue.selection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ignore: must_be_immutable
|
// ignore: must_be_immutable
|
||||||
class CustomInputUtil extends StatefulWidget {
|
class CustomInputUtil extends StatefulWidget {
|
||||||
final TextEditingController? controller;
|
final TextEditingController? controller;
|
||||||
|
@ -20,22 +29,25 @@ class CustomInputUtil extends StatefulWidget {
|
||||||
final String? Function(String?)? validator;
|
final String? Function(String?)? validator;
|
||||||
final bool haveMaxLength;
|
final bool haveMaxLength;
|
||||||
final void Function(String)? onChanged;
|
final void Function(String)? onChanged;
|
||||||
|
final List<TextInputFormatter>? inputFormatters;
|
||||||
|
|
||||||
CustomInputUtil(
|
CustomInputUtil({
|
||||||
{super.key,
|
super.key,
|
||||||
this.controller,
|
this.controller,
|
||||||
required this.labelText,
|
required this.labelText,
|
||||||
required this.hintText,
|
required this.hintText,
|
||||||
required this.suffixIcon,
|
required this.suffixIcon,
|
||||||
this.autoFocus = false,
|
this.autoFocus = false,
|
||||||
required this.focusNode,
|
required this.focusNode,
|
||||||
this.onChanged,
|
this.onChanged,
|
||||||
this.textInputAction = TextInputAction.next,
|
this.textInputAction = TextInputAction.next,
|
||||||
this.keyboardType = TextInputType.text,
|
this.keyboardType = TextInputType.text,
|
||||||
this.maxLength = 80,
|
this.maxLength = 80,
|
||||||
this.validator,
|
this.validator,
|
||||||
this.obscureText,
|
this.obscureText,
|
||||||
required this.haveMaxLength});
|
this.inputFormatters,
|
||||||
|
required this.haveMaxLength,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<CustomInputUtil> createState() => _CustomInputUtilState();
|
State<CustomInputUtil> createState() => _CustomInputUtilState();
|
||||||
|
@ -152,6 +164,7 @@ class _CustomInputUtilState extends State<CustomInputUtil> {
|
||||||
keyboardType: widget.keyboardType,
|
keyboardType: widget.keyboardType,
|
||||||
inputFormatters: [
|
inputFormatters: [
|
||||||
LengthLimitingTextInputFormatter(widget.maxLength),
|
LengthLimitingTextInputFormatter(widget.maxLength),
|
||||||
|
if (widget.inputFormatters != null) ...widget.inputFormatters!
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
@ -43,6 +43,8 @@ class _VehicleRegisterScreenState extends State<VehicleRegisterScreen> {
|
||||||
hintText: FFLocalizations.of(context)
|
hintText: FFLocalizations.of(context)
|
||||||
.getVariableText(ptText: 'Placa', enText: 'License Plate'),
|
.getVariableText(ptText: 'Placa', enText: 'License Plate'),
|
||||||
suffixIcon: Symbols.format_color_text,
|
suffixIcon: Symbols.format_color_text,
|
||||||
|
inputFormatters: [UpperCaseTextFormatter()],
|
||||||
|
maxLength: 7,
|
||||||
),
|
),
|
||||||
_buildCustomInput(
|
_buildCustomInput(
|
||||||
context: context,
|
context: context,
|
||||||
|
@ -54,6 +56,7 @@ class _VehicleRegisterScreenState extends State<VehicleRegisterScreen> {
|
||||||
hintText: FFLocalizations.of(context).getVariableText(
|
hintText: FFLocalizations.of(context).getVariableText(
|
||||||
ptText: 'Ex: Voyage, Ford', enText: 'e.g. Voyage, Ford'),
|
ptText: 'Ex: Voyage, Ford', enText: 'e.g. Voyage, Ford'),
|
||||||
suffixIcon: Symbols.car_repair,
|
suffixIcon: Symbols.car_repair,
|
||||||
|
inputFormatters: [],
|
||||||
),
|
),
|
||||||
_buildCustomInput(
|
_buildCustomInput(
|
||||||
context: context,
|
context: context,
|
||||||
|
@ -66,6 +69,7 @@ class _VehicleRegisterScreenState extends State<VehicleRegisterScreen> {
|
||||||
ptText: 'Ex: Preto, Amarelo, Branco',
|
ptText: 'Ex: Preto, Amarelo, Branco',
|
||||||
enText: 'e.g. Black, Yellow, White'),
|
enText: 'e.g. Black, Yellow, White'),
|
||||||
suffixIcon: Symbols.palette,
|
suffixIcon: Symbols.palette,
|
||||||
|
inputFormatters: [],
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.fromLTRB(70, 20, 70, 30),
|
padding: const EdgeInsets.fromLTRB(70, 20, 70, 30),
|
||||||
|
@ -91,6 +95,8 @@ class _VehicleRegisterScreenState extends State<VehicleRegisterScreen> {
|
||||||
required String labelText,
|
required String labelText,
|
||||||
required String hintText,
|
required String hintText,
|
||||||
required IconData suffixIcon,
|
required IconData suffixIcon,
|
||||||
|
required final List<TextInputFormatter>? inputFormatters,
|
||||||
|
int maxLength = 80,
|
||||||
}) {
|
}) {
|
||||||
return CustomInputUtil(
|
return CustomInputUtil(
|
||||||
controller: controller,
|
controller: controller,
|
||||||
|
@ -101,7 +107,8 @@ class _VehicleRegisterScreenState extends State<VehicleRegisterScreen> {
|
||||||
suffixIcon: suffixIcon,
|
suffixIcon: suffixIcon,
|
||||||
haveMaxLength: true,
|
haveMaxLength: true,
|
||||||
onChanged: (value) => setState(() {}),
|
onChanged: (value) => setState(() {}),
|
||||||
maxLength: 80,
|
inputFormatters: inputFormatters,
|
||||||
|
maxLength: maxLength,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,8 @@ class _VehicleUpdateScreenState extends State<VehicleUpdateScreen> {
|
||||||
hintText: FFLocalizations.of(context)
|
hintText: FFLocalizations.of(context)
|
||||||
.getVariableText(ptText: 'Placa', enText: 'License Plate'),
|
.getVariableText(ptText: 'Placa', enText: 'License Plate'),
|
||||||
suffixIcon: Symbols.format_color_text,
|
suffixIcon: Symbols.format_color_text,
|
||||||
|
inputFormatters: [UpperCaseTextFormatter()],
|
||||||
|
maxLength: 7,
|
||||||
),
|
),
|
||||||
_buildCustomInput(
|
_buildCustomInput(
|
||||||
context: context,
|
context: context,
|
||||||
|
@ -54,6 +56,7 @@ class _VehicleUpdateScreenState extends State<VehicleUpdateScreen> {
|
||||||
hintText: FFLocalizations.of(context).getVariableText(
|
hintText: FFLocalizations.of(context).getVariableText(
|
||||||
ptText: 'Ex: Voyage, Ford', enText: 'e.g. Voyage, Ford'),
|
ptText: 'Ex: Voyage, Ford', enText: 'e.g. Voyage, Ford'),
|
||||||
suffixIcon: Symbols.car_repair,
|
suffixIcon: Symbols.car_repair,
|
||||||
|
inputFormatters: [],
|
||||||
),
|
),
|
||||||
_buildCustomInput(
|
_buildCustomInput(
|
||||||
context: context,
|
context: context,
|
||||||
|
@ -66,6 +69,7 @@ class _VehicleUpdateScreenState extends State<VehicleUpdateScreen> {
|
||||||
ptText: 'Ex: Preto, Amarelo, Branco',
|
ptText: 'Ex: Preto, Amarelo, Branco',
|
||||||
enText: 'e.g. Black, Yellow, White'),
|
enText: 'e.g. Black, Yellow, White'),
|
||||||
suffixIcon: Symbols.palette,
|
suffixIcon: Symbols.palette,
|
||||||
|
inputFormatters: [],
|
||||||
),
|
),
|
||||||
_buildSubmitButton(context),
|
_buildSubmitButton(context),
|
||||||
],
|
],
|
||||||
|
@ -104,6 +108,8 @@ class _VehicleUpdateScreenState extends State<VehicleUpdateScreen> {
|
||||||
required String labelText,
|
required String labelText,
|
||||||
required String hintText,
|
required String hintText,
|
||||||
required IconData suffixIcon,
|
required IconData suffixIcon,
|
||||||
|
required List<TextInputFormatter>? inputFormatters,
|
||||||
|
int maxLength = 80,
|
||||||
}) {
|
}) {
|
||||||
return CustomInputUtil(
|
return CustomInputUtil(
|
||||||
controller: controller,
|
controller: controller,
|
||||||
|
@ -114,6 +120,8 @@ class _VehicleUpdateScreenState extends State<VehicleUpdateScreen> {
|
||||||
suffixIcon: suffixIcon,
|
suffixIcon: suffixIcon,
|
||||||
haveMaxLength: true,
|
haveMaxLength: true,
|
||||||
onChanged: (value) => setState(() {}),
|
onChanged: (value) => setState(() {}),
|
||||||
|
inputFormatters: inputFormatters,
|
||||||
|
maxLength: maxLength,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ import 'dart:developer';
|
||||||
|
|
||||||
import 'package:auto_size_text/auto_size_text.dart';
|
import 'package:auto_size_text/auto_size_text.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'package:hub/components/atomic_components/shared_components_atoms/custom_input.dart';
|
import 'package:hub/components/atomic_components/shared_components_atoms/custom_input.dart';
|
||||||
import 'package:hub/components/atomic_components/shared_components_atoms/submit_button.dart';
|
import 'package:hub/components/atomic_components/shared_components_atoms/submit_button.dart';
|
||||||
|
|
Loading…
Reference in New Issue