Dart Programming – Map ”; Previous Next The Map object is a simple key/value pair. Keys and values in a map may be of any type. A Map is a dynamic collection. In other words, Maps can grow and shrink at runtime. Maps can be declared in two ways − Using Map Literals Using a Map constructor Declaring a Map using Map Literals To declare a map using map literals, you need to enclose the key-value pairs within a pair of curly brackets “{ }”. Here is its syntax − var identifier = { key1:value1, key2:value2 [,…..,key_n:value_n] } Declaring a Map using a Map Constructor To declare a Map using a Map constructor, we have two steps. First, declare the map and second, initialize the map. The syntax to declare a map is as follows − var identifier = new Map() Now, use the following syntax to initialize the map − map_name[key] = value Example: Map Literal Live Demo void main() { var details = {”Usrname”:”tom”,”Password”:”pass@123”}; print(details); } It will produce the following output − {Usrname: tom, Password: pass@123} Example: Adding Values to Map Literals at Runtime Live Demo void main() { var details = {”Usrname”:”tom”,”Password”:”pass@123”}; details[”Uid”] = ”U1oo1”; print(details); } It will produce the following output − {Usrname: tom, Password: pass@123, Uid: U1oo1} Example: Map Constructor Live Demo void main() { var details = new Map(); details[”Usrname”] = ”admin”; details[”Password”] = ”admin@123”; print(details); } It will produce the following output − {Usrname: admin, Password: admin@123} Note − A map value can be any object including NULL. Map – Properties The Map class in the dart:core package defines the following properties − Sr.No Property & Description 1 Keys Returns an iterable object representing keys 2 Values Returns an iterable object representing values 3 Length Returns the size of the Map 4 isEmpty Returns true if the Map is an empty Map 5 isNotEmpty Returns true if the Map is an empty Map Map – Functions Following are the commonly used functions for manipulating Maps in Dart. Sr.No Function Name & Description 1 addAll() Adds all key-value pairs of other to this map. 2 clear() Removes all pairs from the map. 3 remove() Removes key and its associated value, if present, from the map. 4 forEach() Applies f to each key-value pair of the map. Print Page Previous Next Advertisements ”;
Category: dart Programming
Dart Programming – Collection ”; Previous Next Dart, unlike other programming languages, doesn’t support arrays. Dart collections can be used to replicate data structures like an array. The dart:core library and other classes enable Collection support in Dart scripts. Dart collections can be basically classified as − Sr.No Dart collection & Description 1 List A List is simply an ordered group of objects. The dart:core library provides the List class that enables creation and manipulation of lists. Fixed Length List − The list’s length cannot change at run-time. Growable List − The list’s length can change at run-time. 2 Set Set represents a collection of objects in which each object can occur only once. The dart:core library provides the Set class to implement the same. 3 Maps The Map object is a simple key/value pair. Keys and values in a map may be of any type. A Map is a dynamic collection. In other words, Maps can grow and shrink at runtime. The Map class in the dart:core library provides support for the same. 4 Queue A Queue is a collection that can be manipulated at both ends. Queues are useful when you want to build a first-in, first-out collection. Simply put, a queue inserts data from one end and deletes from another end. The values are removed / read in the order of their insertion. Iterating Collections The Iterator class from the dart:core library enables easy collection traversal. Every collection has an iterator property. This property returns an iterator that points to the objects in the collection. Example The following example illustrates traversing a collection using an iterator object. Live Demo import ”dart:collection”; void main() { Queue numQ = new Queue(); numQ.addAll([100,200,300]); Iterator i= numQ.iterator; while(i.moveNext()) { print(i.current); } } The moveNext() function returns a Boolean value indicating whether there is a subsequent entry. The current property of the iterator object returns the value of the object that the iterator currently points to. This program should produce the following output − 100 200 300 Print Page Previous Next Advertisements ”;
Dart Programming – Boolean
Dart Programming – Boolean ”; Previous Next Dart provides an inbuilt support for the Boolean data type. The Boolean data type in DART supports only two values – true and false. The keyword bool is used to represent a Boolean literal in DART. The syntax for declaring a Boolean variable in DART is as given below − bool var_name = true; OR bool var_name = false Example Live Demo void main() { bool test; test = 12 > 5; print(test); } It will produce the following output − true Example Unlike JavaScript, the Boolean data type recognizes only the literal true as true. Any other value is considered as false. Consider the following example − var str = ”abc”; if(str) { print(”String is not empty”); } else { print(”Empty String”); } The above snippet, if run in JavaScript, will print the message ‘String is not empty’ as the if construct will return true if the string is not empty. However, in Dart, str is converted to false as str != true. Hence the snippet will print the message ‘Empty String’ (when run in unchecked mode). Example The above snippet if run in checked mode will throw an exception. The same is illustrated below − Live Demo void main() { var str = ”abc”; if(str) { print(”String is not empty”); } else { print(”Empty String”); } } It will produce the following output, in Checked Mode − Unhandled exception: type ”String” is not a subtype of type ”bool” of ”boolean expression” where String is from dart:core bool is from dart:core #0 main (file:///D:/Demos/Boolean.dart:5:6) #1 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:261) #2 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:148) It will produce the following output, in Unchecked Mode − Empty String Note − The WebStorm IDE runs in checked mode, by default. Print Page Previous Next Advertisements ”;
Dart Programming – Functions
Dart Programming – Functions ”; Previous Next Functions are the building blocks of readable, maintainable, and reusable code. A function is a set of statements to perform a specific task. Functions organize the program into logical blocks of code. Once defined, functions may be called to access code. This makes the code reusable. Moreover, functions make it easy to read and maintain the program’s code. A function declaration tells the compiler about a function”s name, return type, and parameters. A function definition provides the actual body of the function. Sr.No Functions & Description 1 Defining a Function A function definition specifies what and how a specific task would be done. 2 Calling a Function A function must be called so as to execute it. 3 Returning Functions Functions may also return value along with control, back to the caller. 4 Parameterized Function Parameters are a mechanism to pass values to functions. Optional Parameters Optional parameters can be used when arguments need not be compulsorily passed for a function’s execution. A parameter can be marked optional by appending a question mark to its name. The optional parameter should be set as the last argument in a function. We have three types of optional parameters in Dart − Sr.No Parameter & Description 1 Optional Positional Parameter To specify optional positional parameters, use square [] brackets. 2 Optional named parameter Unlike positional parameters, the parameter”s name must be specified while the value is being passed. Curly brace {} can be used to specify optional named parameters. 3 Optional Parameters with Default Values Function parameters can also be assigned values by default. However, such parameters can also be explicitly passed values. Recursive Dart Functions Recursion is a technique for iterating over an operation by having a function call to itself repeatedly until it arrives at a result. Recursion is best applied when you need to call the same function repeatedly with different parameters from within a loop. Example Live Demo void main() { print(factorial(6)); } factorial(number) { if (number <= 0) { // termination case return 1; } else { return (number * factorial(number – 1)); // function invokes itself } } It should produce the following output − 720 Lambda Functions Lambda functions are a concise mechanism to represent functions. These functions are also called as Arrow functions. Syntax [return_type]function_name(parameters)=>expression; Example Live Demo void main() { printMsg(); print(test()); } printMsg()=> print(“hello”); int test()=>123; // returning function It should produce the following output − hello 123 Print Page Previous Next Advertisements ”;
Dart Programming – Operators
Dart Programming – Operators ”; Previous Next An expression is a special kind of statement that evaluates to a value. Every expression is composed of − Operands − Represents the data Operator − Defines how the operands will be processed to produce a value. Consider the following expression – “2 + 3”. In this expression, 2 and 3 are operands and the symbol “+” (plus) is the operator. In this chapter, we will discuss the operators that are available in Dart. Arithmetic Operators Equality and Relational Operators Type test Operators Bitwise Operators Assignment Operators Logical Operators Arithmetic Operators The following table shows the arithmetic operators supported by Dart. Show Examples Sr.No Operators & Meaning 1 + Add 2 − Subtract 3 -expr Unary minus, also known as negation (reverse the sign of the expression) 4 * Multiply 5 / Divide 6 ~/ Divide, returning an integer result 7 % Get the remainder of an integer division (modulo) 8 ++ Increment 9 — Decrement Equality and Relational Operators Relational Operators tests or defines the kind of relationship between two entities. Relational operators return a Boolean value i.e. true/ false. Assume the value of A is 10 and B is 20. Show Examples Operator Description Example > Greater than (A > B) is False < Lesser than (A < B) is True >= Greater than or equal to (A >= B) is False <= Lesser than or equal to (A <= B) is True == Equality (A==B) is False != Not equal (A!=B) is True Type test Operators These operators are handy for checking types at runtime. Show Examples Operator Meaning is True if the object has the specified type is! False if the object has the specified type Bitwise Operators The following table lists the bitwise operators available in Dart and their role − Show Examples Operator Description Example Bitwise AND a & b Returns a one in each bit position for which the corresponding bits of both operands are ones. Bitwise OR a | b Returns a one in each bit position for which the corresponding bits of either or both operands are ones. Bitwise XOR a ^ b Returns a one in each bit position for which the corresponding bits of either but not both operands are ones. Bitwise NOT ~ a Inverts the bits of its operand. Left shift a ≪ b Shifts a in binary representation b (< 32) bits to the left, shifting in zeroes from the right. Signpropagating right shift a ≫ b Shifts a in binary representation b (< 32) bits to the right, discarding bits shifted off. Assignment Operators The following table lists the assignment operators available in Dart. Show Examples Sr.No Operator & Description 1 =(Simple Assignment ) Assigns values from the right side operand to the left side operand Ex:C = A + B will assign the value of A + B into C 2 ??= Assign the value only if the variable is null 3 +=(Add and Assignment) It adds the right operand to the left operand and assigns the result to the left operand. Ex: C += A is equivalent to C = C + A 4 ─=(Subtract and Assignment) It subtracts the right operand from the left operand and assigns the result to the left operand. Ex: C -= A is equivalent to C = C – A 5 *=(Multiply and Assignment) It multiplies the right operand with the left operand and assigns the result to the left operand. Ex: C *= A is equivalent to C = C * A 6 /=(Divide and Assignment) It divides the left operand with the right operand and assigns the result to the left operand. Note − Same logic applies to Bitwise operators, so they will become ≪=, ≫=, ≫=, ≫=, |= and ^=. Logical Operators Logical operators are used to combine two or more conditions. Logical operators return a Boolean value. Assume the value of variable A is 10 and B is 20. Show Examples Operator Description Example && And − The operator returns true only if all the expressions specified return true (A > 10 && B > 10) is False. || OR − The operator returns true if at least one of the expressions specified return true (A > 10 || B > 10) is True. ! NOT − The operator returns the inverse of the expression’s result. For E.g.: !(7>5) returns false !(A > 10) is True. Conditional Expressions Dart has two operators that let you evaluate expressions that might otherwise require ifelse statements − condition ? expr1 : expr2 If condition is true, then the expression evaluates expr1 (and returns its value); otherwise, it evaluates and returns the value of expr2. expr1 ?? expr2 If expr1 is non-null, returns its value; otherwise, evaluates and returns the value of expr2 Example The following example shows how you can use conditional expression in Dart − Live Demo void main() { var a = 10; var res = a > 12 ? “value greater than 10″:”value lesser than or equal to 10″; print(res); } It will produce the following output − value lesser than or equal to 10 Example Let’s take another example − void main() { var a = null; var b = 12; var res = a ?? b; print(res); } It will produce the following output − 12 Print Page Previous Next Advertisements ”;
Dart Programming – Loops
Dart Programming – Loops ”; Previous Next At times, certain instructions require repeated execution. Loops are an ideal way to do the same. A loop represents a set of instructions that must be repeated. In a loop’s context, a repetition is termed as an iteration. The following figure illustrates the classification of loops − Let’s start the discussion with Definite Loops. A loop whose number of iterations are definite/fixed is termed as a definite loop. Sr.No Loop & Description 1 for loop The for loop is an implementation of a definite loop. The for loop executes the code block for a specified number of times. It can be used to iterate over a fixed set of values, such as an array 2 for…in Loop The for…in loop is used to loop through an object”s properties. Moving on, let’s now discuss the indefinite loops. An indefinite loop is used when the number of iterations in a loop is indeterminate or unknown. Indefinite loops can be implemented using − Sr.No Loop & Description 1 while Loop The while loop executes the instructions each time the condition specified evaluates to true. In other words, the loop evaluates the condition before the block of code is executed. 2 do…while Loop The do…while loop is similar to the while loop except that the do…while loop doesn’t evaluate the condition for the first time the loop executes. Let us now move on and discuss the Loop Control Statements of Dart. Sr.No Control Statement & Description 1 break Statement The break statement is used to take the control out of a construct. Using break in a loop causes the program to exit the loop. Following is an example of the break statement. 2 continue Statement The continue statement skips the subsequent statements in the current iteration and takes the control back to the beginning of the loop. Using Labels to Control the Flow A label is simply an identifier followed by a colon (:) that is applied to a statement or a block of code. A label can be used with break and continue to control the flow more precisely. Line breaks are not allowed between the ‘continue’ or ‘break’ statement and its label name. Also, there should not be any other statement in between a label name and an associated loop. Example: Label with Break Live Demo void main() { outerloop: // This is the label name for (var i = 0; i < 5; i++) { print(“Innerloop: ${i}”); innerloop: for (var j = 0; j < 5; j++) { if (j > 3 ) break ; // Quit the innermost loop if (i == 2) break innerloop; // Do the same thing if (i == 4) break outerloop; // Quit the outer loop print(“Innerloop: ${j}”); } } } The following output is displayed on successful execution of the above code. Innerloop: 0 Innerloop: 0 Innerloop: 1 Innerloop: 2 Innerloop: 3 Innerloop: 1 Innerloop: 0 Innerloop: 1 Innerloop: 2 Innerloop: 3 Innerloop: 2 Innerloop: 3 Innerloop: 0 Innerloop: 1 Innerloop: 2 Innerloop: 3 Innerloop: 4 Example: Label with continue Live Demo void main() { outerloop: // This is the label name for (var i = 0; i < 3; i++) { print(“Outerloop:${i}”); for (var j = 0; j < 5; j++) { if (j == 3){ continue outerloop; } print(“Innerloop:${j}”); } } } The following output is displayed on successful execution of the above code. Outerloop: 0 Innerloop: 0 Innerloop: 1 Innerloop: 2 Outerloop: 1 Innerloop: 0 Innerloop: 1 Innerloop: 2 Outerloop: 2 Innerloop: 0 Innerloop: 1 Innerloop: 2 Print Page Previous Next Advertisements ”;
Dart Programming – Enumeration ”; Previous Next An enumeration is used for defining named constant values. An enumerated type is declared using the enum keyword. Syntax enum enum_name { enumeration list } Where, The enum_name specifies the enumeration type name The enumeration list is a comma-separated list of identifiers Each of the symbols in the enumeration list stands for an integer value, one greater than the symbol that precedes it. By default, the value of the first enumeration symbol is 0. For example enum Status { none, running, stopped, paused } Example Live Demo enum Status { none, running, stopped, paused } void main() { print(Status.values); Status.values.forEach((v) => print(”value: $v, index: ${v.index}”)); print(”running: ${Status.running}, ${Status.running.index}”); print(”running index: ${Status.values[1]}”); } It will produce the following output − [Status.none, Status.running, Status.stopped, Status.paused] value: Status.none, index: 0 value: Status.running, index: 1 value: Status.stopped, index: 2 value: Status.paused, index: 3 running: Status.running, 1 running index: Status.running Print Page Previous Next Advertisements ”;
Dart Programming – Libraries
Dart Programming – Libraries ”; Previous Next A library in a programming language represents a collection of routines (set of programming instructions). Dart has a set of built-in libraries that are useful to store routines that are frequently used. A Dart library comprises of a set of classes, constants, functions, typedefs, properties, and exceptions. Importing a library Importing makes the components in a library available to the caller code. The import keyword is used to achieve the same. A dart file can have multiple import statements. Built in Dart library URIs use the dart: scheme to refer to a library. Other libraries can use a file system path or the package: scheme to specify its URI. Libraries provided by a package manager such as the pub tool uses the package: scheme. The syntax for importing a library in Dart is given below − import ”URI” Consider the following code snippet − import ”dart:io” import ”package:lib1/libfile.dart” If you want to use only part of a library, you can selectively import the library. The syntax for the same is given below − import ”package: lib1/lib1.dart” show foo, bar; // Import only foo and bar. import ”package: mylib/mylib.dart” hide foo; // Import all names except foo Some commonly used libraries are given below − Sr.No Library & Description 1 dart:io File, socket, HTTP, and other I/O support for server applications. This library does not work in browser-based applications. This library is imported by default. 2 dart:core Built-in types, collections, and other core functionality for every Dart program. This library is automatically imported. 3 dart: math Mathematical constants and functions, plus a random number generator. 4 dart: convert Encoders and decoders for converting between different data representations, including JSON and UTF-8. 5 dart: typed_data Lists that efficiently handle fixed sized data (for example, unsigned 8 byte integers). Example : Importing and using a Library The following example imports the built-in library dart: math. The snippet calls the sqrt() function from the math library. This function returns the square root of a number passed to it. Live Demo import ”dart:math”; void main() { print(“Square root of 36 is: ${sqrt(36)}”); } Output Square root of 36 is: 6.0 Encapsulation in Libraries Dart scripts can prefix identifiers with an underscore ( _ ) to mark its components private. Simply put, Dart libraries can restrict access to its content by external scripts. This is termed as encapsulation. The syntax for the same is given below − Syntax _identifier Example At first, define a library with a private function. Live Demo library loggerlib; void _log(msg) { print(“Log method called in loggerlib msg:$msg”); } Next, import the library import ”test.dart” as web; void main() { web._log(“hello from webloggerlib”); } The above code will result in an error. Unhandled exception: No top-level method ”web._log” declared. NoSuchMethodError: method not found: ”web._log” Receiver: top-level Arguments: […] #0 NoSuchMethodError._throwNew (dart:core-patch/errors_patch.dart:184) #1 main (file:///C:/Users/Administrator/WebstormProjects/untitled/Assertion.dart:6:3) #2 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:261) #3 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:148) Creating Custom Libraries Dart also allows you to use your own code as a library. Creating a custom library involves the following steps − Step 1: Declaring a Library To explicitly declare a library, use the library statement. The syntax for declaring a library is as given below − library library_name // library contents go here Step 2: Associating a Library You can associate a library in two ways − Within the same directory import ”library_name” From a different directory import ”dir/library_name” Example: Custom Library First, let us define a custom library, calculator.dart. library calculator_lib; import ”dart:math”; //import statement after the libaray statement int add(int firstNumber,int secondNumber){ print(“inside add method of Calculator Library “) ; return firstNumber+secondNumber; } int modulus(int firstNumber,int secondNumber){ print(“inside modulus method of Calculator Library “) ; return firstNumber%secondNumber; } int random(int no){ return new Random().nextInt(no); } Next, we will import the library − import ”calculator.dart”; void main() { var num1 = 10; var num2 = 20; var sum = add(num1,num2); var mod = modulus(num1,num2); var r = random(10); print(“$num1 + $num2 = $sum”); print(“$num1 % $num2= $mod”); print(“random no $r”); } The program should produce the following output − inside add method of Calculator Library inside modulus method of Calculator Library 10 + 20 = 30 10 % 20= 10 random no 0 Library Prefix If you import two libraries with conflicting identifiers, then you can specify a prefix for one or both libraries. Use the ”as” keyword for specifying the prefix. The syntax for the same is given below − Syntax import ”library_uri” as prefix Example First, let us define a library: loggerlib.dart. library loggerlib; void log(msg){ print(“Log method called in loggerlib msg:$msg”); } Next, we will define another library: webloggerlib.dart. library webloggerlib; void log(msg){ print(“Log method called in webloggerlib msg:$msg”); } Finally, we will import the library with a prefix. import ”loggerlib.dart”; import ”webloggerlib.dart” as web; // prefix avoids function name clashes void main(){ log(“hello from loggerlib”); web.log(“hello from webloggerlib”); } It will produce the following output − Log method called in loggerlib msg:hello from loggerlib Log method called in webloggerlib msg:hello from webloggerlib Print Page Previous Next Advertisements ”;
Dart Programming – Data Types ”; Previous Next One of the most fundamental characteristics of a programming language is the set of data types it supports. These are the type of values that can be represented and manipulated in a programming language. The Dart language supports the following types− Numbers Strings Booleans Lists Maps Numbers Numbers in Dart are used to represent numeric literals. The Number Dart come in two flavours − Integer − Integer values represent non-fractional values, i.e., numeric values without a decimal point. For example, the value “10” is an integer. Integer literals are represented using the int keyword. Double − Dart also supports fractional numeric values i.e. values with decimal points. The Double data type in Dart represents a 64-bit (double-precision) floating-point number. For example, the value “10.10”. The keyword double is used to represent floating point literals. Strings Strings represent a sequence of characters. For instance, if you were to store some data like name, address etc. the string data type should be used. A Dart string is a sequence of UTF-16 code units. Runes are used to represent a sequence of UTF-32 code units. The keyword String is used to represent string literals. String values are embedded in either single or double quotes. Boolean The Boolean data type represents Boolean values true and false. Dart uses the bool keyword to represent a Boolean value. List and Map The data types list and map are used to represent a collection of objects. A List is an ordered group of objects. The List data type in Dart is synonymous to the concept of an array in other programming languages. The Map data type represents a set of values as key-value pairs. The dart: core library enables creation and manipulation of these collections through the predefined List and Map classes respectively. The Dynamic Type Dart is an optionally typed language. If the type of a variable is not explicitly specified, the variable’s type is dynamic. The dynamic keyword can also be used as a type annotation explicitly. Print Page Previous Next Advertisements ”;
Dart Programming – Async
Dart Programming – Async ”; Previous Next An asynchronous operation executes in a thread, separate from the main application thread. When an application calls a method to perform an operation asynchronously, the application can continue executing while the asynchronous method performs its task. Example Let’s take an example to understand this concept. Here, the program accepts user input using the IO library. Live Demo import ”dart:io”; void main() { print(“Enter your name :”); // prompt for user input String name = stdin.readLineSync(); // this is a synchronous method that reads user input print(“Hello Mr. ${name}”); print(“End of main”); } The readLineSync() is a synchronous method. This means that the execution of all instructions that follow the readLineSync() function call will be blocked till the readLineSync() method finishes execution. The stdin.readLineSync waits for input. It stops in its tracks and does not execute any further until it receives the user’s input. The above example will result in the following output − Enter your name : Tom // reads user input Hello Mr. Tom End of main In computing, we say something is synchronous when it waits for an event to happen before continuing. A disadvantage in this approach is that if a part of the code takes too long to execute, the subsequent blocks, though unrelated, will be blocked from executing. Consider a webserver that must respond to multiple requests for a resource. A synchronous execution model will block every other user’s request till it finishes processing the current request. In such a case, like that of a web server, every request must be independent of the others. This means, the webserver should not wait for the current request to finish executing before it responds to request from other users. Simply put, it should accept requests from new users before necessarily completing the requests of previous users. This is termed as asynchronous. Asynchronous programming basically means no waiting or non-blocking programming model. The dart:async package facilitates implementing asynchronous programming blocks in a Dart script. Example The following example better illustrates the functioning of an asynchronous block. Step 1 − Create a contact.txt file as given below and save it in the data folder in the current project. 1, Tom 2, John 3, Tim 4, Jane Step 2 − Write a program which will read the file without blocking other parts of the application. import “dart:async”; import “dart:io”; void main(){ File file = new File( Directory.current.path+”\data\contact.txt”); Future<String> f = file.readAsString(); // returns a futrue, this is Async method f.then((data)=>print(data)); // once file is read , call back method is invoked print(“End of main”); // this get printed first, showing fileReading is non blocking or async } The output of this program will be as follows − End of main 1, Tom 2, John 3, Tim 4, Jan The “end of main” executes first while the script continues reading the file. The Future class, part of dart:async, is used for getting the result of a computation after an asynchronous task has completed. This Future value is then used to do something after the computation finishes. Once the read operation is completed, the execution control is transferred within “then()”. This is because the reading operation can take more time and so it doesn’t want to block other part of program. Dart Future The Dart community defines a Future as “a means for getting a value sometime in the future.” Simply put, Future objects are a mechanism to represent values returned by an expression whose execution will complete at a later point in time. Several of Dart’s built-in classes return a Future when an asynchronous method is called. Dart is a single-threaded programming language. If any code blocks the thread of execution (for example, by waiting for a time-consuming operation or blocking on I/O), the program effectively freezes. Asynchronous operations let your program run without getting blocked. Dart uses Future objects to represent asynchronous operations. Print Page Previous Next Advertisements ”;