Skip to content

isikkerim/dart-programming-guide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Dart Programming Tutorial for Beginners

Learn the basics and fundamentals of Dart Programming from scratch. This guide provides a structured roadmap to understanding Dart, the language behind Flutter, and its key concepts.


πŸ“‹ Table of Contents

  1. Overview
  2. Installation
  3. Getting Started with Dart Programming
  4. Data Types and Variables
  5. Control Flow Statements
  6. Loop Control Statements
  7. Functions in Dart
  8. Exception Handling
  9. Object-Oriented Programming
  10. Advanced OOP Concepts
  11. Functional Programming in Dart
  12. Dart Collections
  13. Callable Classes
  14. Dart with Flutter: Key Concepts
  15. Conclusion

0. Overview

Course Introduction

This tutorial is designed for beginners looking to start with Dart Programming. By the end, you’ll have a solid foundation in Dart and be ready to dive into Flutter app development.

Prerequisites

  • Basic programming knowledge is helpful but not mandatory.
  • Familiarity with object-oriented concepts will be a plus.

Software Requirements

  • Dart SDK
  • Visual Studio Code (or any preferred code editor)
  • Flutter (for Dart + UI development)

1. Installation

Installing Dart SDK

Verifying Installation

dart --version

Setting Up an Editor

Install Dart and Flutter plugins in Visual Studio Code or IntelliJ IDEA.


2. Getting Started with Dart Programming

Running Your First Dart Program

Create a file named hello.dart:

void main() {
  print("Hello, Dart!");
}

Run the program:

dart run hello.dart

Comments in Dart

  • Single-line: // This is a comment
  • Multi-line:
    /* This is a multi-line comment */

3. Data Types and Variables

Core Data Types

  • int, double (Numbers)
  • String (Text)
  • bool (True/False)
  • List, Set, Map (Collections)

String Interpolation

String name = "Dart";
print("Welcome to $name!");

Constants

  • Final: Runtime constants
    final String appName = "MyApp";
  • Const: Compile-time constants
    const double pi = 3.14;

4. Control Flow Statements

IF-ELSE

if (true) {
  print("Condition is true");
} else {
  print("Condition is false");
}

Ternary Operator

String result = (5 > 3) ? "Yes" : "No";

5. Loop Control Statements

FOR Loop

for (int i = 0; i < 5; i++) {
  print(i);
}

WHILE and DO-WHILE

int i = 0;
while (i < 5) {
  print(i);
  i++;
}

6. Functions in Dart

Declaring Functions

int add(int a, int b) => a + b;

Optional Parameters

void greet(String name, [String? title]) {
  print("Hello $title $name");
}

7. Exception Handling

Try-Catch Example

try {
  int result = 12 ~/ 0;
} catch (e) {
  print("Error: $e");
}

8. Object-Oriented Programming

Classes and Objects

class Animal {
  String name;

  Animal(this.name);

  void eat() {
    print("$name is eating");
  }
}

void main() {
  var dog = Animal("Dog");
  dog.eat();
}

9. Advanced OOP Concepts

  • Inheritance:
    class Dog extends Animal {
      Dog(String name) : super(name);
    }
  • Polymorphism
  • Static Variables and Methods

10. Functional Programming in Dart

Lambda Expressions

var square = (int x) => x * x;

11. Dart Collections

Lists

List<int> numbers = [1, 2, 3];

Maps

Map<String, int> scores = {"Alice": 90, "Bob": 80};

12. Callable Classes

Classes that behave like functions:

class Person {
  call(String msg) => "Hello, $msg";
}

13. Dart with Flutter: Key Concepts

Why Dart for Flutter?

  • Strongly-typed
  • Hot reload for rapid UI changes
  • Easy-to-learn syntax

Common Flutter Widgets

  • Container, Row, Column, ListView

14. Conclusion

Congratulations on completing this guide! You're now ready to build real-world applications using Dart and Flutter. Continue your learning journey by exploring the official Dart documentation and Flutter tutorials.


πŸ’‘ Additional Resources


Feel free to contribute to this repository or suggest improvements! πŸŽ‰

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages