You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
HMG_Patient_App_New/lib/widgets/CustomSwitch.dart

43 lines
1.3 KiB
Dart

import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
import 'package:hmg_patient_app_new/theme/colors.dart';
class CustomSwitch extends StatefulWidget {
final bool value;
final ValueChanged<bool> onChanged;
const CustomSwitch({super.key, required this.value, required this.onChanged});
@override
State<CustomSwitch> createState() => _CustomSwitchState();
}
class _CustomSwitchState extends State<CustomSwitch> {
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () => widget.onChanged(!widget.value),
child: Container(
width: 48.w,
height: 30.h,
decoration: BoxDecoration(
color: AppColors.switchBackgroundColor ,
borderRadius: BorderRadius.circular(18),
),
child: AnimatedAlign(
duration: Duration(milliseconds: 300),
alignment: widget.value ? Alignment.centerRight : Alignment.centerLeft,
child: Container(
margin: EdgeInsets.all(2.h),
width: 28.w,
height: 28.h,
decoration: BoxDecoration(
color: AppColors.thumbColor,
shape: BoxShape.circle,
),
),
),
),
);
}
}