Search⌘ K
AI Features

Solution: E-Commerce Order Processor

Explore how to implement flow control statements in Dart to handle e-commerce order statuses. Learn to iterate collections, skip canceled orders, and route active statuses using switch cases for clean, maintainable code.

We'll cover the following...
Dart
void main() {
final orderStatuses = ['PENDING', 'CANCELLED', 'SHIPPED', 'UNKNOWN', 'PENDING'];
for (final status in orderStatuses) {
if (status == 'CANCELLED') {
continue;
}
switch (status) {
case 'PENDING':
print('Route to packing line.');
case 'SHIPPED':
print('Route to tracking system.');
default:
print('Flag for manual review.');
}
}
}

Solution explanation

In the main.dart file:

  • Line 4: ...