lib/
├── injection_container.dart # GetIt Registry: Orchestrates local-only registrations
├── main.dart # Global app entry; initializes Hive (Local Storage)
├── core/
│ ├── services/ # Core Singletons
│ │ ├── sharing_service.dart # Handles System Sharing (Files/Text)
│ │ └── log_service.dart # Local system logging
│ └── util/ # Pure functional utilities (Mappers, Helpers)
├── features/ # Clean Architecture Modules
│ ├── notes/ # Core Notes Engine
│ │ ├── data/ # NoteLocalDataSource (Hive only)
│ │ ├── domain/ # NoteEntity & NoteBlockEntity
│ │ └── presentation/ # BLoC (State) & UI
│ └── settings/ # Local Preferences & Profile (QR logic)
The app uses GetIt as a Service Locator (sl) for a strictly local dependency graph:
- Factories (
registerFactory): Used for BLoCs (NoteBloc,SettingsBloc). - Lazy Singletons (
registerLazySingleton): Used for Repositories and Local DataSources. - External Dependencies: Only local instances of
HiveBoxare injected. All Firebase and remote services have been purged.
- Reactive Streams: Uses
getMediaStream()for real-time sharing of files/text from other apps. - Initial Intents: Uses
getInitialMedia()to catch "Share" events that launch the app from a cold state. - File Handling: Configured as a system-wide handler for code files (
.dart,.py,.js, etc.) on Android.
CodeNote operates as a Strictly Offline application:
- Hive (Local Database):
notesBox: Stores all notes, blocks, and local metadata.settingsBox: Stores user preferences (Theme, Font Size) and local profile data.
- Event:
UpdateNoteEventis dispatched from the UI. - Local Commit:
NoteBlocinstantly updates the UI state (Optimistic UI). - Persistence:
NoteRepositorysaves the changes toNoteLocalDataSource(Hive). - Reactive: Local streams automatically emit the new list to all listeners.
The project uses a specialized Gradle Lifecycle Interceptor to ensure compatibility across all modules:
// android/build.gradle
gradle.afterProject { project ->
if (project.hasProperty('android')) {
project.android {
compileSdkVersion 36
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
if (project.plugins.hasPlugin('kotlin-android')) {
kotlinOptions { jvmTarget = '17' }
}
}
}
}Rationale: Forces the entire project tree (including third-party plugins) to align with Java 17 and Android SDK 36.
- State:
flutter_bloc(v9.1+),dartz(Functional Error Handling). - Storage:
hive,hive_flutter(High-performance NoSQL). - Real-time Sharing:
receive_sharing_intent. - UI Components:
flutter_animate,flutter_code_editor,flutter_markdown,qr_flutter.