Dart by Google?
Dart 2 is statically typed.
With its combination of static and runtime checks, Dart has a sound type system, which guarantees that an expression of one type cannot produce a value of another type.
Even with type-safe Dart, you can annotate any variable with dynamic if you need the flexibility of a dynamic language. The dynamic type itself is static, but can contain any type at runtime. Of course, that removes many of the benefits of a type-safe language for that variable.

Every Dart app has a main() function. To display’s text, you can use the top-level print() function:
void main() { print(‘Hello, World!’); print(“hello world”); } |

** remember: single quote [‘ ’] or double quotes[“ ”] work same for print statements. When we use print() function, it generates a new-line every time.
Newline character(\n) – this character helps to generate new line in console or output screen.
void main(){ print(‘hey!!\n i am shimanta das’); print(“hello”); } |

Tab character(\t) – generate tab between two characters.
void main(){ print(‘windows\tlinux’); } |

User input
User input means user can input via keyboard.
To take input from a user in Dart, you need to import the ‘dart:io’ library. The input is taken through the console using the .readLineSync() function. About ‘stdin’ Class: This class allows the user to read data from standard input in both synchronous and asynchronous ways.
Remember: you can’t take directly take Integer/double input instead of String input in Dart. For that after taking String variable input you need to typecast into integer/double and do whatever operations you want to do. This process also known as ‘typecasting’. You will learn about this later in the articles.
Note: The .runtimeType property is used to find out the runtime type of the object. The keyword var in Dart language lets a variable store any type of data. The .runtimeType property helps to find what kind of data is stored in the variable using var keyword. |
Let’s work on taking String input…
Code 1:
import ‘dart:io’; void main(){ String? str; print(‘Enter Your String: ‘); str = stdin.readLineSync(); print(‘your string: ‘); print(str); print(str.runtimeType); } |

Let’s work on taking integer input…
Code 2:
import ‘dart:io’; void main(){ String? str; // late -> values initialized later late int a; print(‘enter value: ‘); str = stdin.readLineSync(); // converts string->integer explicitly(typecasting) if (str!=null) { a=int.parse(str); } print(‘a value ‘); print(‘$a’); print(‘variable A runtime-type: ‘); print(a.runtimeType); } |

Let’s work on taking double input…
Code 3:
import ‘dart:io’; void main(){ String? str; late double val; print(‘Enter Value: ‘); str=stdin.readLineSync(); // implicit converts String->double if (str!=null) { val = double.parse(str); } print(‘double value is ‘); print(val); print(val.runtimeType); } |

Comments
Comments are those statements which are ignored by the interpreter in dart.
There are 2 types of comments –
- Single-line
- Multi-line
Single-line & multiline Comment
Let’s see the single-line & multi-line comment uses
void main(){ // single line comment /* multi line comment line 1 line 2 line 3 */ } |
Comparison between Dart, Python, Java, C/C++
topic | Dart | C/C++ | Python | Java |
Learn | Easy | Moderate | easy | moderate |
OOPS | All have but not so much control | All have & all controls | All have but not so much control | All have & all controls |
Variables type | Static(default) & dynamic | Static | Dynamic | static |
Modern application | Cross platforms application development with modern U.I | Cross platforms application development | Cross platforms application development | Cross platforms application development |
Tools for dart development/coding…
You can use your own tool…
Windows – vs code, dart sdk
Linux – vs code, nano editor, dart sdk
Mac – vs code, dart sdk
Remember: if you want to online code compiler –
Dart-pad[recommended]: https://dartpad.dev/?