Null-safe profile formatter
Write a function that takes String? name and int? age, then returns a readable line using defaults when values are null.
Languages / Knowledge library
client-optimized language for multi-platform apps
Dart helps teams build fast, type-safe apps for mobile, web, desktop, and server with one language, strong tooling, and predictable performance.
2011: Google announced Dart to improve large-scale client app development. 2013: Dart 1.0 shipped with a stable language and VM. 2018: Dart 2.0 strengthened the type system for production use. 2021: Dart 2.12 added sound null safety. 2023: Dart 3.0 added records, pattern matching, and new class modifiers.
Work through these exercises in order. Try the task before opening a reference.
Write a function that takes String? name and int? age, then returns a readable line using defaults when values are null.
Create a User class with final fields, fromJson, and toJson. Parse a list of users and sort by createdAt.
Build a small pipeline: receive events from a Stream, process heavy work in an isolate, and emit typed results with error handling.
Use a switch expression on a record (x, y) to label origin, axis, or quadrant.
Add one package to pubspec.yaml, pin a compatible version constraint, and explain why exact pinning vs range matters.
A logistics firm managing warehouse inventory across mobile handheld scanners and a central web-based management dashboard.
The firm struggles with code fragmentation, as their legacy stack requires separate teams to maintain Java for backend services and JavaScript for web dashboards, leading to inconsistent inventory state updates.
By adopting Dart, the firm can utilize a single language for both the mobile scanner application and the backend service, leveraging shared data models and business logic to ensure consistent state management across platforms.
Shows how shared Dart logic synchronizes data between different platforms.
Dart records defining inventory items
Native app for warehouse staff
Server-side logic for database sync
Central inventory storage
This code demonstrates the use of records for shared data structures and async-await for non-blocking network operations, which are central to the Unified Logistics Inventory Sync solution.
typedef InventoryItem = ({String id, int quantity}); // Shared record type
Future<void> updateStock(InventoryItem item) async {
// Asynchronous logic for network sync
print('Syncing ${item.id} with quantity ${item.quantity}');
}The firm achieves a unified codebase that reduces synchronization errors between the warehouse floor and the management dashboard, resulting in more reliable inventory tracking.
While Dart provides excellent cross-platform capabilities, developers must be mindful of memory usage in long-running backend processes; this can be checked by monitoring the isolate heap usage during high-concurrency inventory sync operations.