Overview
Icarus uses Riverpod for state management across the application. The provider architecture follows a multi-page document model where each strategy contains multiple pages, and each page holds its own set of placed elements (agents, abilities, drawings, etc.).Provider Architecture
Core Strategy Provider
TheStrategyProvider manages the overall strategy state and coordinates between different element providers.
Location: lib/providers/strategy_provider.dart:172-186
The ID of the currently active page being edited. Null when no page is loaded.
Strategy State
Location:lib/providers/strategy_provider.dart:144-170
Indicates whether the current strategy has unsaved changes
The name of the current strategy, or null if no strategy is loaded
Unique identifier for the current strategy
File system path where strategy images and assets are stored
Element Providers
Each type of placeable element has its own dedicated provider that manages state for that element type.Agent Provider
Location:lib/providers/agent_provider.dart:13-14
addAgent(PlacedAgent)- Add a new agent to the canvasremoveAgent(String id)- Remove an agent by IDupdatePosition(Offset, String id)- Update agent positiontoggleAgentState(String id)- Toggle between alive/dead statesswitchSides()- Mirror all agents when switching attack/defend
Ability Provider
Location:lib/providers/ability_provider.dart:14-15
addAbility(PlacedAbility)- Add a new abilityupdatePosition(Offset, String id)- Update ability positionupdateRotation(int index, double rotation, double length)- Adjust ability direction and rangeswitchSides()- Mirror abilities when switching sides
Drawing Provider
Location:lib/providers/drawing_provider.dart:61-62
DrawingState that includes:
All completed drawing elements on the page
The drawing currently being created (null when not actively drawing)
Incremented to trigger repaints when drawings change
startFreeDrawing(Offset, CoordinateSystem, Color, bool isDotted, bool hasArrow)- Begin a new drawingupdateFreeDrawing(Offset, CoordinateSystem)- Add points to current drawingfinishFreeDrawing(Offset?, CoordinateSystem)- Complete and simplify the drawing using Douglas-Peucker algorithmonErase(Offset)- Remove drawings near the cursorrebuildAllPaths(CoordinateSystem)- Reconstruct all drawing paths (called after zoom/pan changes)
Map Provider
Location:lib/providers/map_provider.dart:12
The selected Valorant map (Ascent, Bind, Haven, etc.)
Whether the strategy is for attacking or defending side
Toggle visibility of spawn barriers on the map
Toggle visibility of ultimate orbs
Toggle visibility of site/region names
Folder Provider
Location:lib/providers/folder_provider.dart:115-116
Page Management
Strategies can contain multiple pages, each with its own set of elements. The active page determines which elements are currently visible and editable.Switching Pages
Location:lib/providers/strategy_provider.dart:481-524
- Flush current page - Save all provider state to the current page in Hive
- Clear undo/redo - Reset action history
- Load new page - Hydrate all providers from the target page’s data
- Rebuild paths - Reconstruct any coordinate-dependent elements
Adding Pages
Location:lib/providers/strategy_provider.dart:674-710
Auto-Save System
The strategy provider implements an automatic save system with debouncing to prevent excessive writes. Location:lib/providers/strategy_provider.dart:198-239
Delay before triggering an auto-save after the last edit (defined in
Settings.autoSaveOffset)Undo/Redo System
All element providers track their history through theActionProvider. Each modification creates a UserAction that can be undone or redone.
Action Types:
A new element was added to the canvas
An element was removed from the canvas
An existing element was modified (position, rotation, etc.)
agent, ability, drawing, text, image, or utility. This allows the appropriate provider to handle the undo/redo operation.
State Persistence
All provider state is persisted to Hive when saving. The_syncCurrentPageToHive() method collects state from all element providers and writes it to the active page.
Location: lib/providers/strategy_provider.dart:1257-1289