Code improvements

This commit is contained in:
Juan Gilsanz Polo
2025-04-03 22:26:14 +02:00
parent 7982644c23
commit 93ebb1de40
17 changed files with 114 additions and 107 deletions

View File

@@ -25,13 +25,15 @@ class CustomSwitchListTile extends StatelessWidget {
return Material(
color: Colors.transparent,
child: InkWell(
onTap: disabled != null && disabled == true
? null
: () => onChanged(!value),
onTap: disabled != null && disabled == true ? null : () => onChanged(!value),
child: Padding(
padding: padding ?? const EdgeInsets.only(
top: 12, left: 16, right: 18, bottom: 16
),
padding: padding ??
const EdgeInsets.only(
top: 12,
left: 16,
right: 18,
bottom: 16,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
@@ -55,35 +57,33 @@ class CustomSwitchListTile extends StatelessWidget {
: Theme.of(context).colorScheme.onSurface,
),
),
if (subtitle != null) ... [
if (subtitle != null) ...[
const SizedBox(height: 5),
SizedBox(
width: MediaQuery.of(context).size.width-110,
width: MediaQuery.of(context).size.width - 110,
child: Text(
subtitle!,
style: TextStyle(
fontSize: 14,
color: disabled != null && disabled == true
? Theme.of(context).listTileTheme.textColor!.withOpacity(0.38)
: Theme.of(context).listTileTheme.textColor
? Theme.of(context).listTileTheme.textColor!.withOpacity(0.38)
: Theme.of(context).listTileTheme.textColor,
),
),
),
]
],
],
),
),
const SizedBox(width: 16),
Switch(
value: value,
onChanged: disabled != null && disabled == true
? null
: onChanged,
)
value: value,
onChanged: disabled != null && disabled == true ? null : onChanged,
),
],
),
),
),
);
}
}
}