'Manipulate DateTimeFormField while clikcing on radio button
I've to change DateTimeFormField date according ti given condition into radio button. For example, if I select Yes, I've to set DateTimeFormField value as DateTime.now(). For N/A DateTimeFormField will be empty. I'm using setState in Yes, N/A for changing the value. The value is changing but not showing into DateTimeFormField. I mean it's not refreshing. How can I refresh the DateTimeFormField value according to Yes, N/A selection?
DateTimeFormField(
dateFormat: DateFormat('yyyy-MM-dd'),
mode: DateTimeFieldPickerMode.date,
initialValue: DateTime.parse(list[index].end!),
decoration: InputDecoration(
isDense: true,
contentPadding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 10.h),
hintStyle: TextStyle(color: Colors.black45),
errorStyle: TextStyle(color: Colors.redAccent),
border: OutlineInputBorder(),
suffixIcon: Icon(Icons.event_note),
),
onDateSelected: (DateTime value) {
list[index].end= value.toString();
},
)
Radio<String>(
value: list[index].yes!,
groupValue: "Y",
onChanged: (value) {
setState(() {
list[index].naFlag = "N";
list[index].yes = "Y";
list[index].yes = "Y";
if(list[index].start== null) {
list[index].start= DateTime.now().toString();
}
if(list[index].end== null) {
list[index].end= DateTime.now().toString();
}
});
list[index].yes = "Y";
list[index].naFlag = "N";
},
activeColor: Colors.blue,
)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
