aiuto
This commit is contained in:
@@ -4,7 +4,7 @@ import 'package:flux/core/theme/theme.dart';
|
||||
|
||||
class FluxTextField extends StatefulWidget {
|
||||
final String label;
|
||||
final IconData icon;
|
||||
final IconData? icon;
|
||||
final bool isPassword;
|
||||
final bool autoFocus;
|
||||
final TextEditingController? controller;
|
||||
@@ -14,11 +14,12 @@ class FluxTextField extends StatefulWidget {
|
||||
final Function(String)? onSubmitted;
|
||||
final Function(String)? onChanged;
|
||||
final int? maxLength;
|
||||
final String? Function(String?)? validator;
|
||||
|
||||
const FluxTextField({
|
||||
super.key, // Usiamo super.key per Flutter moderno
|
||||
required this.label,
|
||||
required this.icon,
|
||||
this.icon,
|
||||
this.isPassword = false,
|
||||
this.autoFocus = false,
|
||||
this.controller,
|
||||
@@ -28,6 +29,7 @@ class FluxTextField extends StatefulWidget {
|
||||
this.onSubmitted,
|
||||
this.onChanged,
|
||||
this.maxLength,
|
||||
this.validator,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -45,8 +47,9 @@ class _FluxTextFieldState extends State<FluxTextField> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TextField(
|
||||
return TextFormField(
|
||||
controller: widget.controller,
|
||||
validator: widget.validator,
|
||||
obscureText: _obscureText,
|
||||
enableSuggestions: !widget.isPassword,
|
||||
autocorrect: !widget.isPassword,
|
||||
@@ -79,6 +82,7 @@ class _FluxTextFieldState extends State<FluxTextField> {
|
||||
horizontal: 16,
|
||||
vertical: 16,
|
||||
),
|
||||
|
||||
suffixIcon: widget.isPassword
|
||||
? IconButton(
|
||||
icon: Icon(
|
||||
@@ -95,7 +99,7 @@ class _FluxTextFieldState extends State<FluxTextField> {
|
||||
)
|
||||
: null, // Se non è una password, niente icona
|
||||
),
|
||||
onSubmitted: widget.onSubmitted,
|
||||
onFieldSubmitted: widget.onSubmitted,
|
||||
onChanged: widget.onChanged,
|
||||
maxLength: widget.maxLength,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user