Flutter Mobile Development · Lektion

Dart-Grundlagen für Flutter

Tauchen Sie in die Grundlagen der Dart-Programmierung ein, einschließlich Variablen, Datentypen, Kontrollfluss, Funktionen und objektorientierter Konzepte, die für Flutter unverzichtbar sind.

Lektion 2 von 411 Schritte

Dart-Grundlagen für Flutter ist eine kostenlose Flutter Mobile Development-Lektion auf CoddyKit. Dies ist Lektion 2 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Flutter Mobile Development-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Flutter Mobile Development-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

Welcome to Dart!

Before building apps, let’s learn Dart — Flutter’s language. It’s client-optimized and quick to pick up if you know Java or JavaScript.

Storing Data: Variables & Types

Variables store data. Declare them with var for inferred types, or be explicit: int, double, String, bool.

Variables in Action

Here’s declaring different variable types. Note Dart’s null safety: a variable can’t be null unless you opt in with ?.

void main() {
  var name = "Alice"; // Type inferred as String
  int age = 30;
  double height = 1.75;
  bool isStudent = true;
  String? middleName; // Can be null

  print("Name: $name");
  print("Age: $age");
  print("Student: $isStudent");
}

Grouping Data: Lists

A Dart List is an ordered, zero-indexed collection — like an array. Declare a typed one like List<String> and grab items by position.

void main() {
  List<String> fruits = ['Apple', 'Banana'];
  print('Initial fruits: $fruits');

  fruits.add('Orange'); // Add an item
  print('After adding: $fruits');

  print('First fruit: ${fruits[0]}');
}

Making Decisions: If/Else

Control flow lets your code decide. if runs when a condition is true; chain else if and else for the rest.

void main() {
  int temperature = 25;

  if (temperature > 30) {
    print('It\'s very hot!');
  } else if (temperature > 20) {
    print('It\'s warm.');
  } else {
    print('It\'s cool.');
  }
}

Repeating Actions: Loops

Loops repeat a block. A for loop is perfect for iterating a list or running a task a fixed number of times.

void main() {
  List<String> colors = ['Red', 'Green', 'Blue'];

  for (String color in colors) {
    print('Color: $color');
  }

  for (int i = 0; i < 3; i++) {
    print('Count: $i');
  }
}

Functions: Reusable Code

Functions are reusable blocks that do one task. They take parameters as input and can return a value as output.

Defining & Calling Functions

This shows two functions: greet takes a name, add returns an int. void means a function returns nothing.

void greet(String name) {
  print('Hello, $name!');
}

int add(int a, int b) {
  return a + b;
}

void main() {
  greet('Coddy');
  int sum = add(10, 5);
  print('Sum: $sum');
}

Basic Classes & Objects

Dart is object-oriented: a class is a blueprint for objects. Objects bundle properties (data) and methods (behavior) to keep code organized.

class Car {
  String brand; // Property
  int year;    // Property

  Car(this.brand, this.year); // Constructor

  void displayInfo() { // Method
    print('$brand from $year');
  }
}

void main() {
  var myCar = Car('Toyota', 2020); // Create an object
  myCar.displayInfo(); // Call a method

  var otherCar = Car('Honda', 2022);
  otherCar.displayInfo();
}

Dart Fundamentals Check

Which of the following Dart code snippets are valid variable declarations or initializations?

Recap: Dart Essentials

Nice work! You’ve got Dart’s core building blocks — variables, lists, control flow, loops, functions, and classes. This is the foundation for every Flutter app.

Kostenlos starten

Lerne Dart mit einem KI-Tutor — kostenlos

Schreibe und führe echten Code in deinem Browser aus, bekomme sofortige Hilfe von einem 24/7 KI-Tutor und setze dein Lernen im Web oder in der App fort.

Kurse
22
Lektionen
88

Häufig gestellte Fragen

Ist die Lektion „Dart-Grundlagen für Flutter“ kostenlos?

Ja — der vollständige Text von „Dart-Grundlagen für Flutter“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Flutter Mobile Development-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Flutter Mobile Development-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Dart-Grundlagen für Flutter“?

Tauchen Sie in die Grundlagen der Dart-Programmierung ein, einschließlich Variablen, Datentypen, Kontrollfluss, Funktionen und objektorientierter Konzepte, die für Flutter unverzichtbar sind. Du übst Flutter Mobile Development mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Flutter Mobile Development zu starten?

Keine Vorkenntnisse erforderlich. Flutter Mobile Development auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 2 von 4.

Wie lange dauert die Lektion „Dart-Grundlagen für Flutter“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Flutter Mobile Development-Lektion Code schreiben und ausführen?

Ja. Jede Flutter Mobile Development-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Flutter-Ökosystem und Einrichtung
  2. Dart-Grundlagen für Flutter
  3. Entwicklung Ihrer ersten Flutter-App
  4. Asynchrone Programmierung mit Futures und async/await
← Zurück zu Flutter Mobile Development