This commit is contained in:
string 2025-09-20 11:18:30 +05:30
parent 70c992ddb9
commit 6ace7ced7b
5 changed files with 15 additions and 1 deletions

View File

@ -28,6 +28,10 @@ class CheckboxField extends BaseField {
required ColorScheme colorScheme,
VoidCallback? onChanged,
}) {
// Set default value to false if controller is empty
if (controller.text.isEmpty) {
controller.text = 'false';
}
final bool checked = controller.text.toLowerCase() == 'true';
return Row(
children: [

View File

@ -1,3 +1,5 @@
// working code
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'base_field.dart';

View File

@ -24,6 +24,11 @@ class SwitchField extends BaseField {
required ColorScheme colorScheme,
VoidCallback? onChanged,
}) {
// Set default value to true if controller is empty
if (controller.text.isEmpty) {
controller.text = 'true';
}
final bool current = (controller.text.toLowerCase() == 'true');
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,

View File

@ -383,6 +383,7 @@
// }
// }
// }
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../../../core/providers/dynamic_theme_provider.dart';

View File

@ -185,7 +185,9 @@ class _ModernTextFieldState extends State<ModernTextField>
controller: widget.controller,
focusNode: widget.focusNode,
keyboardType: widget.keyboardType,
obscureText: _obscureText,
obscureText: widget.suffixIcon != null
? widget.obscureText
: _obscureText,
enabled: widget.enabled,
readOnly: widget.readOnly,
maxLines: widget.maxLines,