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.
		
		
		
		
		
			
		
			
				
	
	
		
			42 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Dart
		
	
			
		
		
	
	
			42 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Dart
		
	
| import 'package:flutter/material.dart';
 | |
| import 'package:hmg_patient_app_new/core/utils/size_utils.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.h,
 | |
|         height: 30.h,
 | |
|         decoration: BoxDecoration(
 | |
|           color: widget.value ? Color(0xFFE6F7F0) : Color(0xFFE6F7F0),
 | |
|           borderRadius: BorderRadius.circular(18),
 | |
|         ),
 | |
|         child: AnimatedAlign(
 | |
|           duration: Duration(milliseconds: 200),
 | |
|           alignment: widget.value ? Alignment.centerRight : Alignment.centerLeft,
 | |
|           child: Container(
 | |
|             margin: EdgeInsets.all(4),
 | |
|             width: 28,
 | |
|             height: 28,
 | |
|             decoration: BoxDecoration(
 | |
|               color: Color(0xFF5FCB89),
 | |
|               shape: BoxShape.circle,
 | |
|             ),
 | |
|           ),
 | |
|         ),
 | |
|       ),
 | |
|     );
 | |
|   }
 | |
| } |