switchFormEntry method
Widget
switchFormEntry(
{ - String title = 'Switch',
- String subTitle = 'the switch',
- required dynamic onToggle(
- bool
),
- bool defaultValue = false,
})
Implementation
Widget switchFormEntry({
String title = 'Switch',
String subTitle = 'the switch',
required Function(bool) onToggle,
bool defaultValue = false,
}) {
return formEntry(
title: title,
subTitle: subTitle,
inputWidget: Container(
padding: EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.grey[50],
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Colors.grey[200]!),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Colors.black87,
),
),
if (subTitle.isNotEmpty) ...[
SizedBox(height: 4),
Text(
subTitle,
style: TextStyle(fontSize: 14, color: Colors.grey[600]),
),
],
],
),
),
SizedBox(width: 16),
MouseRegion(
cursor: isEdit
? SystemMouseCursors.click
: SystemMouseCursors.basic,
child: FlutterSwitch(
value: defaultValue,
onToggle: isEdit ? onToggle : (value) {},
activeColor: primaryActiveColor,
inactiveColor: Colors.grey[300]!,
disabled: !isEdit,
width: 50,
height: 30,
borderRadius: 15,
padding: 2,
),
),
],
),
),
);
}