Hey there, this Mahmoud Asan and welcome to my Dart programming language tutorial. Dart is the main programming language to develop cross platform mobile application using flutter framework. In this video tutorial, I will discuss the fundamental features of Dart programming language. If you know any other programming language, then you will find that is really easy to understand. So no more talking, let's begin. to minister Dart SDK in your system, please visit HTTPS and dot dot Dave. And here it will see that there is a get dirt link, just click that on that paynow. And here you will see there is three version Windows, Linux and Mac. So if you are using Windows, just follow the instructions to install that SDK in your system. As I use Mac, so I follow this MAC instruction, and I already installed Dart in my system. Currently, there is version 2.3, which I'm also using for this lesson as well. To write Dart code, you can use any editor but I personally prefer Visual Studio code editor. So if you want to use Visual Studio code editor you can install from this web base. And there is also Mac, Windows and Linux version. As I'm using Mac. So I installed the Mac version. Also, if you do not want to install the Dart SDK or the Visual Studio code editor in your system, you just want to check out Dart by just typing the code in a web editor, you can just use that Dart bet. So the address is Dart pad dot dartlang dot o RG. Here, you will see this interface. And for example, here is a main function. And suppose here, I write print HelloWorld. One and I just click Run, and you do it show, compile the program and show the output in the right side window. So if you want, you can also use this dot pet but I personally prefer to use Visual Studio code editor and run Dart code in the system. So currently, I opened my Visual Studio code editor and here you will see the Visual Studio code editor. And to highlight the syntax, you should install a dart extension to install that extension in the Visual Studio code editor, you have to click View then here you will see extension, just click on it. And here. If you search Dart, you will see dot 3.1 point zero there is an extension which I already installed. So if you are using Visual Studio code editor, you just find out this Dart extension and click Install and it will be installed in your Visual Studio code editor. And then if you click View Explorer, then you will see this interface as well. So currently, I created this playground dot d, a RT. So Dart code extension is de RT. So I created this playground dot Dart file in my dekstop demo directory, where I will write some code and execute in the terminal. So if you do not see any terminal window in Visual Studio code editor, just click terminal, and then click new terminal. So here, we will get the current directory location automatically. So if I want to run this playground dot Dart, so what I have to type da, RT Dart and then the file name, so playground dot Dart In my case, and if I click Run, I can see the output of the program here. So I don't need to open this terminal window. Separately, I just you get I just can use this built in Terminal feature in Visual Studio code editor. Dark Dart is a static type programming language, it is also a compiled programming language. So it static type means if you define a variable as a string, you cannot assign other values like integer or double on that distinct type variable. Though there is an exception like there is a type called dynamic which you can use to store any kind of values. I will discuss that on later. Another thing is that that supports two type of compilation, one is called A or D or a ahead of time and other is called j it or just in time compilation. So when we want to run a dart program, we have to compile it and then run but it happens automatically. So when we write a dart program and we just run it automatically complex on the fly and this is called just in time compilation and when we deploy our final product, then it will be compiled as a ot or a doc term time compilation with some optimization. Let's write a dart program. So every Dart program is starts with a with the main function. So let's write a main function void main. So your main is a function. And what means this function returns nothing. If you want, we can avoid this void. So it is optional. So that means if there is no return type that is called this function does not return anything. So let's define a variable. So I type for first name, and here I assign My name Muhammad. And then suppose I want to define another variable last name. So in this case, I will type string last name. Awesome. And now I want to print this so first name, then last name. So if I are here, I have to put a plus sign for a string concatenation. And if I want to run this program, I have to type dot playground or TRT Harry here you will see the output Muhammad is paste our son. So what does it happen in here. So the first line number two, here I define a variable using the var keyword. So var means a variable, and the variable name is first name, where I have assigned Muhammad as the fellow. So when you define a variable like this way, Dart compiler automatically guessed that this is a string type very veloz, because and this is called type in for inference. And in the second type, second line, the third line, we define the variable as a string type and which we mentioned it in the before. So if you defined variable like this word that is string last, and you cannot assign other fields, like if I type two, it will show an error. But in the fastest if I type two here, it will not show an error in here, because in that case, it will understand that this is a integer value. So you have to remember this thing in Dart programming language that it supports both type inference and is statically typed defined. So when we type Dart playground or DRT theory, just in time compilation happens. So this code will compile on the fly, and then it will run and we can see the output in that time, you know, if there will be an arrow, we can see that arrow also in here. Another thing is that all the built in Dart libraries, like a built in types collection and other core functionality for every Dart program basically, is defined in a package that is called Dart door, colon core package. So if you want to input you have to type this import, then single core Dart colon, then core packages. But the thing is that if I run this program, again, nothing will be changed, it will run as usual. But the thing is that this Dart coloane core pack is automatically imported. So for this case are normal cases, we do not need to import this Dart coloane core package, it will be imported in every Dart program automatically. So let's write another program in this program, we want to take input from user so for this input output operation, we have to import a library that is called IO libraries. So I have to import then Dart colon IO. And now let's write a main function. And here I want to fast show user that you have to type your name. So I have to write a code like a standard out dot write line. And here I will write what is your name and then a question mark, and then I will take the input from user so for this reason, I will type a string name and then a standard in dot rate line sync. And then I will print that name so my name is dollar name. So let's run this program first. So, you see in the screen vision, what is your name if I type ma mod Asa you will be seeing that it is showing my name is Mahmoud arson. So basically this is standard out and a standard in this library is defined in this dark colon IO packet. So the first line we are showing you that that by writing standard out dot write line that means if this line is shown in the terminal, then in this line is standard in that red line saying this when other program found this line, it will wait for the user to given input, so, when we get the input from user, we assign that variable which is a string in this name variable and finally, we just using the built in print method or paint function to output the name in that terminal. And here it will seen within the A string we are using $1 sign and the variable name. So, this is called a string interpolation. So, within the string, we change a variable with the relative Hello, we can write common in three separate or in dark tip in a dark program. So, if you want to write a comment in line then you have to use to forward slash that is called inline comment. If you want to write block comment, then you have to use forward slash star and you have to in the comment using another a star and forward slash. so here we can write multiple line of comment. Another comment is three forward slash that is called documentation. So that will be used as a document of for your program. There are two type programming languages one is called a strongly typed and other is called dynamic type. So in a strongly typed programming language like c++ or Java or Swift, that type of a variable is known at compile time. And another type programming language that is called dynamic type like Python, Ruby or Java escape in these programming languages, that type of a variable is known at runtime. So in Dart programming language, there are five basic type like int, double A string, bool, and dynamic. These four types are fundamental type and dynamic is a dynamic type, that means we can change the valeu at runtime with different time fellows. So in this example, let's define a variable. So int for integer amount one is the variable name where we have sn 100. Then in the second line, we have defined var amount to 200. So in this case, the by using the var keyword we define a variable amount to so as it is 200, that is an integer value. So the Dart compiler automatically knows, knows that that this is a integer value, an integer variable. So Dart compiler make this amount to an integer. So next time, if we, as an other video, like double or easting, in this amount, it will show an error. And in the third line, we have just been this amount one and among two, then we define another variable using double and put a double Hello. And then in the second cases, we have defined the double variable but using the var keyword, so the variable value type will be determined at the compile time, then you also print that value as well. Then we define another variable name one, which is a string type we define in by mentioning a string. And in that second cases we using we define name two as a string variable using var keyword, but here the type inference occurred. Here we define Is it true one using the bulkier dotnet. This is a Boolean type variable where we have assigned true, this is a boolean value and then using the var keyword, we define another variable is it true to where we define false value, which is also a Boolean fellow. So both of these variable are Boolean type. And finally, we define a variable width variable. And where we have used the key we use the keyword dynamic. So this week variable is a dynamic type variable. So the valeu value type can be defined at the runtime. So at the first time, we have sn 100. And the second type, we have assigned Dart programming, which is a string and the first time it was a integer. So let's run this program we see that this program is run perfectly well. So, here we see that amount, one 100 amount to 200 this line, this pin line is printed in here, then we printed the floating point veloz using this line print. So we are seeing that this veloz is also printed correctly. Here we are using this My name is this thing is also printed in here and we can say this true and false. This two variable the Boolean type variable values are also painted in here perfectly well. And finally this dynamic type week variable which we have sn 100 it is printed in here. And the next time we change the value of this week variable as a string type ways we have seen that this is also printing correctly that means this week variable which is dynamic type, we can assign any type of Hello at any time. So this is the fundamental art imagery type in Dart programming language and one thing you have to remember that Dart is an object oriented programming language and everything is object in here, even the novel type. So now type means if we assign here week variable and just put Now that means there is nothing, and if I just type brain to week variable in this case, and let's try to run this program. And you see it is showing now so even this narrative is also an object. So everything is object in Dart programming language, this integer Veilleux this variable, everything is objective in this function is also an object, which is a subtype of the function class. We can define a string variable using single quotes or double quotes. So if we start defining a string using single core, you have to in that listing using single code as well, the same rule is applied for double quotes as well. So here is one is define a string variable using single quote and x two is defined using double quotes. In the s3 variable, we using a single quote and we also want that there is an apostrophe within the each keyword. So in this case, we have to use a backward slash to separate this single core within the A string. But if we are just using this double core to define a string, we can just replace this special character by just single code. And finally, if you want to define a Royston, roistering mean if there is a special character that is newline character suppose, it will not be evaluated. So, to define a raw string, you have to just put a R in front of the string. So, let's run this program. You see that single core This is things printed double quote listing is also printed. And here as you see that this apostrophe is showing here nicely also for the h4 variable as well and in the final case, the roys thing, you see this newline character is not evaluated because it is defined as roistering by using the R in front of the A string is the interpolation means to replace a variables value actual value within a string. So here we have defined a variable age where we have assigned 35 an integer Hello, and in the second a string variable we replace this age of variables valeu within the string by using this dollar sign so that means when you want to interpolate in a string, just use the dollar sign in front of the variable name within a string. So if we run this program, we see the output is showing correctly that my age is 35. We can define multi line string in Dart programming language using either three single quotes and ending with three single quotes or is starting with three double quarter India with three double quotes if I run this program, you'll see it issuing the multi line string in the terminal type conversion isn't very important topic in any programming language, sometimes we we need to convert a string to an integer and sometimes we need to convert an integer to a string to convert an A string to an integer value you can use the parse method of int object so here we are passing and is string one and this method part will convert this string one to an integer one and sn that value in this one variable. In the next line, we are using the built in air sac function to verify there. So here we are verifying that if one equal to in desert one, if it is not true, then it will show an error in the terminal. Similarly, we want to convert an instinct to data Well, we can use the parse method defined in that devil object. So let's run this program you will see there is no problem no error issuing that mean this parsing occurred correctly, but if we want to change the easting like this is string that is known known in desert Villa within this scheme then what happened let's write this program, you see it is showing an arrow that this person has tried to convert this easting to and read extent number, but it is it found that they are these str characters. So that means it cannot convert this str to N in teaser Veilleux there. So it will be thrown an E roll and this exception is called format exception. So you have to make sure that if you want to convert an integer or double valeu is string Veilleux to an integer or double primitive value then you have that st with that integer or double Hello Similarly, if we want to convert from integer to a string we can use that here 1.2 string method. So, that means, as I said before that everything in Dart programming language is an object. So that means here the numeral will one is also an object. So, we can use this two string method of that object. So, here we are typing 1.2 string, and we are converting this integer value to an A string value and sn this in one as a string variable. And in later we also using this pie veloz that is a double Veilleux to add a string, so here we have to use to string as fixed to so here basically we want to convert this for floating point number to two fixed point floating point numbers. So let's run this program. And you see there is no error. So that means this one integer is converted to a string, which we are verifying in here, by putting single court outside of one that means it's an E string, and it inserted correctly. Similarly, here, we converted this double of Halo two to fix point double his string. So, and we are verifying here that if this is as a string with two fixed point on fixed point number, and we found that yes, it is also inserted correctly in here. So that means 3.1 point four now is in a string value. So this is how we can convert any type to any type in Dart programming language. When we define a variable, we can define that variable as a constant type that means during the runtime, we cannot change the value of that variable. So to define a variable as constant in Dart programming language, we have to use the keyword cost. So here we have defined a variable a const, num and this is an integer constant, because there I have put is zero which an integer so by type in foreign the compiler will make this variable as integer constant. Similarly, a const bool is a Boolean constant, and a consisting is an int is a string constant, then we are printing these three variables here and also the next three line we are checking the runtime type, that means what type the compile created during the runtime. So let's run this program, you see where we are seeing zero through a course a string, and that type is int bool, and a string. So, this is how we can define constant type in our programming language. Suppose we define a variable like int, and now and did not assign any value within this variable, if we just use the print function, and try to print the value of this noun variable. Let's run this program and see what is shown in that terminology showing there there is now that means there is no value assigned in this variable. So you have to keep in mind that if you define a variable or object, but did not assign any very values on it, that means that they're empty. So, it is it contains the null object, we can also externally use null in this case, so if I run this program, again, you will see there is no chance. So that means if we did not explicitly assign now value within a variable, it automatically assigned if there is no real value assigned to this variable. If you know other programming languages like JavaScript, c++, swift or Python, all the standard operators will work in Dart programming language. So for example, if you want to add to veloz, you can just use the plus sign for negative minus you can use minus sign for if you want to see that if there is any remainder or not you can use the modulus operator that is also called percentage operator in some programming language. And if you want to take relational data like if two values are equal or not, for example, here using this if logic we are checking that if num equal to zero or not, then print zero a for not equal to you can use not equal to this operator and for greater than or equal to you can use this greater than an equal sign and less than an equal sign for less than or equal to operator. If you want to use any short term shortcut valeu like for example if for here, we are using num multiplication equal to two it means that I want to assign num equal to num multiply by two. For example, here we are using the shortcut Veilleux. So, we put this multiplication vilo in here in front of the equal sign and and then we are passing to that mean this is inom equal to num multiply by two similar t thing you can use using the plus or minus like that. And a dart programming language also support unary operator that means you can if you use c++ Java or JavaScript you can use this unary operator like plus plus num This means that increment now, hello one by one, you can This is called post increment pre increment and this is called post increment, post increment both are unary operator and you can also use another shortcut virulite plus equal one similar similar to this unary operator. And for logical operator you can use this double ampersand sign so that means this logical and and for logical or you can use this double bar sign. So in Python we use this we use only and and or the physical the English keyword like and, and and or in Python but in in Java escape in Dart we can use this logical and and logical OR operator to make to condition based in within an if statement. So here we are writing a code like if num greater than 200 and num less than 200 t then print 200 to 202. So the here we can use the logical AND operator n in this case, both of this part and this part should be true to make this thing happen. For not equal to operator, we can just use this sign and then equal sign. So if I run this program, you will see everything is showing correctly when the terminal now our operator is one of the important operator in Dart programming language. Basically, this kind of operator is existed in many modern programming languages like swift kotlin. And in Dart, there are three variation of this operator. So let's discuss. So suppose we want to define a class. So in this class, now, there is a property we declared that is another num and where we have assigned 10. And let's define the main function. So here, I want to create an object of this class num. So bar n equal to num. So to create object of a class in Dart programming language, you just have to use the class name and the parentheses, then the object will be automatically created. So an instance of this num class is created an SN in this variable that is n. So n is an object of num class. Let's define another variable. So what we actually want, we want to assign this value in this number variable. Suppose this kind of Veilleux comes from another area, suppose we are using an API from this API, we get this kind of a JSON object and the JSON object, maybe there exists a variable and we want to get that number, so we have to make sure that this in object is not null. So how we do that, normally what we write if and not equal to null, then number equal to n dot num and just print the number. So normally, it's a common programming practice that we check that if the object is not now then exhale the object properties like it here. So, if I run this program, Dart playground you see it is working perfectly. Suppose this in object is not we remove this num, last name and if I run this program, again, you see it is showing this number has a null object. So there is nothing basically, when this inner object is now this thing will not exist, but if I just remove this if worked, and if I run this program again, you see, now there is an error thrown that is no such method error. So basically, we are excesses in dot num, but n is now that's why it will throw an error and the program will terminate in here. So there is a shortcut in Dart programming language language using that we can ever this if statement, so what we have to write we just To write, instead of n dot num, we have to write in a question mark, then dot then num. So if I run this program again, you'll see in this case it is showing nothing because there is no no object in object is now that's why this thing is not one and number equals now that is shown in here. And if there is an object, suppose we put in the, we create an object in here, the instance of num plus and if I run this program, again, you see now it is showing 10. So the number is 10. So basically, this knowledge our operator means that if there is an object, so if n is an object, and if the object property now is accessible, then just do it. So that means if n is an object, and if n is an invalid object, then x is the property named now and assign the value from num to here. But if n is not an object, if n is a null object, then just escaped this. There is another variation of this Nol our operator. So in case if this is not a valid object, there, there is nothing happened in here, right, the number will remain null, as it is defined, but what we want if the an object is now we want to default Hello, happy to be SME number. So how we can do that there are shortcut way to do that is you use a double question mark and assign a default value for example, we want to default value zero. So let's save this program and run again. So now, you'll see that when we run this program, that number is printing as zero that means when this part is now then this part will be executed. But if we just again, put this number here, and if I run this program again, then you see that 10 is printed, so that means na n is a valid object that has a property of now. So that value is sn in here, but in case n is a is not a valid object, then in that case, the default video zero will be so in number. That third variation of this nonlinear operator is like this. Suppose we define a variable number now it is not if I just print this number, and save this program and run. You see it issuing now. But what do we want that we want to make a condition like if the variable or object is null, we want to assign a default value. So what we can do that we just use double question mark, then a equals sign all together and put a default Hello if I run this program again, you'll see now issuing 100, if I run this program, after the first point is statement, you'll see the number 100 is showing in the second case as well. So here it is happening is that the when the number is not a very top date, that means the number is now then this 100 will be assigned in this variable and that is permanent, okay. So, you have to keep in keep mine in this tree variation of the knowledge or operator because if you do not check now, sometimes your program may care. So, if you know this another operator and you can, if you can use it wisely, then it can save in many cases in your program. There is another operator called ternary operator in Java escape c c++, Java. So that operate is also existed in Dart programming language. So for example, here we define a program int x equals 100 and var result equals x remainder two equal to zero. So, that means if we want to define this 100 I mean the value of x by two. So, if there is a reminder and if the remainder is zero, then pin this event, but if the remainder is not zero, then paint or so, in the next time we are printing the result. So, if I run this program, you see in this case, it is printing even because x equals 100, which is divided which is reminded by two and there is no remainder. So that means this condition met and fast part of the of this ternary operator is executed but if I just make it suppose 101 and run this program again. You see now this condition is not met. That's Why this odd is printed. There is a type test operator in Dart programming languages. For example, let's define a variable integer x equals 100. Or maybe var x equals 100. So we want to know that if What if x is an integer type, then just print something. So how we can write that program. So we have to type if, then x is int, then print integer. So let's save this program and run. You'll see, as this condition is true, that means we want to check that whether the variable of x is integer type. That's why we have written that if x is in that means if x is an integer, then pain InDesign and it is true. But if we change the value to suppose a double value, and if I run this program again, then this condition is not true. That's why we did not see any integer is printed in that terminal. Sometimes we want to write a program with some condition that means if a certain condition is true, then do something and if certain condition is false, then don't do something. So in our Dart programming language, we can write conditional code using if else if and else operators. So that means, here let's define a program first we define a variable integer number equals 100. So then, we are using the remainder operator we are checking that if this condition is true, that means if this number is divided by two with no dividend that means equal to zero, then print even if not, then if it is divided by three, then print OT and E. In other cases, that means if this false condition is not true, second condition is not true, there are default cases then paled confused, so let's run this program first. So, here it is showing even then I am I put here 90 and it is showing even again, so if I put here 91 it is showing one fused. So, in this scenario, the first condition when made then the second and third condition that means elsif and his block will not be executed. But if this block is not true, then the then the program will check this block if it is not true, then it will check the default block. So this is how we can write a feels if and else condition in Dart program. There is another way we can write if is a statement in Dart programming language. And in this case, we have to use this switch statement. So basically switch wars similar like if this condition. So here we are defining a variable number where we have sn vadose zero, and then in the switch statement within the parenthesis, we are checking this number variable. And within the curly braces, this is the body of this switch statement, we are checking that if the value of this variable is zero, then pain this and break, then break from this switch statement. In case this condition is not true, then check this condition if case equals one, then do this thing and break from this which is admin. If no none of the case is true, then just a do that default condition. So here, let's run this program. It is showing even because this condition met so if I put here one and save this program and run, you see now it is showing or because this condition is not met, that's why this condition met. That's why it is showing here. But in case if I put different Pedro and run this program, it is showing confused because zero and one is not met, this condition is not met. That's why the default condition is executed. looping means we want to execute a task for a finit number of time repeatedly. So there are basically five kinds of loop in Dart programming language. So the first loop is the standard for loop is 10 dot for loop. It's similar like in JavaScript. So for example, we want to print one to 10. So how we can do that, let's write F is standard for loop. So you have to pass die for then within parenthesis. let's declare a variable var i equals one, then semi colon. This is the first part that are initialized part. Then we write the condition I there's n equals two Yeah, so, as long as i less than or equals to 10 then run this loop and then the increment or decrement part. So, here I have written pre increment plus plus i. So, these are the increment or decrement parts. So, that means, the when the this program is run this part will be executed first then it will check the condition in here and after and then the body will be executed then the program goes to here and increment the value of i and then check the condition again if the condition is true then it will break from the loop otherwise it will continue the loop. So, if I just put print I and run this program you see it between one to 10 So, this is the standard for loop there is another for loop that is called for in loop Suppose, we have an error so far numbers we define a variable number and using the square bracket and it is a shortcut that means it's an error we define some variables within this array 123 and we want to print all of this veloz So, using foreign loop we can do it easily. So, here we are writing for the N var in in numbers and within the body print and so, here it is meaning that for a bar in in number, so, the value of n will be first time one second time two and time three it will be executed as long as the ad a contains some Pharaohs. So, if I run this program you see the string 123 So, this is the standard foreign loop if we want to use this array using the standard for loop we can do that also for example for var i equals zero I less then numbers dot length then plus plus i and here print numbers Hi. So, if I run this program you see in this case one two threes again printed because we are using the standard for loop there is another loop that is called for each loop. So basically for each and higher order function. So for example here like before we have defined an array with some integer values. So we want to print the each of these video right so we can do that using number dot for each and then here we have to define a function. So for example, we want to access each of these vedo right. So we can do that like in and then we can use an arrow function, what is the arrow function I will discuss later, we can also use a normal function here as well, but in this case, it's looks elegant to use arrow function, and we just write code like this way if I run this program again you see it is showing or sorry, here I have the ID Mr. It has to be it has to be in so if I run this program, you see 123 is printing. So basically this for each is an higher order function because it takes another function as a parameter, this full thing is actually a function but we have written in the short from that is called arrow function. I will discuss this thing in later in the function part but just keep in mind that there is another way for looping especially in an array or object using the for each loop. If you think this arrow function looks a bit complicated for you, you can do another thing you can define another function like board, print num and here is a parameter and just print this now. And now instead of this arrow function just to pass this non function print down function reference and if I run this program again you'll see the same output 123 basically we are passing this function as a parameter of this for each higher order function. There is another rule or the number four types of loops called while loop suppose we have defined a variable num equals five and we want to print the value of num unless it is zero so we have to write while then the condition within parenthesis that num get at the zero so as long as num greater than zero, execute the body and then we fast printing the Hello have now and then we decrease the value of num by one if I run this program you see, it is doing nothing because I did not save. So, let's run again then you see that it is showing 54321 there is another variation of this while loop. So, instead of using the condition before we have to write do in here and after the body called the basis you can write the condition the while condition after this curly braces. So, if I run this program again you'll see the same output 54321 if within a loop for a certain condition, we want to terminate the loop we can do that do this by using break statements. So, here in this loop, this loop will run 10 times apart here we have written a condition if i greater than five then just break otherwise print I if I run this program, you see zero to five is printed and then when the value of i become see that is the it is greater than five then this break is statement executed and the loop is terminated. So this is how we can use break current break statement in any loop to terminate the loop. Suppose we want to write a program to print the odd numbers or even number so in our case, we want to print the odd number. So we have written a loop a standard for loop this loop will run 110 times and here we have written a condition if I modulus two equal to zero that means if the DV after the division if there is no remainder, that means zero, then continue here continue his statement mean that don't go the remaining statement just continue from the loop from here if I run this program, you'll see it is showing the odd numbers from the range zero to 10. So here you will have seen that 13579 so the first time i equals zero and zero less than 10. So zero remainder two equal to zero there. So this condition made true so the container is statement executed and the end the loop goes to here. So I becomes one. And then the condition is again checking if s one is less than 10. And within the body if one reminder to equal to zero, it is not true. That's why this condition did did not meet for the second time. That's why we have seen this one is printing in here. So this is how this container a statement was within a for loop. There are three built in collection type in Dart programming language, least sate and map. So list basically is an ordered collection of halos. So it is in some programming language is called array, but in Dart programming language, it is called least. So suppose we want to define a list. And we can do that using list class. So when we define list Li St. And then we define a variable so that means this names is an object of least class. And here using the shortcut way that is means using the square bracket, we can define some way to like jack, and Jill. So these two are a string items within this list. So if we want to access each of these value, we can do that. So basically in list, the first item is indexed in zero The second item is one and this is how it goes. So if I want to access the first item from this list, we have to write brain names then square bracket zero if I run this program, you'll see it is when jack because jack is a state within the position or index at zero if I print one and run the program again, in this case it is showing in jail. If we want to know the number of elements existed in the list, we can use the length property of the list object. So here we are painting name dot length, so let's run the program. You'll see ad showing two that means this list object names contents, two items. Instead of list if I just put var here and If I run this program, you'll see it was in this case, the compiler. By type inference will know that this names list is a string type list item. So if I put my cursor in here you see it is showing list. angle bracket is string. That means this next is a list. And it is known in beider type inference. If we want to access each of this item, we can do that by using any for loop. But normally in this case, you can use the for in loop so far, bar in in names and print. And so if I run this program, you'll see jack and Jerry's printed. If I want to use mixed item, that means some videos will be staying some yellow, maybe double some bills, maybe in desert, we can do that as well. So 10 100.1. And if I run this program, you'll see each of these video is printed. And if I put my cursor in here, you see nowadays showing list and within angle bracket object. But if we want that this list should be a string type, we can do that by defining the instance, represent this bar by list and within angle bracket we define is a string. In that case, if you put any value other than a string, it will shown and erode. So this is a statically typed names list. That means you cannot put other type instead of a string if I run this program. You'll see it issuing now jack and do so for a statically typed list, you can just put a angle bracket after the keyword list and put that type in here. This list is a mutable type. So that means if we want to change the value of the index one we can do that. So names one, instead of zero, we type like Mark and if I run this program, you will see now it is showing jack and mark so the value is replaced with a new video. But if we want to define each of these various constant that when we do not want to change it at runtime, we can do that easily just by just putting the const keyword before the square bracket. If I use this program now and run it you see it is showing an arrow that unsupported operation because you cannot change a constant value at runtime. If I remove this part, clear the skin and run the program again. You see there is no error in that case. Suppose we want to copy a list to another list. We can how we can do that. For example, let's define another list, or just have our names too. And if I just assign these names, one, I mean that's nice Bart. And if we accept this name store and run this program, you'll see we can still access the video jack and jill. But basically when you assign a object like list within another object, it's actually not copied instead this names to accessing the names veloz. So suppose if I change the value of names, after assigning these, suppose I change the value of names one equal to mark. And if I run this program again, you see we get that updated Hello, we are changing that of Hello repel the Veilleux of GL by Mark in the nails variable. And we are looping the names to variable but we can still see this updated video like jack and Martha This is not a select. This is not actually copying rather, both names to ns pointing the same list of items. So instead of doing that, if we want to really grown the list, what we can do that is using our spread operator in Dart 2.3 we can do that easily. So here we just put a square bracket and then three dot and then the first variable name so names one. So if I just run this program again. You'll see in this case when we looping names two, we are actually getting the old value jack and jill basically in this case names two and names does not point to the same list of item. Both names and names. Two are totally different items. list items. So this spread operator is similar like JavaScript, I first saw this three.is spread operator in JavaScript and this three.or a spread operator is introduced in Dart 2.3. said in Dart programming language is an unordered collection of unique items. And dark support for set is provided by set literals and the set type. So suppose we're defining a set by var keyword var, hello James. And here we have to use the curly braces. And within curly braces, we want to put some string vedo. So we can type flu, Rhine, and then chloride to veloz. So these are basically unique IDs if I copied this flu right again after the comma, and if I loop this program, so for var x in Hello Jas and print x, and if I run this program, you see it is only showing floros, fluoride and chlorine. So this foreign if we put it two times, but it is actually stored one time, because by definition set is an unique collection of items. There is another way to define set, if you want to define an empty set, you cannot just put like the support, so you want to put an empty set, just remove this for loop and remove these curly braces, the IDs of these curly braces, if I just type print, hello jeans, run time type. And if I run this program, you'll see in this cases, we thought that it should be set a but instead it become a link hashmap type. So if you want to define a empty set, if you want to define the empty set, you must have to define the type name in here like you have to put if I just put a string here, within angle bracket. Now you'll see it issuing has set. So just empty curly braces means hash map, but when you are defining a type before the callable, then it does it become a hash set. And another way to define has said is like this, that set using the set keyword that means set class is in the same class, then you can also put this string thing in here, set a string and then if I put in names and curly braces, and if I check the names, runtime type, you'll see it is also has it so either way you can define an empty, has set in Dart programming language. in Dart programming language map basically, is a collection of key value pair of items in some programming language, like in Python, it is called dictionary. So let's define a map in Dart programming language. So here I have defined a map gift and that key of each of the identity is staying So here I have defined within single code fast, which by this key, we are putting Veilleux Petraeus then say again, Dart loves and feel the golden rings. If I want to access each of this item, we can do that easily like print gifts. And this is also on our data. And if we want to access any of this video, we have to use the key. So for example, here I am, I want to use the key fifth. And if I run this program, you see it is showing golden rings. So this is how we can create map in Dart programming language. Another thing is that you can also use integer value SK for example 213. And in this case, we also remove this faith and instead we just put one and run this program. You see, you see that it also was without any issue. If you want to define an empty set, or sorry, if you want to define an empty map you can do that using the map class. So here we are defining gift as a and we want to created an instance of map in here and assigning that gift. And now we want to add key value pairs by ourselves. We can do that by easily like gifts. Then within a square bracket we can put the key suppose here Fast as a key and the valeu suppose mango. And if I run this program gifts fast you see it works. So this is how we can create map in Dart programming language. Another way we can do that using curly braces, and they are we have to put the key and the value together. For example here fast and within after colon we have to put like mango love Hello then another key. So this basically key and this is the video so this two item becomes a key value pair as a one item within the map. So in the second key, we want to put another video like jack foot. And now we want if we want to access any of these video, like gifts. Second, and if I run this program, you see it issuing jackfruit so this is how we can create map in Dart programming language. in Dart programming language, each function is an object of class function where F is the capital letter. So let's define a function. For example, we want to defining a function as a square root which we can use to square any integer or num type any integer or double Hello. So, for this reason, we want the return type should be dynamic. So, when you define a function at the first first part, you have to define the type which it will return if there is this if a function does not return anything you can use void or you can escape the void which means it does not return anything. So in this case, we are putting dynamic then the function name is square, we also take any of Hello So, this function can take parameters. So if we want to, if you want the function take parameter we have to define that. So here we are defining our norms. So this function will take a parameter as num, and this function will return the num into num. So whatever we pass any valid integer or double Hello in this square function, it will multiply that by the same hello and return of Hello. So let's define another function, for example, void show output. And here, we take an A, define a variable as parameter bar message. So this function takes messages as parameter. And using the built in pin function, it will pin the messages in the terminal. So now let's call this function first show output. And within this function, we want to use this function square. so here we are typing a square. While we are putting two. If I run this program, you'll see it is showing four then we use the same statement, but in this case, we are putting 2.5 and let's run this program, you see now it is showing four and 6.25. As we define this function, this a score function is dynamic. So that means this function can return any type of non value like any type of integer or double of Hello. And another thing if I just type print and square this function name without parenthesis and runtime runtime type. And let's run this program. You'll see this is showing that this function is quite easy dynamic type. in Dart programming languages, there is a shortcut way to defining a function which is a one line if statement. So for example, here in Dart programming language you have to use the equal sign and greater than sign together to make a arrow This is called fat arrow and sometimes called fat arrow expression. So here we define a full function right that dynamic is square one now and within curly braces, we define a body we can make it we can make it shorter using arrow functions. So instead of this, just remove this arrow part and return part and just put a arrow here. So here what we are defining that dynamic is square varname, then arrow expression now multiply Nam, so when you write an arrow function like this way, the result of the valeu after the comma petitioner will automatically return. So if I save this program and run again, you'll see this program was as like before, a function that has no name or In short, you can call nameless function is called anonymous function in Dart programming language. In some other programming language, like in Python, it is called lambda, or in some programming language, it is called closer. So here, let's define a list with some string values of items. And we want to use the for each function of this list. So let's type list dot for each, these are higher order function, because for each function get can take other function as parameters. So within the body, we will define a anonymous function. So before defining an anonymous function in here, let's define a named function. So suppose I'm defining a function void, print F, which takes a parameter item, and just using the print built in function, it just print the value of the item variable in the screen. And here, we just want to pass this printf function as reference. So if I run this program, you'll see it issuing Apple bananas and orange. But in this case, or sometimes when you define a forest function with a shorthand function, then in many cases, computer programmers do not define a name function, instead, they prefer to use anonymous function within that places. So to do that, let's guard this part and remove the name function part and here remove this printf and put that thing in here. So, if I save this program, clear the screen and run the program again, you see it works. So that means this function is an anonymous function, because this function does not have any name. There are two types of parameters in function in the programming language like Python programming language. So one type of parameter is called positional parameter or positional argument. And the second type is called named parameter or named argument. So let's see the positional argument or positional parameter first. So here we are defining an arrow function which takes two parameter. So in this case, we are using the positional arguments. So here, num one is the first position nonprint the second for position, and we're just returning after combining the hell if I run this program, you will see it works it is showing for now, here, if you look carefully, you'll see that when we call this some method, we just passing the value and we expect that these two will be assigned in number one and these two will be as an int num two, because we are using the positional argument on our positional parameter, let's convert this function this arrow function to named parameter. So in that case, we have to use the curly braces here. So we want that this two parameter should be as named parameter and when I put curly braces in here, you see it is showing red color in here. So if I just remove this thing, and if I call sum, now you'll see that it is showing number one and number two, if I put num, for example, in this case, if I want to put num too fast, so I have right return num two colon then suppose four, and then I want to put num one, suppose two, if I save this program and run this, again, you see it is showing six. So when you are using named parameter, you have to use the name of the parameter when you are calling the function. And this basically works for not only arrow function, but also for a general function. Another interesting thing of named parameter is that by default named parameter is optional. And we can also mix positional parameter and named parameter together. For example, in this case, we want to change a bit. We want that the num two is only named parameter but the num one is positional parameter. And num two may be optional, right. So in this case, When we want to call these functions some, then we have to put the value as the first parameter. Suppose I am putting 10. And as this name parameter for this name parameter, I use the name num two. And suppose I put two. And if I run this program, you see it is showing 12. But I told before that when you define a variable sorry, when you define a parameter as named parameter by default that is optional. That means, if you do not provide any value for num two, it should work. Right. But it is crushing why we're defining this num two parameter as optional by defining these as a named parameter. But when there is no video, but we are still accessing these Veilleux. So, as this num to maybe optional, what we can do, we can write a conditional not not our operator like double colon zero. So, if I, if I change this modification in here, and if I run this program again, you'll see it is also showing an error because I think I have to put a parenthesis to give the priority and now if I run this program, again, you'll see there is no arrow. So, in this case, when we do not provide the named parameter of Hello, and in the function body, we are checking that whether num two is null or not if it is now then just pass the default value as zero otherwise, if there is any value just use there. So, if I again use this statement print and sum and here I put another Veilleux then two and num two. So, you see it is showing 10 and 12. If you want that, if no value is provided, we can use any default value. So, instead of using this, we can do a shortcut default value parameter. So here, after number two, we put a equal sign and put a default fellow. So if we change this function here, and if I run this program again, you'll see there is no error, because when there is no parameter, no value for num two parameter it is using the zero in here. So zero plus 10 that is 10. And when we pass any value like two then in this case the default value will not be used and 10 plus two will be 12. So, this is showing in here I told that by definition name parameter are optional, right. But if you are using a positional parameter, and you want to make any of them as optional that how you can do that. So for example, here we want to make this num two as optional, but this is a positional argument or positional parameter. So to make it optional, we just have to put a square bracket outside of the parameter and now this num to become optional. So, if I run this program, you'll see it issuing four and to set the first time we are passing two values and the second time we are passing one pillow. So in that case that Nam to become null. And here as we are using knowledge our operators so that default values zero will be used in the second case in object oriented programming class is a very important topic. Using class we can define our own custom type, we can encapsulate the related halos and related methods together. And when you define a class you can inherit to make some subclass Also, you can do some other thing like you can use polymorphism you can reuse your object oriented code for other purpose. So in Dart programming language, we can create a custom type using the class keyword. So let's define a class. So, here we are defining a class named Parson. So to define a class in dirt you have to use the keyword class then the class name and within curly braces, we are defining the body. So basically class is a blueprint for an actual object, this is not object This is we are defining the type that means we are defining a person class or person type. And later in the main function, we will use the other of this person class. So in this person class or blueprint, we want that a person should have a name, a person should have a just basic to type, okay. And now, let's define a method in here. So, when you define a function within a class that is called method. So, here we are defining a method point, this function or this method returns nothing and then show output the function name, which is called method them in the context of class. And this patter does not take any parameter and it just print the Hello of name and age. And now let's create an object. so here we can create object into Well, suppose we want to use this person name in here, so person class name in here and then person one and then Parson. So when you use the parentheses after the class name, basically it will instantiate an object and sn that object to this person one object variable, right. So if I just want to access this show output method, I can write person one dot show output, basically, it will print nothing, I mean to now, if we want to access this variable name and age, we can do that like person one dot name, suppose my name Muhammad and person one dot age, my suppose 35. So if I run this program, again, issuing more than 35 Now, let's create another person object. But before that, we want to use a constructor, which is called default constructor. So what is that, so let's define a constructor. So basically, constructor is also a method without any return type. So and in Dart programming language, you have to use that class them as constructor name. So, here we want to defining a constructor and constructor method is automatically called when you instantiate an object. So, here in this case, we want to pass two parameter is string name and the second parameter is optional int age and by default, it should be 18. If there is no ages provided, and as this name, parameter name, and the class properties name are same, to if you want to access the objects or instance, our field we in this case, we have to use that this keyword This means these objects name or this object age also we can call this using this we can also call the method defined within that class. So here we want to use this dot name equals name, and this dot age equals A so if any name and age is provided, when we create the instance of a class will pass the values and the various will be assigned the object or instance fields. So now, when we define the constructor, you see now it is showing an error because it expect that I have to pass at least one name. So here, I just past service ma mode. And after saving the program, if I run this program, it was a different mama than 18 because I did not pass any a that's why it is taking that default value, but if I pass any is like 35 you see now you're showing Mama 35. So this is called default constructor. Another shortcut oil to write a constructor basically constructor is using to assign some values when the class instance is created. If the parameter name is same as the properties or feel stem within the class, we can use the shortcut okay. So, instead of using this body, we can just use here these dot name and here these dot A's and a default value. So if I run this program, again, you see it works. And in case if I do not want to provide this 35 and run this program again, you will see it was again industry Mahmood 18. So if in your constructor other than initializing the values, you want to do something else, if there is no other thing you want to do within the constructor body, you can escape them curly braces part I only use this way to shortcut the constructor. Let's define another object. So, in this case I am going to using the var keyword and person two and I give the person I want to name jack and age is suppose 25. And let's Parson to and call the show output method. Let's clear the screen and respond the program. You see in the first case it is showing Mama 18 and the second case it is showing jack 25. So basically this person one and person two is totally different instance of the same class that is person class. And here as we are using var keyword, but in the right side after the equal sign we are using the person class so using the type inference the compiler, the compiler will automatically know that this person to bicycle an object of the person class other than default constructor, there is another constructor that is called named constructor. So when you define a constructor like this, where like the class name as the constructor, then this constructor will automatically called that is why it is called default constructor. But sometimes we may need to instantiate an object of a class with some different kinds of hellos right, then how we can do that. There is another way suppose we want to define a named constructor. If you define other constructor besides the default constructor that is called named constructor to define a name cost property, you have to use the class name. So here Parson then you have to put a dot and then the constructor name. So we want to name the constructor as guest. And here, we want to sn some veloz. So here name equal to guest and age equal to 18. Okay, so let's create another object var barsana tree, Parson and dot cased in this case, you see I am not passing any values. That's why it is not calling that default constructor. Instead it is I am calling the guest constructor and if I run this person three dot show output method and run this program. You see in the top cases it is showing guest and 18 for the person three object. So this is how we can create other constructor beside default constructor. Normally what happens when we define a variable either explicitly or within a class, we can change the value at any time if we want, right. But if we want that, we will define a field or properties or variable within a class. And that will be unchangeable after initializing, then we can do that by using the final keyword. So here we define a class class x capital X and within the class in the body, we are defining a variable named name. So and we are using the keyword final. And then we are defining another variable named age where we have assigned contain. And before defining the variable we are using the keyword static and cost. So I will discuss all of these three things final is static and static const. And then within the class default constructor, we are just assigning the Hello passing to the constructor in the named variable. So let's create an object so var x x capital F, and then pass the fairyloot check. And now if I print x dot name, and run this program, you'll see it issuing check. So suppose I want to change the value of name if dot name equals something is like Jill. And I want to print the x dot name again. Basically, it is showing that name can be used as a setter because it is final. So the Dart extension in this Visual Studio code editor can detect that error. But if I just remove this final thing and just use var name, and run this program, you'll see first time it is showing jet and the second time it is showing g so the key point here is that if you want to define any properties, as a constant, you can use the final keyword and using the default construct or when you ascend the hill. You cannot change the value after assigning EDA in the second time. So only faster you can assign the value using the default constructor or any named constructor, there is two ways to define a value when we defining a variable as constant one is using Final keyword and other is using const keyword when you are using const keyword that is a compile time constant, it cannot be changed any time at all at runtime, but when you are using Final keyword within a class, you can change it using the constructor. So this is possible at runtime. And if you want to use any cost constant video is in the constructor within a class you must have to put a static in front of debt cost hour in front of that cost variable. So, here we are using a steady cost India's 10 and if I want to access the value of a we can write brain x dot age and it will not work because this is a compile time constant and we are using ad in the class. And as this is a static variable, we have to use the class time to access the property and this is called class property. This name is called object property because this name is different for different object but the aesthetic property is same for all object or all instance, but there is a backup because it's a class property. So here you have to put the capital X dot age and if I run this program, you see dish 110. So, suppose I want to create another object for x suppose bar y equal to x and g and y brained brain print y dot name and you'll see that for x object and y object the name value is different part s this property is based on class. So, we have to access that property using the class name dot property and this is same for all instance. So the age 10 is is same for both X object and y object. If we want to use the cons and final outside of the class, we can also do this. So let's remove this class part and remove this thing and suppose we want to define to constant vadose. So final har name suppose the name is something Mahmoud. And in this case, you do not have to use the var because it is this name will be be a string by type inference and there's different other below cost name suppose age equal to 30 let's print name and print age and if I run this program after clearing that term, you know you see it worse and we cannot change any of this name equal to something else cannot possible also a is equal to something cannot possible it will be showing any error because here you see it is showing that name is a final variable and age is also a constant variable which cannot be re assigned. And in this case outside of the class both final and cost actually worth like same there is no difference. So, you can use anything a final or cost outside of that class. When we define a class and later we want to add some extra feature within the class, but that extra feature is not required for all the instance of the origin occur then we can use the class inheritance and in Dart program using the extend keyword you can inherit a class. So here we are defining a class of akel where there is two property model and here and in the default constructor when we pass a model and year. In this default constructor we are assigning that model Hello using these dot model will be in this model and these dot here the passing here will be sn in here. And within the default constructor body we are just printing the model and here nothing new and there is another method to output just it prints the model and yet if we want to use this here that's also okay. Basically this means that the instance which it is called now, we are defining another class class car and that inherit this vehicle class right by using the extend keyword. And here we are defining a new property that is called double price. And in this default constructor in the car constructor, what we are doing we are taking three parameter right is string dot a string model year and these dot Price here he here there is an interesting thing. So, the interesting thing is that this price is the new thing of this car, but these cars as inherit the vehicle, so, this model and here also existed within the car class. So, what we are doing we are when we create an instance of this car class, we are assigning the price villo directly in this variable using the d dot price. But for the model and year, we want to pass that variable halos using in the vehicle constructor and to do that in dirt, you have to use a colon operator after the parenthesis of the sub class default constructor and you have to use the super keyword and using super keyword you have to pause the video so here when we are calling this after column we're calling this super then within parentheses model and here this model and here will be passed to this constructor vehicle right. So, and in this car class, we are also defining a method show output and under show output, we want to call this method that means super cost method and here we are calling this super keyword we are using this super keyword then dot then the method name. So, basically super dot shortcut means we are calling this method the superclass method and then we are printing the this curse price. Now here we are creating an object car one equals car not vehicle object, we are getting a car one car object, we are passing accord as a model 2014 as the year and 150,000 as the price and then we are calling car one show output. So, if I run this program, you see it is showing aircore 2014 because when the instance of this card is created, then we are calling basically this car constructor and here we are passing trivial right ecore 2014 and 150,000. So, to accord will be in here 2014 will be here positional argument and 150,000 will be here and as we are using these dot price and there is a property name price as the same name. So, this 150,000 will be assigned as the price of this car. And after all on on the default constructor as we are calling super model here this echoed in 2014 will be passed to this vehicle and will be sn this model and a year and then when we call this car one dot show output he will say this method is called here we are calling the super method, superclass method show output where it will be printed model and year. So, you see here model and here is printed and then this price is printed in here. So we are seeing this price in here. So this is how we can inherit or extend a superclass to mean add to a subclass. Method overriding a suppose in a class there is a method and in the subclass it here in y class extend this Ace class, we want the same method to redefine that is called method overriding. If you want that other programmers know that this method is overriding, you can use an override annotation. So when you use an override in front of a method signature, that means the compiler will know that this method is overriding and in any case, there is no method of the original name, it will show an arrow that method does not override an inherited method. This is basically a safety feature in Dart programming language. When you overriding a method you will if you do not use the Add override keyword, it will not show an error. There is no issue for this. You will have to use override when you don't have control of superclass method implementation. Basically, the intent of the override notation is to care situation when a superclass renames a member and independent subclass which used to override the member code silently continue working with the superclass implementation. So the good practice is if you override a superclass method, you just use the Add override annotation. gators and setters are a spatial method that provide read and write access to an object properties. Normally each instance variable has an implicit Gator process setter if appropriate. But if you want you can create additional properties by implementing getters and setters using that gate and set keyword. So here we define a class rectangle where we are using de nom object so basically now means it's an It's a type and That that is inherited by the integer and double type. So, here we are defining num left top width and height so the value of left of width and height can be integer or double. And in the default constructor we are just assigning the veloz past and sn in the properties. Now we are defining two gators that is right and bottom and to setter for each of them. So, to defining a gator, we are defining a right Gator name right and use the gate keyword before the name and then we are providing the return type and here we are using an arrow function and it will what it will do if we call this right Gator will get left plus with these two variables data and we will get this value and if we want to make a setter we have to use the set keyword and setter name. So here it is right and we are passing any Veilleux noun valeu and we are putting the left value. So, using the arrow function what we are doing we are assigning left equals valeu minus with So, we have a we are passing a value right and what we are doing we are doing a customization. So we are we are missing that with Veilleux from the Halo and that sn in that Veilleux in the left variable within that class. Similarly, we are doing the same thing as for bottom and now we are creating an object rect using the rectangle class name and passing some veloz and then we're printing the reg dot left of Hello let's run this program we are seeing that the left value is three and then we are we are calling the getter method that is right so reg dot write equals 12. When we defining a method we have to use the paranthesis. But when we are using the getter or setter, we do not need to use any balances like when we want to access any getter, we just have to use the dot operator. And when we want to use a setter, we just call the setter name and the equal sign and in that case the value will be assigned as a setter. So here when we are calling rec dot right equals to L so that 12 comes in here and of helou minus cervello is 12. And it minus with a weight is here that is 20. So hello is 1212 minus 20 equals minus h so that's why when we are printing reg dot left, we are getting this minus eight output. So this is how we can define getter and setter in Dart programming language. Exception Handling eg a feature in a programming language by which we can know that if there is any runtime problem occurred or not. So indirect, if we want to use exception handling, we can use the throw try catch finally keyword. So suppose here we are defining a function must greater than zero. So this function, if it gets a value greater than zero, then there is no problem it will return the value but if it gets a value equal to zero less than zero, then it will throw an exception. And to throw an exception you have to use the throw keyword and the exception class name. And within the exception class, now you can provide a message you'll see that the method definition is swing showing above the cursor. If a function throws in exception, you have to catch that otherwise the program will terminate. So we defining another function late verify the failover where we can pass any value. And within the function we are defining a value verification variable where we'll SNF why send off Hello. So, as this math function must be greater than zero can throw an exception. So, we have to define this function within that try block. So, here in the try block we are using valeu verification equal mask greater than zero and we are passing the value. So, if there is an error occurred, then we are just printing the error by catching the error in here cares within the parent services we can catch any type of exception here and then in the finally block which is basically an optional block we are checking something like if this video verification is now because if In any case, if this mouse greater than zero function returns an error then that case this value verification will be not right by definition it is null and if it succeeds, then it will this variable will get the value. So in the finally block we are checking that if that is now that we are printing value is not accepted. Otherwise we are printing Hello verified and we're using the string interpolation we are passing the Hello So let's run this problem. You see in first cases it is showing valeu tin but when we in the second case when we are passing the halos zero in the first case it is printing below verified by 10. But in the second case it is this catch block basically captured this exception that value must be greater than zero you see this this message is printing in here, but after the exception word and then in the finally block we also captured the value I mean the message and here it is printed Veilleux is not accepted. Basically when you use the catch keyword and within the parenthesis you use any parameter like he basically handles all kinds of error but if your program has a specific type of error you can use the on keyword So, after the try block you have to use on then the exception name then if you have another type of arrow then you can use on and that exception name and sometimes anything else that is an exception you can use like this on exception catch e So, this is another pattern but normally I prefer or in most cases I use that try catch block or try catch finally block I normally do not use the on exception thing unless it is very important for the particular program. So I hope that this tutorial will help you to understand that programming language and you can able to dive deep in flutter framework. If you liked this video, please give it a thumbs up and if you have any questions please ask in that comment section. I also welcome you to visit my personal YouTube channel where I regularly publish programming related video tutorials. So thank you for watching and have a nice day