cover

String in Dart #

In string we can put almost all kind of character.

Our name is also combination of character.

How to declare/define String?

main.dart
String string_name

Example 1 #

In this example we will declare string and later on put some value in it. Once we have value in the our string variable we will print their value.

main.dart
void main(){
    String website;
    website = "nstack";
    print(website);
}

Example 2 #

In this example we will declare string with value and print it’s value.

main.dart
void main(){
    String website = "nstack";
    print(website);
}

We can’t apply mathematics operation on String because that will not make sense.

Can you find the product of two names? Probably Not!

There is one mathematics operation which could be applied to String which is adding of two String.

Adding two String #

Adding of two string means putting one string after other. We usually don’t call it as adding of string but here I am calling it. I am calling adding of two string because it is being done use mathematical +(Add) Symbol.

main.dart
void main(){
    String website = "nstack";
    String tld = ".in";
    String url = website + tld;
    print(url);
}

The more appropriate term for adding string is Concat of String.