update method

  1. @override
void update(
  1. String input
)
override

Updates the value based on the user's input.

Perform validation here and set error accordingly. You do not have to set value in this function -- for example, if the user entered an invalid input.

Implementation

@override
void update(String input) {
	if (input.isEmpty) {
		error = "Must not be blank";
	} else if (regex.stringMatch(input) != input || input.endsWith(".")) {
		error = "Not a valid IP";
	} else if (input.split(".").any((part) => int.parse(part) > 255)) {
		error = "IP out of range";
	} else {
		error = null;
		value = InternetAddress(input);
	}
	notifyListeners();
}