onPressCheckboxDoneListPattern method
- TextEditingValue value,
- String text,
- void onUpdateValue(
- TextEditingValue newValue
This function returns a TapGestureRecognizer that updates a given TextEditingValue with a new text value that replaces a specific pattern with a checkbox.
Args: value (TextEditingValue): A TextEditingValue object that represents the current value of the text field. text (String): The original text that needs to be updated with a checkbox list pattern. onUpdateValue (void Function(TextEditingValue newValue)): onUpdateValue is a callback function that takes in a new TextEditingValue as a parameter and updates the value of the text editing field. This function is called when the TapGestureRecognizer is triggered, which means when the user taps on a checkbox in the list pattern. The new value is created by replacing
Returns:
A TapGestureRecognizer object is being returned.
Implementation
TapGestureRecognizer onPressCheckboxDoneListPattern(
TextEditingValue value,
String text,
void Function(TextEditingValue newValue) onUpdateValue,
) {
return TapGestureRecognizer()
..onTap = () {
final newValue = value.copyWith(
composing: TextRange.empty,
selection: TextSelection.collapsed(offset: text.length),
text: text.replaceAll(
match,
"- [ ] ${match.replaceAll("- [x]", "")}",
),
);
onUpdateValue.call(newValue);
};
}