🐛 Fix offline map download issues and add UX improvements#5
Merged
Conversation
This commit finalizes the implementation of three major initiatives: - **Routing Engine**: Implemented OSRM integration with configurable backend and Haversine fallback for offline calculation. - **Offline Maps**: Integrated FMTC backend, added region download capabilities, created MapPickerScreen, and added `regions.json` asset. - **Codebase Cleanup**: Refactored `MainScreen` from 1600+ lines to a modular architecture (~289 lines), improving maintainability and testability. All 216 tests are passing.
This commit addresses multiple critical issues reported by the user: - **Offline Maps Persistence**: Implemented Hive-based storage for offline map regions. The app now correctly remembers downloaded maps after a restart. - **Restricted Regions**: Updated the available offline map regions to strictly "Luzon", "Visayas", and "Mindanao". - **Geographic Accuracy**: Scientifically verified and updated the bounding box coordinates for these regions to ensure full coverage of outlying islands (e.g., Palawan, Batanes, Tawi-Tawi). - **Connectivity Detection**: Replaced the single `google.com` check with a robust multi-endpoint check (1.1.1.1, microsoft.com, github.com) to fix false "offline" status in regions where Google is blocked. - **Crash Prevention**: Fixed a startup crash caused by unhandled exceptions during FMTC backend initialization. Added defensive try-catch blocks to ensure the app launches gracefully even if offline maps fail to load.
This commit introduces a hierarchical offline map system allowing users to download individual Philippine islands instead of entire regions. Key changes: Data Layer: - Added 28 individual islands with accurate bounding boxes across Luzon (10), Visayas (11), and Mindanao (7) island groups - Created hierarchical JSON schema with parent-child relationships - Updated regions.json with 31 total regions (3 groups + 28 islands) Model Layer: - Added RegionType enum (islandGroup, island) with Hive persistence - Extended MapRegion with type, parentId, priority fields - Added fromJson/toJson serialization methods Repository Layer: - Created RegionRepository for dynamic JSON-based region loading - Implemented hierarchical queries (getIslandGroups, getIslandsForGroup) - Added caching to avoid repeated JSON parsing Service Layer: - Updated OfflineMapService to load regions dynamically - Added downloadIslandGroup() for batch island downloads - Implemented aggregated progress tracking for group downloads Presentation Layer: - Redesigned RegionDownloadScreen with expandable island groups - Added "Download All" button per group - Individual island toggles with size estimates Documentation: - Added architecture documentation - Added island boundaries research data All 258 tests passing.
📝 Summary: Resolved 4 critical offline map issues plus a regression bug, improving the download experience with proper state management and new features. 🔧 Changes: - 🗄️ Fixed HiveError by adding Hive initialization and adapter registration - ⏹️ Fixed download stop button not resetting status properly - 📊 Added percentage display (e.g., "45%") next to progress bar - 🗑️ Added "Clear All Data" feature in AppBar menu - 🔄 Fixed regression: download now works after stop without app restart 🧪 All 258 tests passing.
8 tasks
MasuRii
added a commit
that referenced
this pull request
Mar 16, 2026
…ine-maps Fix offline map download issues and add UX improvements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Summary
This PR fixes 4 critical offline map issues plus a regression bug, significantly improving the download experience with proper state management and new user-friendly features.
✨ Changes
main.dart📁 Files Changed
lib/main.dartlib/src/services/offline/offline_map_service.dartlib/src/presentation/screens/region_download_screen.dartlib/src/models/map_region.dartlib/src/repositories/region_repository.dartlib/src/core/di/injection.config.darttest/*.dart(5 files)🧪 Testing Instructions
flutter test- all 258 tests should pass🔧 Technical Details
_cancelRequestedflag was not reset at the start ofdownloadRegion()anddownloadIslandGroup()_cancelRequested = falseat the very start of both methods, before any early returns📋 Checklist
dart formatdart analyze)