Dart Uri scheme
Syntax & Examples


Uri.scheme property

The `scheme` property in Dart's Uri class represents the scheme component of the URI.


Syntax of Uri.scheme

The syntax of Uri.scheme property is:

 String scheme 

This scheme property of Uri the scheme component of the URI.

Return Type

Uri.scheme returns value of type String.



✐ Examples

1 Getting the scheme from an HTTPS URI

In this example,

  1. We parse an HTTPS URI.
  2. We access the `scheme` property of the URI.
  3. We print the scheme to standard output.

Dart Program

void main() {
  Uri uri1 = Uri.parse('https://example.com');
  print(uri1.scheme); // https
}

Output

https

2 Getting the scheme from an FTP URI

In this example,

  1. We parse an FTP URI.
  2. We access the `scheme` property of the URI.
  3. We print the scheme to standard output.

Dart Program

void main() {
  Uri uri2 = Uri.parse('ftp://example.com/file.txt');
  print(uri2.scheme); // ftp
}

Output

ftp

Summary

In this Dart tutorial, we learned about scheme property of Uri: the syntax and few working examples with output and detailed explanation for each example.