Hello Friends,
This is 2nd blog on this series #30DaysOfFlutter.
In the last blog we learn about how to install/setup the flutter. You can check my previous blog if you had not done it yet -
https://bigakash.blogspot.com/2021/02/1st-day-with-flutter-hello-flutter.html
I know I am not able to post blog regularly but I will try now to be regular for this series.
So Lets Gets Start!!
As we know for flutter development the programming language used is #Dart which is made by Google, so in this post we will dive into dart language and try to get familiar with it so that we can start writing flutter applications.
Dart is an object oriented programming language and its syntax is very much smilar to java or other object oriented langauge. We will see here some important concepts/features/syntax that differentiate it with other languages -
1. Main function - Each app must have a top level main function as shown below -
// Entry point of the application void main() { var name = 'XYZ'; // Declare and initialize a string variable. print(name); // Display name on console. }
2. Functions - Function are usually created in following way -
Integer sun(Integer a, Integer b) { return a+b; }You just need to define return type, function name and function body to create a function. In Dart inserting the return type is even not required as it can use type inference to infer the return type.
/// Two optional parameters - firstName & lastName void printHelloWorld({String firstName, String lastName}) { print(...) }
printHelloWorld(firstName: 'ABCD', lastName: 'EFGH');
String printMessage(String firstName, String lastNAme, [String message]) { var text = 'Hello $firstName $lastNAme';
if (message != null) { text = '$result $message!!';
} return text;
}
printMessage('Akash', 'Bisariya'); // Hello Akash Bisariya
printMessage('Akash', 'Bisariya', 'Good evening') // Hello Akash Bisariya GoodEvening!!
var name = 'XYZ';
- numbers - It's further divided into 2 types - integers(int) & doubles(double)
- strings - You can use either single '' or double "" quotes to create string.
- booleans -
- lists (also known as arrays)
- sets
- maps
- runes (for expressing Unicode characters in a string such as laughing emojis)
- symbols (these are compile time constants)
class Person{ String name; String lastName; String this.age; Person(this.name, this.lastName); Person.newEntry(){this.age=0} }
var p1 = new Person(2, 2);
var p2 = new Person.newEntry();
class A extends object { ..... void printMessgae() { print("This is mixin class") } }
class B with A
{
....
}
Now you can use the 'printMessage' method with the object of class B.
You can only extend the 'Mixin' class with Object class.
So friends these are some features of Dart language, we will use these features when developing the Flutter applications later.
For more detailed review of Dart language you can use the following official Doc -
https://dart.dev/guides/language/language-tour
Thanks for reading. From next post we will start developing the Flutter application.
Thanks for sharing this nice information blogs. We are a flutter app development company in the USA.
ReplyDelete