2 changed files with 70 additions and 2 deletions
@ -0,0 +1,61 @@ |
|||
import 'package:flutter/material.dart'; |
|||
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|||
|
|||
class RowSwitchWidget extends StatefulWidget { |
|||
final Map templateData; |
|||
|
|||
const RowSwitchWidget(this.templateData, {super.key}); |
|||
|
|||
@override |
|||
State<RowSwitchWidget> createState() => _RowSwitchWidgetState(); |
|||
} |
|||
|
|||
class _RowSwitchWidgetState extends State<RowSwitchWidget> { |
|||
Map get _templateData => widget.templateData; |
|||
|
|||
@override |
|||
Widget build(BuildContext context) { |
|||
final isDarkMode = Theme.of(context).brightness == Brightness.dark; |
|||
|
|||
return Padding( |
|||
padding: EdgeInsets.fromLTRB(10.w, 10.w, 0, 10.w), |
|||
child: Row( |
|||
children: [ |
|||
Expanded( |
|||
child: Text( |
|||
_templateData['name'], |
|||
style: TextStyle( |
|||
fontSize: 14.sp, |
|||
color: isDarkMode ? Colors.white : Colors.black, |
|||
), |
|||
), |
|||
), |
|||
if (_templateData['description'] != null) |
|||
Text( |
|||
_templateData['description'], |
|||
style: TextStyle( |
|||
fontSize: 12.sp, |
|||
color: isDarkMode ? Colors.white : Colors.grey, |
|||
), |
|||
), |
|||
SizedBox( |
|||
height: 26.w, |
|||
child: Transform.scale( |
|||
scale: 0.8, |
|||
alignment: Alignment.centerRight, |
|||
child: Switch( |
|||
value: _templateData['value'], |
|||
onChanged: (bool value) { |
|||
setState(() { |
|||
_templateData['value'] = value; |
|||
}); |
|||
_templateData['onCallback'](value); |
|||
}, |
|||
), |
|||
), |
|||
), |
|||
], |
|||
), |
|||
); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue