Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 444 Vote(s) - 3.51 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dart / Flutter - Validating a string for URL

#11
You can use the [url_launcher][1] package for this.

Future<bool> checkIfUrlIsValid({required String url}) async {
if (await canLaunchUrl(Uri.parse(url))) {
return true;
}
return false;}


checkIfUrlIsValid(url: 'https://google.com'); // true;
checkIfUrlIsValid(url: 'google com'); // false;


[1]:

[To see links please register here]

Reply

#12
Use this simple function then you can identify string is valid URL or not


bool isURl(String url){
return RegExp(r'^((?:.|\n)*?)((http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)([-A-Z0-9.]+)(/[-A-Z0-9+&@#/%=~_|!:,.;]*)?(\?[A-Z0-9+&@#/%=~_|!:‌​,.;]*)?)')
.hasMatch(url); }



Reply

#13
If you are using [GetX][1], it provides a string extension called "isURL":

```dart
import 'package:get/get.dart';

final url = 'https://www.google.com/';

if (url.isURL) {
print('Success');
}
```

Note: you should not install this plugin if you will only use this extension, the idea is to take advantage of it if you already use it.

More String extensions from GetX:

- isNum
- isNumericOnly
- isAlphabetOnly
- isBool
- isDocumentFileName
- isExcelFileName
- isEmail
- isPhoneNumber
- isDateTime

And others.

See: [

[To see links please register here]

][2]


[1]:

[To see links please register here]

[2]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through