Add Your Heading Text Here

For every programming language, there are certain rules are predefined for writing programs.

Dart also have its own syntax or structure for writing programs

A program written in dart may be consist of

  • Operator
  • Variables
  • Functions
  • Expressions
  • Class
  • Objects
  • Constructors
  • Libraries
  • Typedef
  • Data Structures represented as Collections/Generics
  • Comments

We will understand each and every topic of dart through step by step to have command over dart language and smoother our experience of learning dart syntax.

Let’s have a basic hello world example in dart,

Helloworld.dart file

main() {
print(“Hello World”);
}

In Dart, The execution of your program starts with main() function. main() is the entry point function which is mandatory in a dart program.

Any dart code written in a file must have extension have “.dart”. In above example, we have created a new file named as Helloworld with .dart extension and written our program inside it.

With the .dart extension file we can identify that the particular file has code written in the dart language.

Similarly, there are other syntactical concepts or rules that will help you to understand the dart syntax easily.

Let’s have intro with each dart syntactical rules one by one.

White-spaces and Line Breaks

We can freely use white-spaces, tabs and new lines as much as we want in our programs and we are able to format our code because Dart ignores spaces, tabs and newlines that appear in code.

Dart is case sensitive

Dart is case sensitive language, so it differentiates lowercase and uppercase characters in your program.

Statements ends with a semicolon

In dart code, every statement must end with semicolon (;). We can write multiple statements in a single line, but we need to add semicolon between them.

Comments in Dart

Comments are useful for any program. It improves readability of our program. They are used to notate the particular code-block or function or class is used for what purpose or helps other programmers to understand our code by reading comments.

In dart, two types of comment are there:

  • Single Line Comment : Any text between // is comment.
  • Multi Line Comment : Any text between /* */ is multiline comment.

For ex :

// This is example of single line comment.

/* Line 1
Line 2 –>This is example of multiline comment.
Line 3 */

Dart syntax is conventional programming syntax like C, C++ and java. Hence, easier to learn and understand. So, you can have command over the dart language in very short time. So, make yourself ready to have a smoother journey for learning an object oriented dart programming language.

Feel free to ask your questions in the comment section. Keep reading and commenting your suggestions to make toastguyz a better site to learn different programming languages.

Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
KALAIVANAN.K
KALAIVANAN.K
3 years ago

Please upload some question and answer for interview and learning purpose

Show Buttons
Hide Buttons