checkURLandNavigate method
Future<void> checkURLandNavigate (String navigateTo, String argument)
This function check the URL and navigate to the respective URL.
params:
navigateTo
: urlargument
: message
returns:
Future<void>
: void
Implementation
Future<void> checkURLandNavigate(String navigateTo, String argument) async {
urlFocus.unfocus();
validate = AutovalidateMode.always;
/// if the url is valid.
if (formKey.currentState!.validate()) {
navigationService
.pushDialog(const CustomProgressDialog(key: Key('UrlCheckProgress')));
validate = AutovalidateMode.disabled;
final String uri = url.text.trim();
final bool? urlPresent =
await locator<Validator>().validateUrlExistence(uri);
if (urlPresent! == true) {
final box = Hive.box('url');
box.put(urlKey, uri);
box.put(imageUrlKey, "$uri/talawa/");
navigationService.pop();
graphqlConfig.getOrgUrl();
navigationService.pushScreen(navigateTo, arguments: argument);
} else {
navigationService.pop();
navigationService.showTalawaErrorSnackBar(
"URL doesn't exist/no connection please check",
MessageType.error,
);
}
}
}