This repository has been archived on 2024-10-18. You can view files and clone it, but cannot push or open issues or pull requests.
ftc_patient_app/lib/view/custom_widgets/custom_radio_button.dart

60 lines
1.6 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:ftc_mobile_app/utilities/custom_app_colors.dart';
import 'package:get/get.dart';
import 'custom_text_widget.dart';
class RadioButton extends StatelessWidget {
final String value;
final Rx<String?> selectedOption;
final bool isEnabled;
const RadioButton({
super.key,
required this.value,
required this.selectedOption,
this.isEnabled = true,
});
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
selectedOption(value);
},
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Ink(
width: 32.r,
height: 32.r,
child: Obx(() {
return Radio(
value: value,
groupValue: selectedOption(),
onChanged: selectedOption,
fillColor: MaterialStateProperty.resolveWith((states) {
if (!isEnabled) return CustomAppColors.kLightGreyColor;
if (states.contains(MaterialState.selected)) {
return CustomAppColors.kSecondaryColor;
}
return Colors.black;
}),
);
}),
),
CustomTextWidget(
text: value,
isExpanded: false,
fontSize: 14.sp,
fontWeight: FontWeight.w400,
fontColor:
isEnabled ? Colors.black : CustomAppColors.kLightGreyColor,
)
],
),
);
}
}