Skip to main content

checkURLandNavigate method

Future<void> checkURLandNavigate (String navigateTo, String argument)

<p>This function check the URL and navigate to the respective URL.</p> <p><strong>params</strong>:</p> <ul> <li><code>navigateTo</code>: url</li> <li><code>argument</code>: message</li> </ul> <p><strong>returns</strong>:</p> <ul> <li><code>Future<void></code>: void</li> </ul>

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,
);
\}
\}
\}