mod switch between pages and remove errors
This commit is contained in:
@@ -18,8 +18,36 @@ class MyFormField extends StatelessWidget {
|
||||
final TextInputType keyboardType;
|
||||
final String? Function(String?)? validator;
|
||||
|
||||
// Prüft ob Controller noch verwendbar ist
|
||||
bool _isControllerValid() {
|
||||
try {
|
||||
userController.text;
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Wenn Controller disposed ist, zeige Ersatz-Widget
|
||||
if (!_isControllerValid()) {
|
||||
return Container(
|
||||
height: 56,
|
||||
decoration: BoxDecoration(
|
||||
color: fillColor,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(color: Colors.grey),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'$labelText (Controller nicht verfügbar)',
|
||||
style: TextStyle(color: Colors.grey[600]),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return TextFormField(
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
style: const TextStyle(color: Colors.black),
|
||||
|
||||
Reference in New Issue
Block a user