Metropolitan Museum Integration
The app connects to the Met’s public API to fetch artifact data:lib/logic/artifact_api_service.dart
Artifact Data Model
TheArtifactData class represents museum artifacts:
lib/logic/data/artifact_data.dart
Artifact API Logic
TheArtifactAPILogic class manages artifact fetching with caching:
lib/logic/artifact_api_logic.dart
Caching Strategy
- In-Memory Cache: Uses
HashMapto store fetched artifacts - Session-Level: Cache persists during app session
- Prevents Redundant Requests: Same artifact ID only fetched once
- Fast Lookups: O(1) complexity for cached items
Artifact Search Screen
The search interface allows users to find artifacts by keyword and time range:lib/ui/screens/artifact/artifact_search/artifact_search_screen.dart
Search Functionality
Text Search
- Case-insensitive matching
- Whole word boundaries (
\b) - Optional plural forms (
s?) - Searches both title and keywords
Time Range Filtering
The expanding time range selector allows filtering by creation date:lib/ui/screens/artifact/artifact_search/time_range_selector/expanding_time_range_selector.dart
- Visual timeline with artifact distribution
- Draggable range handles
- Histogram showing artifact density by year
- Smooth animations when adjusting range
- Default range from wonder’s
artifactStartYrtoartifactEndYr
Search Visualization
Results Grid
Search results display in a responsive staggered grid:Result Tiles
Each artifact displays as an image card with title overlay:Highlight Artifacts
Each wonder features curated highlight artifacts:lib/logic/data/highlight_data.dart
Artifact Details View
Tapping an artifact opens a detailed view:- High-resolution image
- Full metadata (title, date, culture, medium, dimensions)
- Classification and period information
- Link to Met Museum website
- Related artifacts suggestions
Performance Optimizations
- Image Caching: Network images cached automatically
- Lazy Loading: Grid items built on-demand
- Debounced Search: Text input debounced to reduce API calls
- Self-Hosted Thumbnails: Small images served from CDN
- Responsive Images: Different sizes (600px, 2000px, full) based on context
Error Handling
- Graceful degradation when API unavailable
- Fallback to self-hosted data
- User-friendly error messages
- Retry logic for failed requests