setValue method
void
setValue(})
Implementation
void setValue(DateTime? result, TimeOfDay? timeResult, String? format,
{DateTime? secondResult}) {
DateTime now = DateTime.now();
//return result based on type and format
if (type == "date" || type == "year" || type == "range") {
try {
if (secondResult != null) {
value =
"${DateFormat(format).format(result!)} - ${DateFormat(format).format(secondResult)}";
} else {
value = DateFormat(format, 'en_US').format(result!);
}
} on FormatException catch (e) {
Log().debug('${e}FORMATTING ERROR!!!!!');
}
} else if (type == "time") {
//if (format == 'yMd') format= 'H:m';
try {
value = DateFormat(format).format(DateTime(
now.year, now.month, now.day, timeResult!.hour, timeResult.minute));
} on FormatException catch (e) {
Log().debug('${e}FORMATTING ERROR!!!!!');
value = '';
}
} else {
try {
value = DateFormat(format).format(DateTime(result!.year, result.month,
result.day, timeResult!.hour, timeResult.minute));
} on FormatException catch (e) {
Log().debug('${e}FORMATTING ERROR!!!!!');
value = '';
}
}
onChange(context);
}