Files
superport/.claude/agents/flutter-patterns.md
JiWoong Sul 655d473413
Some checks failed
Flutter Test & Quality Check / Test on macos-latest (push) Has been cancelled
Flutter Test & Quality Check / Test on ubuntu-latest (push) Has been cancelled
Flutter Test & Quality Check / Build APK (push) Has been cancelled
web: migrate health notifications to js_interop; add browser hook
- Replace dart:js with package:js in health_check_service_web.dart\n- Implement showHealthCheckNotification in web/index.html\n- Pin js dependency to ^0.6.7 for flutter_secure_storage_web compatibility

auth: harden AuthInterceptor + tests

- Allow overrideAuthRepository injection for testing\n- Normalize imports to package: paths\n- Add unit test covering token attach, 401→refresh→retry, and failure path\n- Add integration test skeleton gated by env vars

ui/data: map User.companyName to list column

- Add companyName to domain User\n- Map UserDto.company?.name\n- Render companyName in user_list

cleanup: remove legacy equipment table + unused code; minor warnings

- Remove _buildFlexibleTable and unused helpers\n- Remove unused zipcode details and cache retry constant\n- Fix null-aware and non-null assertions\n- Address child-last warnings in administrator dialog

docs: update AGENTS.md session context
2025-09-08 17:39:00 +09:00

2.0 KiB

Superport Flutter Patterns v8.0

What This Really Is

Project-specific code patterns and examples. Not an "agent", just templates.

Project Structure

lib/
  data/      # API, DTOs
  domain/    # Business logic, entities
  screens/   # UI screens
  widgets/   # Reusable components

Common Patterns in This Project

API Call Pattern

Future<Either<Failure, List<EquipmentDto>>> getEquipments() async {
  try {
    final response = await _api.getEquipments();
    return Right(response.items);
  } catch (e) {
    return Left(ServerFailure(e.toString()));
  }
}

Controller Pattern

class EquipmentController extends ChangeNotifier {
  List<EquipmentDto> _items = [];
  bool _isLoading = false;
  
  Future<void> loadItems() async {
    _isLoading = true;
    notifyListeners();
    
    final result = await _useCase.getEquipments();
    result.fold(
      (failure) => _handleError(failure),
      (data) => _items = data,
    );
    
    _isLoading = false;
    notifyListeners();
  }
}

ShadCN UI Components

// ALWAYS use these, NEVER Flutter defaults
StandardDataTable<T>()     // Not DataTable()
ShadButton.outline()        // Not ElevatedButton()
ShadSelect<String>()        // Not DropdownButton()

Korean Validation

// Business registration number
bool validateBusinessNumber(String number) {
  if (number.length != 10) return false;
  // Actual validation logic here
  return true;
}

// Korean phone
final phoneRegex = RegExp(r'^01[0-9]-?\d{3,4}-?\d{4}$');

Backend Field Mapping (CRITICAL)

// MUST match backend exactly
@JsonKey(name: 'companies_id') int? companiesId  // NOT company_id
@JsonKey(name: 'models_id') int? modelsId        // NOT model_id

Project-Specific Rules

  1. Clean Architecture: Domain → Data → Presentation
  2. Backend owns business logic
  3. Frontend just displays
  4. shadcn_ui components only
  5. Korean comments for complex logic

Copy these patterns. They work in this project.