String Interpolation in Dart Programming

Mukul Latiyan
Updated on 24-May-2021 11:57:58

2K+ Views

There are times when we want to make use of variables inside the statement that is made up of string values.We know that we can add two strings together in Dart with the help of the + symbol operator. But to make use of a variable in between the strings that we are concatenating, we need to add one more + symbol and then type the name of the variable, which works okay when it comes to small statements.ExampleConsider the example shown below − Live Demovoid main(){    String name = "Tutorials";    var collegeName = "DTU";    print("Name is " ... Read More

String in Dart Programming

Mukul Latiyan
Updated on 24-May-2021 11:57:31

214 Views

A String in dart is a sequence or series of characters. The characters can be - special characters, numbers or letters. In Dart, we can represent strings with both the single quotes and double quotes.Example'a string value' or "another string value"Both the examples are valid examples of a string in Dart.In Dart, we can declare strings with the help of the String keyword and also we can use the var keyword as well.ExampleConsider the example shown below − Live Demovoid main(){    String name = "Tuts";    var herName = "Shreya";    print(name);    print(herName); }In the above example, we have ... Read More

Set in Dart Programming

Mukul Latiyan
Updated on 24-May-2021 11:57:07

306 Views

A set is a collection of objects in which each object can occur exactly once. It implies that all the objects in the element type, are either in the set or not in the set.A set is an important data structure and is very helpful in cases where we need exactly one occurrence of each object.There are multiple ways in dart with which we can create a Set, but the default way of making use of the Set() constructor is the most common one.ExampleConsider the example shown below − Live Demovoid main() {    var fruits = new Set();    print(fruits); ... Read More

Runes in Dart Programming

Mukul Latiyan
Updated on 24-May-2021 11:56:45

305 Views

We know that strings in Dart are a sequence of Unicode UTF-16 characters. Dart Runes are actually UTF-32 Unicode code points.They are UTF-32 string which is used to print special symbols.For example, the theta symbol in dart is displayed when we assign the Unicode equivalent value of '\u0398' to a variable.ExampleConsider the example shown below − Live Demovoid main(){    var heartSymbol = '\u0398';    print(heartSymbol); }OutputΘThere are different methods/properties that we can apply on dart Runes to extract the string core units. These mainly are −string.codeUnitAt()string.codeUnitsstring.runesstring.codeUnitAt()The string.codeUnitAt() method is used to access the character's code unit that is present inside ... Read More

Return statement in Dart Programming

Mukul Latiyan
Updated on 24-May-2021 11:56:14

962 Views

There are certain cases where we want to return a value from a given function so that we can use it later. These return values make use of a return keyword which in turn allows a function to return values.It should be noted that the return statement is optional, if not specified the function returns null.Also, only one return statement is allowed in a function.Syntaxreturn ;Syntax of a Dart function with a return value −returnType funcName(){    // statement(s)    return value; }In the above syntax, the funcName is replaced with the name of our function. The returnType represents the type of data/expression ... Read More

Relational Operators in Dart Programming

Mukul Latiyan
Updated on 24-May-2021 11:55:54

587 Views

Relational operators are used in cases where we want to compare two operands. The result when we use a relational operator between two operands is always a Boolean value.There are different types of relational operators present in Dart. In the table shown below all the relational operators present in dart are mentioned.Let's take a case where we have two variables x and y, with values 20 and 30 respectively.Consider the table shown below as a reference −OperatorDescriptionOutput>Greater thanx > y = false=Greater than or equal tox >= y = false

Read and Write Input in Dart Programming

Mukul Latiyan
Updated on 24-May-2021 11:55:32

2K+ Views

Dart provides us with a standard library named 'io' which contains different classes and in turn, these classes contains different methods that we can use to read or write input from the terminal.We import the library in our program by making use of the import command.ExampleConsider the example shown below −Import 'dart:io';Writing something to the terminalWe can write something to the terminal by making use of the standard out class (stdout) that is available to us in the 'dart:io' library.ExampleConsider the example shown below − Live Demoimport 'dart:io'; void main(List arguments) {    stdout.write('What is your name?\r'); }OutputWhat is your ... Read More

Queue in Dart Programming

Mukul Latiyan
Updated on 24-May-2021 11:55:04

312 Views

A queue is a collection of objects. In Dart, we can do operations on both ends of the queue.A queue can be created by making use of the Queue class this present inside the collection library of dart.ExampleConsider the example shown below − Live Demoimport 'dart:collection'; void main() {    var queue = new Queue();    print(queue); }In the above example, we imported the collection library so that Queue class can be used from it and then we create a Queue and store it in a variable named queue, and finally we print whatever is inside the queue variable.Output{}We can add ... Read More

Optional Parameters in Dart Programming

Mukul Latiyan
Updated on 24-May-2021 11:54:25

6K+ Views

Optional parameters are those parameters that don't need to be specified when calling the function. Optional parameters allow us to pass default values to parameters that we define. There are two types of optional parameters, mainly −Ordered (positional) optional parametersNamed optional parametersOrdered Optional ParametersOrdered optional parameters are those parameters that are wrapped in [ ]. For example, void printSomething(int a, int b, [ int c = 10] ){    // function body }They give us the freedom to call the function with or without the third parameter.ExampleConsider the example shown below − Live Demovoid printSomething(int a, int b, [ int c ... Read More

Null Aware Operators in Dart Programming

Mukul Latiyan
Updated on 24-May-2021 11:53:55

461 Views

Dart has different null aware operators that we can use to make sure that we are not accessing the null values and to deal with them in a subtle way.Mainly, these are −?? operator??= operator? operatorWe will go through each of them in the following article.?? operatorThe ?? operator returns the first expression if and only if it is not null.ExampleConsider the example shown below −void main() {    var age;    age = age ?? 23;    print(age);    var name = "mukul";    name = name ?? "suruchi";    print(name); }In the above example, we declared two ... Read More

Advertisements