app_textfield_n.dart 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // ignore_for_file: must_be_immutable
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter/services.dart';
  4. import '../themes/themes.dart';
  5. class Campo extends StatelessWidget {
  6. final Icon? prefixIcon;
  7. final Widget? suffixIcon;
  8. final String? labelText;
  9. final String? initialValue;
  10. final String? hintText;
  11. final TextInputType? keyboardType;
  12. final TextEditingController? controller;
  13. final Color? fillColor;
  14. final void Function()? onTap;
  15. final bool enabled;
  16. final bool obscureText;
  17. final bool readOnly;
  18. final int? maxLength;
  19. final int? maxLines;
  20. final String? errorText;
  21. final double? textfieldHeight;
  22. final List<String>? autofillHints;
  23. final Function(String v)? onChanged;
  24. List<TextInputFormatter>? inputFormatters;
  25. final TextCapitalization textCapitalization;
  26. String? etiqueta;
  27. String? Function(String?)? validator;
  28. final double? vertical;
  29. Campo(
  30. {super.key,
  31. this.etiqueta,
  32. this.labelText,
  33. this.prefixIcon,
  34. this.keyboardType,
  35. this.onTap,
  36. this.controller,
  37. this.hintText,
  38. this.suffixIcon,
  39. this.inputFormatters,
  40. this.enabled = true,
  41. this.readOnly = false,
  42. this.obscureText = false,
  43. this.fillColor = Colors.white,
  44. this.errorText,
  45. this.textfieldHeight,
  46. this.autofillHints,
  47. this.textCapitalization = TextCapitalization.none,
  48. this.initialValue,
  49. this.maxLength,
  50. this.maxLines = 1,
  51. this.validator,
  52. this.onChanged,
  53. this.vertical});
  54. @override
  55. Widget build(BuildContext context) {
  56. etiqueta ??= "";
  57. return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
  58. if (etiqueta != '')
  59. Text(
  60. etiqueta.toString(),
  61. style: TextStyle(
  62. fontSize: 18,
  63. fontWeight: FontWeight.bold,
  64. color: enabled ? Colors.black : Colors.grey),
  65. ),
  66. if (etiqueta != '')
  67. const SizedBox(
  68. height: 5,
  69. ),
  70. TextFormField(
  71. autofillHints: autofillHints,
  72. validator: validator,
  73. enabled: enabled,
  74. maxLength: maxLength,
  75. maxLines: maxLines,
  76. inputFormatters: inputFormatters,
  77. initialValue: initialValue,
  78. controller: controller,
  79. onTap: onTap,
  80. readOnly: readOnly,
  81. //keyboardType: keyboardType,
  82. textCapitalization: textCapitalization,
  83. cursorColor: AppTheme.tertiary,
  84. obscureText: obscureText,
  85. autocorrect: true,
  86. onChanged: onChanged,
  87. style: const TextStyle(
  88. height: 0,
  89. fontSize: 40.0,
  90. color: Colors.white,
  91. fontFamily: 'digital-7-mono', // Nombre de la fuente
  92. ),
  93. textAlign: TextAlign.center,
  94. keyboardType: TextInputType.number,
  95. decoration: InputDecoration(
  96. filled: true,
  97. fillColor: Colors.grey.shade800,
  98. hintText: '00',
  99. hintStyle: const TextStyle(
  100. fontSize: 40.0,
  101. color: Colors.white,
  102. fontFamily: 'digital-7-mono', // Nombre de la fuente
  103. ),
  104. border: OutlineInputBorder(
  105. borderSide: BorderSide.none,
  106. borderRadius: BorderRadius.circular(10.0),
  107. ),
  108. )),
  109. ]);
  110. }
  111. }