# Days 1-2: Dart Introduction and Development Tools

#### Objective:

* Install Dart SDK and development tools (VSCode/IntelliJ).
    
* Learn basic Dart syntax: variables, data types, operators.
    

---

### 1\. Dart SDK and Development Tools Installation

**Dart SDK Installation:**

1. **Download Dart SDK:**
    
    * Visit the [Dart SDK Download Page](https://dart.dev/get-dart).
        
    * Select the appropriate SDK for your operating system (Windows, macOS, Linux).
        
2. **Install Dart SDK:**
    
    * Follow the installation instructions for your operating system.
        
3. **Verify Installation:**
    
    * Open your terminal or command prompt.
        
    * Run the command `dart --version` to check if Dart is installed correctly.
        

**Development Tools Installation:**

1. **Visual Studio Code (VSCode):**
    
    * Download and install [Visual Studio Code](https://code.visualstudio.com/).
        
    * Open VSCode and go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window or pressing `Ctrl+Shift+X`.
        
    * Search for the Dart extension and install it.
        
2. **IntelliJ IDEA:**
    
    * Download and install [IntelliJ IDEA](https://www.jetbrains.com/idea/).
        
    * Open IntelliJ IDEA and go to `File > Settings > Plugins`.
        
    * Search for the Dart plugin and install it.
        

---

### 2\. Basic Dart Syntax

**Variables:**

Variables in Dart can be declared using `var`, `final`, or `const`.

```dart
void main() {
  var name = 'John';  // A variable that can be reassigned
  final age = 25;     // A variable that cannot be reassigned
  const pi = 3.14;    // A compile-time constant

  print('Name: $name, Age: $age, Pi: $pi');
}
```

**Data Types:**

Dart is a strongly typed language, and it supports various data types like `int`, `double`, `String`, `bool`, `List`, and `Map`.

```dart
void main() {
  int a = 10;
  double b = 20.5;
  String c = 'Hello';
  bool d = true;
  List<int> e = [1, 2, 3];
  Map<String, int> f = {'one': 1, 'two': 2};

  print('Int: $a, Double: $b, String: $c, Bool: $d, List: $e, Map: $f');
}
```

**Operators:**

Dart supports various operators, including arithmetic, relational, logical, and assignment operators.

```dart
void main() {
  int a = 10;
  int b = 20;

  // Arithmetic Operators
  print('Addition: ${a + b}');
  print('Subtraction: ${a - b}');
  print('Multiplication: ${a * b}');
  print('Division: ${a / b}');
  print('Modulus: ${a % b}');

  // Relational Operators
  print('Equal: ${a == b}');
  print('Not Equal: ${a != b}');
  print('Greater than: ${a > b}');
  print('Less than: ${a < b}');

  // Logical Operators
  bool c = true;
  bool d = false;
  print('AND: ${c && d}');
  print('OR: ${c || d}');
  print('NOT: ${!c}');

  // Assignment Operators
  int e = 5;
  e += 5; // e = e + 5
  print('Assignment: $e');
}
```

---

### Examples with Explanations

**Example 1: Basic Dart Program**

```dart
void main() {
  print('Hello, Dart!');
}
```

Explanation: This is the simplest Dart program. The `main()` function is the entry point of the program, and `print()` is used to output text to the console.

**Example 2: Using Variables and Data Types**

```dart
void main() {
  var name = 'Alice';
  int age = 30;
  double height = 5.6;
  bool isStudent = false;

  print('Name: $name');
  print('Age: $age');
  print('Height: $height');
  print('Is Student: $isStudent');
}
```

Explanation: This program demonstrates declaring variables of different data types and printing their values.

**Example 3: Using Operators**

```dart
void main() {
  int a = 15;
  int b = 4;

  print('Sum: ${a + b}');
  print('Difference: ${a - b}');
  print('Product: ${a * b}');
  print('Quotient: ${a / b}');
  print('Remainder: ${a % b}');
}
```

Explanation: This program uses arithmetic operators to perform basic mathematical operations on two integers.

---

### Visual Explanations

**1\. Dart SDK Installation:**

* **Figure 1:** Dart SDK download page.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1716393106812/dcd10057-e096-4145-89cf-a7a639546272.png align="center")
    
* **Figure 2:** Verifying Dart installation in terminal.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1716393226108/8ed3bcf7-ff47-4ce1-bd3a-265c97e33078.png align="center")
    

**2\. Variables and Data Types:**

* **Figure 3:** Example of declaring variables and data types in Dart.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1716393616156/69453b3d-5dfd-435b-972e-a9d15510f22c.png align="center")
    

**3\. Operators:**

* **Figure 4:** Example of using operators in Dart.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1716393853278/bc736826-c19f-41e4-aaae-5360bd1ecd9d.png align="center")
    

By following this guide, you'll have a solid understanding of the basics of Dart and be ready to move on to more advanced concepts in the following days. Happy coding!
