Skip to content
Guest
Flutter · Course Syllabus Show lessons
Dart Core · 9 min read · Beginner

Dart Classes, Records & Async/Await

Model app data with immutable Dart classes, fromJson factories, and non-blocking Future async/await.

What you'll learn

  • Write clean constructors with required named parameters
  • Implement fromJson factory constructors for API responses
  • Use Future and async/await without blocking the UI thread

Overview

Model app data with immutable Dart classes, fromJson factories, and non-blocking Future async/await.

Code Example

class Course {
  final String title;
  final int hours;
  const Course({required this.title, required this.hours});

  factory Course.fromJson(Map<String, dynamic> json) =>
      Course(title: json['title'] as String, hours: json['hours'] as int);
}

Key Takeaways

  • Write clean constructors with required named parameters
  • Implement fromJson factory constructors for API responses
  • Use Future and async/await without blocking the UI thread

Quick Check

Check Your Understanding

Score: 0 / 1

1. Why is `const` used on Dart constructors and Flutter widgets whenever possible?

Study Workspace

Finished this lesson?

Your progress is saved locally in your browser, no account needed.

Search courses, lessons, and references

Type to search across all courses, lessons, and quick references.

Press Esc to close Powered by Pagefind