flutter-backend-api-mapping
Installation
SKILL.md
Flutter-Backend API Mapping
Problem
Backend Python (SQLite) trả String cho ID fields ("1"), frontend Dart model dùng int. Cast sai → app crash.
Common mismatch patterns
| Backend | Flutter Model | Fix |
|---|---|---|
"empId": "1" (String) |
int id |
int.tryParse(data['empId']) ?? 0 |
"empId": 1 (Integer) |
int id |
data['empId'] as int |
"empName" field |
name field |
Map field names explicitly |
initial null missing |
initial required |
Fallback "?" hoặc "M" |