Podstawy języka Dart dla Fluttera
Poznają Państwo podstawy programowania w języku Dart, obejmujące zmienne, typy danych, sterowanie przepływem, funkcje i koncepcje obiektowe niezbędne we Flutterze.
Podstawy języka Dart dla Fluttera to bezpłatna lekcja Flutter Mobile Development na CoddyKit. To lekcja 2 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Flutter Mobile Development, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Flutter Mobile Development zawiera 4 lekcji w sumie.
Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.
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.
Ucz się Dart dzięki korepetycjom AI — za darmo
Pisz i uruchamiaj kod w przeglądarce, otrzymuj natychmiastową pomoc od korepetytora AI dostępnego 24/7 i kontynuuj naukę w sieci lub w aplikacji.
- Kursy
- 22
- Lekcje
- 88
Często zadawane pytania
Czy lekcja „Podstawy języka Dart dla Fluttera” jest bezpłatna?
Tak — pełny tekst „Podstawy języka Dart dla Fluttera” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Flutter Mobile Development, przejdź na CoddyKit PRO. Kurs Flutter Mobile Development zawiera 4 lekcji w sumie.
Co nauczysz się w „Podstawy języka Dart dla Fluttera”?
Poznają Państwo podstawy programowania w języku Dart, obejmujące zmienne, typy danych, sterowanie przepływem, funkcje i koncepcje obiektowe niezbędne we Flutterze. Ćwiczysz Flutter Mobile Development z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.
Czy potrzebuję doświadczenia, aby zacząć Flutter Mobile Development?
Nie wymagamy żadnego doświadczenia. Flutter Mobile Development w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 2 z 4.
Ile czasu zajmuje lekcja „Podstawy języka Dart dla Fluttera”?
Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.
Czy mogę pisać i uruchamiać kod w tej lekcji Flutter Mobile Development?
Tak. Każda lekcja Flutter Mobile Development zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.
Wszystkie lekcje w tym kursie
- Ekosystem Fluttera i konfiguracja
- Podstawy języka Dart dla Fluttera
- Tworzenie pierwszej aplikacji Flutter
- Programowanie asynchroniczne z Futures i async/await