Learn/Orientation/Dart Quick Start for Flutter

Dart Quick Start for Flutter

Learn just enough Dart to start building Flutter apps

8 min~6 min read+35 FX

You can read this lesson publicly. Sign in to unlock exercises, quiz, and FX progress tracking.

Table of Contents

  1. 1. Variables: Storing Data
  2. 2. final and const: Values That Do Not Change
  3. 3. Functions: Reusable Code Blocks
  4. 4. Lists: Ordered Collections
  5. 5. Maps: Key-Value Pairs
  6. 6. If/Else and Ternary
  7. 7. Classes: Blueprints for Objects
  8. 8. Dart in Flutter: Putting It Together
  9. 9. Dart Skills You Must Master Before Level 1
  10. 10. This Lesson In Simple Words
  11. 11. Your level focus
  12. 12. One practical habit
  13. 13. Deep Understanding Guide
  14. 14. Why this lesson matters
  15. 15. Study flow for better retention
  16. 16. Quick Glossary

Having trouble? AI is here to help

Ask context-aware questions about this lesson. Free plan: 5 questions/day. Upgrade to Premium for higher daily limits.

Use the AI button at the bottom of the screen

Dart Quick Start

Before diving deeper into Flutter, you need to learn the essential Dart concepts that power every Flutter app. Dart is the programming language used by Flutter. It is clean, modern, and designed to be easy to pick up, even if you are new to programming.

Variables: Storing Data

Variables are used to hold values. Dart can figure out the type automatically based on what you assign:

dart
1// 'var' lets Dart figure out the type
2var name = 'Alice'; // String (text)
3var age = 25; // int (whole number)
4var height = 5.7; // double (decimal)
5var isStudent = true; // bool (true/false)
6
7// You can also declare the type explicitly:
8String city = 'NYC';
9int score = 100;
10double price = 29.99;
11bool isDarkMode = false;
12
13// Print to console
14print('Hello, $name!'); // String interpolation
15print('Age: ${age + 1}'); // Expression in string

String Interpolation

💡 String Interpolation

Use `$variable` to insert a variable into a string. For expressions, use `${expression}` format, such as `${age + 1}`. This approach is much cleaner and easier to read than traditional string concatenation.

final and const: Values That Do Not Change

dart
1// final: Set once, never changes (can be set at runtime)
2final username = 'john_doe';
3final now = DateTime.now(); // OK - computed at runtime
4
5// const: Must be known at compile time
6const pi = 3.14159;
7const maxItems = 100;
8// const now = DateTime.now(); // ERROR! Not known at compile time
9
10// Rule of thumb:
11// Use 'const' when you know the value before the app runs
12// Use 'final' when the value is computed once at runtime

Functions: Reusable Code Blocks

dart
1// Basic function with return type
2String greet(String name) {
3 return 'Hello, $name!';
4}
5
6// Arrow syntax (short form for one-line functions)
7String greet(String name) => 'Hello, $name!';
8
9// Function with no return value
10void printMessage(String msg) {
11 print(msg);
12}
13
14// Function with optional parameters
15void createUser(String name, {int age = 18, String? city}) {
16 print('Name: $name, Age: $age, City: ${city ?? "Unknown"}');
17}
18
19// Calling functions
20print(greet('Alice')); // Hello, Alice!
21createUser('Bob', age: 25); // Name: Bob, Age: 25, City: Unknown
22createUser('Carol', city: 'NYC'); // Name: Carol, Age: 18, City: NYC

Lists: Ordered Collections

dart
1// Create a list
2var fruits = ['apple', 'banana', 'cherry'];
3List<int> numbers = [1, 2, 3, 4, 5];
4
5// Access items (0-indexed)
6print(fruits[0]); // apple
7print(fruits.length); // 3
8
9// Add & remove
10fruits.add('date'); // Add to end
11fruits.remove('banana'); // Remove by value
12fruits.insert(1, 'blueberry'); // Insert at index
13
14// Loop through
15for (var fruit in fruits) {
16 print(fruit);
17}
18
19// Map (transform each item)
20var caps = fruits.map((f) => f.toUpperCase()).toList();

Maps: Key-Value Pairs

dart
1// Create a map
2var user = {
3 'name': 'Alice',
4 'age': 25,
5 'city': 'NYC',
6};
7
8// Access values
9print(user['name']); // Alice
10
11// Typed map
12Map<String, dynamic> profile = {
13 'name': 'Bob',
14 'age': 30,
15 'scores': [95, 87, 92],
16};

If/Else and Ternary

dart
1// If/else
2if (age >= 18) {
3 print('Adult');
4} else if (age >= 13) {
5 print('Teen');
6} else {
7 print('Child');
8}
9
10// Ternary (shorthand if/else) - used frequently in Flutter
11var label = age >= 18 ? 'Adult' : 'Minor';
12
13// In Flutter widgets:
14Text(isLoggedIn ? 'Welcome back!' : 'Please log in')
15Icon(isFavorite ? Icons.favorite : Icons.favorite_border)

Classes: Blueprints for Objects

Flutter widgets are all classes. Here is how classes work in Dart:

dart
1class User {
2 // Properties
3 final String name;
4 final int age;
5
6 // Constructor (creates the object)
7 User({required this.name, required this.age});
8
9 // Method
10 String greet() => 'Hi, I\'m $name!';
11}
12
13// Using the class
14var user = User(name: 'Alice', age: 25);
15print(user.name); // Alice
16print(user.greet()); // Hi, I'm Alice!

Do Not Memorize Everything

⚠️ Do Not Memorize Everything

You do not need to memorize all of Dart right now. This is a quick overview to get you started. Each of these topics will be covered in more detail in Level 1. For now, focus on understanding the general patterns and how the different pieces fit together.

Dart in Flutter: Putting It Together

Here is how all of these Dart concepts come together inside a real Flutter widget:

dart
1class ProfileCard extends StatelessWidget {
2 // Constructor with named parameters
3 final String name;
4 final int postCount;
5 final bool isVerified;
6
7 const ProfileCard({
8 required this.name,
9 required this.postCount,
10 this.isVerified = false,
11 });
12
13 @override
14 Widget build(BuildContext context) {
15 return Column(
16 children: [
17 // String interpolation
18 Text('Hello, $name!'),
19
20 // Ternary for conditional UI
21 Icon(isVerified ? Icons.verified : Icons.person),
22
23 // Expression in string
24 Text('$postCount posts'),
25 ],
26 );
27 }
28}

Dart Skills You Must Master Before Level 1

You do not need advanced Dart yet, but you should be comfortable with these essentials:

  • Variable declaration and type basics (String, int, double, bool)
  • final vs const and when each one is correct
  • Function syntax including named parameters
  • List and Map usage for common app data
  • Basic class syntax and constructor patterns
  • if/else and ternary usage for UI decisions

If these points feel shaky, repeat this lesson once more with hands-on code edits.

Daily Dart Drill (20 Minutes)

  • 5 min: Rewrite one small code sample from memory.
  • 5 min: Add one variation (extra field, condition, or parameter).
  • 5 min: Predict output before running.
  • 5 min: Explain what changed and why in plain English.

Bridge to Flutter Widgets

💡 Bridge to Flutter Widgets

Whenever you learn a Dart concept, immediately ask: where does this appear in a Flutter widget? This connection turns theory into practical app-building ability.

This Lesson In Simple Words

Learn just enough Dart to start building Flutter apps. Dart is the language behind Flutter, and clear Dart code makes your Flutter UI easier to maintain.

Your level focus

Build confidence with basics first; speed comes later.

One practical habit

Prefer readable names, explicit intent, and async/await over deeply nested callbacks.

Deep Understanding Guide

Why this lesson matters

When Dart basics are weak, state bugs, null crashes, and async confusion increase quickly.

Study flow for better retention

  1. Read one section, run one tiny example, then explain the idea in your own words.
  2. Treat each Dart concept as a building block for widgets, services, and tests you will write later.
  3. If you can teach it in 45 seconds without notes, you understood it.

Common Mistakes To Avoid

  • Ignoring null safety and forcing values with ! without checking data flow.
  • Writing long functions that mix validation, transformation, and side effects together.
  • Using dynamic where a proper type would catch mistakes earlier.
  • Catching broad errors without keeping useful context for debugging.

Practice Sprint (15-25 Minutes)

  • Before running sample code, predict output and behavior in one sentence.
  • Write a small pure function and test it with edge cases.
  • Convert one callback-based snippet to async/await with proper error handling.
  • Refactor a long function into smaller helper methods with clear names.
  • Complete the required exercises without using hints on the first attempt.
  • Answer this question out loud before checking quiz options: "What does this print?".

Quick Glossary

  • widget: A reusable UI building block in Flutter.
  • build: The method that describes UI for the current state.
  • bloc: An event-to-state pattern that separates logic from UI.
  • const: A compile-time constant that can reduce rebuild work.

Code Comprehension Drill

  • State the purpose of the code block in one line before reading details.
  • Mark inputs, state changes, and final output.
  • Change one small value and predict what should happen before running.
  • Run again and compare your prediction with actual behavior.

Lesson Completion Checklist

  • I can explain "Dart Quick Start for Flutter" in simple words without reading notes.
  • I can describe one real app situation where this concept is required.
  • I know at least one mistake to avoid: Ignoring null safety and forcing values with ! without checking data flow.
  • I can modify one code sample and correctly predict the behavior change.
  • I can finish required exercises with understanding, not trial-and-error guesses.

Frequently Asked Questions

What does this print?

The $ sign in a string performs string interpolation: it inserts the value of the variable "name" into the string.

What is the difference between final and const?

final values are set once at runtime (e.g., DateTime.now()). const values must be known before the app runs (e.g., pi = 3.14).

What does this print?

Lists are 0-indexed in Dart. Index 0 = apple, Index 1 = banana, Index 2 = cherry.

What does this return?

The ternary operator checks if age >= 18 (true for 20), so it returns "Adult".

Suggest Improvement

Something seems incorrect, unclear, or missing? Let us know.

About The Author

FlutterCraft editorial lessons are reviewed by experienced Flutter developers and updated to stay aligned with modern Flutter and Dart best practices.

Reference docs: Flutter Documentation, Dart Language Tour, and official package documentation where relevant.

Sign in to continue with exercises and quiz for this lesson.

Sign In to Continue