onufitness_mobile/lib/widgets/Dropdowns/custom_lebel_text_dropdown.dart
2026-01-13 11:36:24 +05:30

80 lines
2.4 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:onufitness/constants/color_constant.dart';
import 'package:onufitness/utils/helper_function.dart';
class LebelTextDropDown extends StatefulWidget {
final String lebelText;
final List<String> items;
String? selectedItem;
final Widget? suffixIcon;
final Function(String?) onChanged;
Color? borderColor;
LebelTextDropDown({
super.key,
required this.lebelText,
required this.items,
required this.selectedItem,
this.suffixIcon,
required this.onChanged,
this.borderColor,
});
@override
LebelTextDropDownState createState() => LebelTextDropDownState();
}
class LebelTextDropDownState extends State<LebelTextDropDown> {
@override
Widget build(BuildContext context) {
return Container(
height: isTablet ? 60.h : null,
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 3.h),
decoration: BoxDecoration(
border: Border.all(color: widget.borderColor ?? textFieldFillColor),
borderRadius: BorderRadius.circular(10.r),
color: textFieldFillColor,
),
child: DropdownButtonFormField<String>(
borderRadius: BorderRadius.circular(20.r),
value: widget.selectedItem,
decoration: InputDecoration(
border: InputBorder.none,
labelText: widget.lebelText,
labelStyle: TextStyle(
fontSize: (isTablet ? 15.sp : 16.sp),
fontWeight: FontWeight.w500,
color: greyTextColor1,
),
),
icon:
widget.suffixIcon != null
? SizedBox(height: 30.h, width: 30.w, child: widget.suffixIcon)
: Icon(
Icons.keyboard_arrow_down,
size: 20.sp,
color: greyTextColor1,
),
style: TextStyle(fontSize: 16.sp, color: Colors.black),
items:
widget.items.map((String type) {
return DropdownMenuItem<String>(
value: type,
child: Text(
type,
style: TextStyle(
fontSize: (isTablet ? 16.sp : 16.sp),
fontWeight: FontWeight.normal,
),
),
);
}).toList(),
onChanged: (String? newValue) {
widget.onChanged(newValue);
},
),
);
}
}