### Install Application Target Source: https://github.com/appaxaap/focus/blob/main/windows/CMakeLists.txt Installs the main application executable to the runtime destination. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Install Flutter Library Source: https://github.com/appaxaap/focus/blob/main/windows/CMakeLists.txt Installs the main Flutter library file to the root of the application bundle. ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install Missing Libraries for Focus AppImage on Debian/Ubuntu Source: https://github.com/appaxaap/focus/blob/main/README.md Use this command to install necessary libraries if the Focus AppImage fails to run on Debian, Ubuntu, or Mint due to missing shared libraries. Ensure your package list is updated before installation. ```bash sudo apt update sudo apt install libkeybinder-3.0-0 libgdk-pixbuf2.0-0 libgtk-3-0 libnotify4 ``` -------------------------------- ### Install Desktop Entry File Source: https://github.com/appaxaap/focus/blob/main/linux/CMakeLists.txt Installs the generated desktop entry file, which is used by desktop environments to launch the application. This file is configured from a template. ```cmake configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/packaging/${APPLICATION_ID}.desktop.in" "${CMAKE_CURRENT_BINARY_DIR}/${APPLICATION_ID}.desktop" @ONLY ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${APPLICATION_ID}.desktop" DESTINATION "${INSTALL_BUNDLE_SHARE_DIR}/applications" COMPONENT Runtime) ``` -------------------------------- ### Install Bundled Plugin Libraries Source: https://github.com/appaxaap/focus/blob/main/windows/CMakeLists.txt Installs any bundled plugin libraries to the root of the application bundle if they exist. ```cmake if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Set Installation Prefix Source: https://github.com/appaxaap/focus/blob/main/linux/CMakeLists.txt Configures the installation prefix to a local bundle directory if not explicitly set. This ensures the application is installed in a relocatable bundle. ```cmake set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() ``` -------------------------------- ### Install Metainfo XML File Source: https://github.com/appaxaap/focus/blob/main/linux/CMakeLists.txt Installs the application's metainfo XML file, which provides metadata for software centers and package managers. This file is configured from a template. ```cmake configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/packaging/${APPLICATION_ID}.metainfo.xml.in" "${CMAKE_CURRENT_BINARY_DIR}/${APPLICATION_ID}.metainfo.xml" @ONLY ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${APPLICATION_ID}.metainfo.xml" DESTINATION "${INSTALL_BUNDLE_SHARE_DIR}/metainfo" COMPONENT Runtime) ``` -------------------------------- ### Example: Initialize Notification Service if Supported Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/notification-service.md Initializes the notification service if it is supported on the current platform. ```dart if (NotificationService().isSupported) { NotificationService().initialize(); } ``` -------------------------------- ### fromJson Method Example Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/task.md Shows an example of creating a Task object from a JSON map, including required fields. ```dart final json = { 'id': '123e4567-e89b-12d3-a456-426614174000', 'title': 'Complete project', 'quadrant': 'urgentImportant', 'dueDate': '2026-06-30T17:30:00.000', 'isCompleted': false, 'createdAt': '2026-06-26T10:00:00.000', 'updatedAt': '2026-06-26T10:00:00.000', }; final task = Task.fromJson(json); ``` -------------------------------- ### Install Missing Libraries for Focus AppImage on Fedora Source: https://github.com/appaxaap/focus/blob/main/README.md Use this command to install necessary libraries if the Focus AppImage fails to run on Fedora due to missing shared libraries. ```bash sudo dnf install keybinder3 gdk-pixbuf2 gtk3 libnotify ``` -------------------------------- ### Configure Installation Prefix for Bundled App Source: https://github.com/appaxaap/focus/blob/main/windows/CMakeLists.txt Sets the installation prefix to the directory next to the executable, allowing the app to run in place. This is crucial for Visual Studio builds. ```cmake set(BUILD_BUNDLE_DIR "$") set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") ``` -------------------------------- ### Install Bundled Libraries Source: https://github.com/appaxaap/focus/blob/main/linux/CMakeLists.txt Installs multiple bundled libraries required by plugins into the bundle's library directory. This loop handles each library individually. ```cmake foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) ``` -------------------------------- ### Install Native Assets Source: https://github.com/appaxaap/focus/blob/main/windows/CMakeLists.txt Installs native assets provided by build.dart from all packages to the root of the application bundle. ```cmake set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install Application Icon Source: https://github.com/appaxaap/focus/blob/main/linux/CMakeLists.txt Installs the application icon to the appropriate location within the bundle's share directory. This ensures the icon is available for the system to display. ```cmake install(FILES "${APPLICATION_ICON}" DESTINATION "${INSTALL_BUNDLE_SHARE_DIR}/icons/hicolor/512x512/apps" RENAME "${APPLICATION_ID}.png" COMPONENT Runtime) ``` -------------------------------- ### Sync Badge Example Usage Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/app-badge-service.md Demonstrates how to call the syncBadge method after fetching tasks and user preference. ```dart final tasks = await hiveService.getAllTasks(); final badgeEnabled = await hiveService.getAppIconBadgeEnabledPreference(); await appBadgeService.syncBadge( tasks: tasks, enabled: badgeEnabled, ); ``` -------------------------------- ### Install Flutter Assets Source: https://github.com/appaxaap/focus/blob/main/windows/CMakeLists.txt Installs the Flutter assets directory. It first removes any existing assets to ensure a clean copy. ```cmake set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install Missing Libraries for Focus AppImage on Arch/Manjaro Source: https://github.com/appaxaap/focus/blob/main/README.md Use this command to install necessary libraries if the Focus AppImage fails to run on Arch Linux or Manjaro due to missing shared libraries. ```bash sudo pacman -S keybinder gdk-pixbuf2 gtk3 libnotify ``` -------------------------------- ### Install ICU Data File Source: https://github.com/appaxaap/focus/blob/main/windows/CMakeLists.txt Installs the ICU data file to the data directory of the application bundle. ```cmake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install AOT Library Source: https://github.com/appaxaap/focus/blob/main/windows/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library, but only for non-Debug build configurations (Profile and Release). ```cmake install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Install Native Assets Source: https://github.com/appaxaap/focus/blob/main/linux/CMakeLists.txt Copies native assets from the build directory to the installation bundle. This ensures all necessary native files are included in the final application package. ```cmake set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Example Workflow with Task Due Dates Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/app-badge-service.md Illustrates the badge count logic with various task scenarios, including due dates and completion status. ```dart // Task 1: Due today, incomplete — COUNTED final task1 = Task( id: '1', title: 'Urgent task', quadrant: Quadrant.urgentImportant, dueDate: DateTime.now().add(Duration(hours: 2)), isCompleted: false, ); // Task 2: Due tomorrow, incomplete — NOT COUNTED final task2 = Task( id: '2', title: 'Tomorrow task', quadrant: Quadrant.notUrgentImportant, dueDate: DateTime.now().add(Duration(days: 1)), isCompleted: false, ); // Task 3: Due today, completed — NOT COUNTED final task3 = Task( id: '3', title: 'Done task', quadrant: Quadrant.urgentImportant, dueDate: DateTime.now(), isCompleted: true, ); // Task 4: No due date — NOT COUNTED final task4 = Task( id: '4', title: 'No due date task', quadrant: Quadrant.notUrgentImportant, dueDate: null, isCompleted: false, ); // Badge count: 1 (only task1) await appBadgeService.syncBadge( tasks: [task1, task2, task3, task4], enabled: true, ); ``` -------------------------------- ### Example Usage of Spacing Constants Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/utilities.md Demonstrates how to use defaultPadding and cardMargin constants to apply spacing to widgets. ```dart Padding( padding: EdgeInsets.all(defaultPadding), child: Card( margin: EdgeInsets.all(cardMargin), child: TaskWidget(), ), ) ``` -------------------------------- ### Example: Schedule Notifications After Service is Ready Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/notification-service.md Waits for the NotificationService to be ready before proceeding to schedule notifications. ```dart await NotificationService().onReady; // Now safe to schedule notifications ``` -------------------------------- ### Listen to Desktop Shell Events Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/desktop-event-bus.md Example of how to listen to the broadcast stream of desktop shell events and process them. ```dart final bus = DesktopEventBus.instance; final subscription = bus.stream.listen((event) { print('Event type: ${event.type}'); }); ``` -------------------------------- ### Task List UI with ConsumerWidget Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/task-notifier.md Example of building a UI component that watches the taskProvider and displays tasks in a ListView. It includes functionality to toggle task completion. ```dart // In a ConsumerWidget class TaskList extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { final tasks = ref.watch(taskProvider); return ListView.builder( itemCount: tasks.length, itemBuilder: (context, index) { final task = tasks[index]; return ListTile( title: Text(task.title), subtitle: Text(task.notes ?? ''), onTap: () => ref.read(taskProvider.notifier) .toggleTaskCompletion(task.id), ); }, ); } } ``` -------------------------------- ### Clean Build Bundle Directory Source: https://github.com/appaxaap/focus/blob/main/linux/CMakeLists.txt Removes the build bundle directory before installation to ensure a clean state. This is executed as part of the installation process. ```cmake install( CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) ``` -------------------------------- ### Example: Initialize Notification Service Conditionally Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/notification-service.md Initializes the notification service only if it is supported on the current platform and not running on the web. ```dart if (!kIsWeb && NotificationService().isSupported) { NotificationService().initialize(); } ``` -------------------------------- ### Install AOT Library Conditionally Source: https://github.com/appaxaap/focus/blob/main/linux/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library only on non-Debug builds. This optimizes performance for release versions by using pre-compiled code. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Sync App Badge Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/providers.md Example of reading the AppBadgeService provider to synchronize the app badge with task data. ```dart final badgeService = ref.read(appBadgeServiceProvider); await badgeService.syncBadge(tasks: tasks, enabled: true); ``` -------------------------------- ### toJson Method Example Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/task.md Illustrates the expected output format when converting a Task object to a JSON map. ```dart final json = task.toJson(); // Output: { // 'id': '123e4567-e89b-12d3-a456-426614174000', // 'title': 'Complete project', // 'notes': 'Finish by Friday', // 'quadrant': 'urgentImportant', // 'dueDate': '2026-06-30T17:30:00.000', // 'isCompleted': false, // 'createdAt': '2026-06-26T10:00:00.000', // 'updatedAt': '2026-06-26T10:00:00.000' // } ``` -------------------------------- ### Emit a Desktop Shell Event Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/desktop-event-bus.md Example of how to emit a specific desktop shell event using the DesktopEventBus instance. ```dart DesktopEventBus.instance.emit(DesktopShellEventType.showWindow); ``` -------------------------------- ### Access Hive Service Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/providers.md Example of reading the HiveService provider to access and retrieve all tasks. ```dart final hiveService = ref.read(hiveServiceProvider); final tasks = await hiveService.getAllTasks(); ``` -------------------------------- ### copyWith Method Example Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/task.md Demonstrates how to use the copyWith method to update specific fields of a Task object. ```dart final updatedTask = task.copyWith( title: 'New Title', isCompleted: true, updatedAt: DateTime.now(), ); ``` -------------------------------- ### Configure Flutter library and headers Source: https://github.com/appaxaap/focus/blob/main/linux/flutter/CMakeLists.txt Sets the path to the Flutter library and ICU data file, and defines the list of Flutter library headers. These are published to the parent scope for use in the install step. ```cmake set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") # Published to parent scope for install step. set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) ``` ```cmake list(APPEND FLUTTER_LIBRARY_HEADERS "fl_basic_message_channel.h" "fl_binary_codec.h" "fl_binary_messenger.h" "fl_dart_project.h" "fl_engine.h" "fl_json_message_codec.h" "fl_json_method_codec.h" "fl_message_codec.h" "fl_method_call.h" "fl_method_channel.h" "fl_method_codec.h" "fl_method_response.h" "fl_plugin_registrar.h" "fl_plugin_registry.h" "fl_standard_message_codec.h" "fl_standard_method_codec.h" "fl_string_codec.h" "fl_value.h" "fl_view.h" "flutter_linux.h" ) list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") ``` -------------------------------- ### Set Installation RPATH Source: https://github.com/appaxaap/focus/blob/main/linux/CMakeLists.txt Configures the RPATH for installed libraries to be relative to the binary's location. This is important for ensuring that dynamically linked libraries can be found after installation. ```cmake set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### Main App Initialization Source: https://github.com/appaxaap/focus/blob/main/_autodocs/configuration.md The entry point for the Focus application, setting up necessary bindings and running the root widget. ```dart void main() async { WidgetsFlutterBinding.ensureInitialized(); // Platform-specific setup // Timezone initialization // Service initialization // Hive database setup // Theme preference loading // Riverpod overrides runApp(ProviderScope(...)); } ``` -------------------------------- ### Set Minimum CMake Version and Project Name Source: https://github.com/appaxaap/focus/blob/main/linux/CMakeLists.txt Specifies the minimum required CMake version and defines the project name with supported languages. This is a standard starting point for any CMake project. ```cmake cmake_minimum_required(VERSION 3.13) project(runner LANGUAGES CXX) ``` -------------------------------- ### Main Entry Point - lib/main.dart Source: https://github.com/appaxaap/focus/blob/main/_autodocs/README.md The main function initializes the platform, services, database, and dependency injection before running the root widget of the application. ```dart void main() async { // Platform setup // Service initialization // Hive database setup // Riverpod dependency injection runApp(FocusApp()); } ``` -------------------------------- ### Get Task Count from HiveService Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/hive-service.md Gets the total number of tasks. Returns the total count of all tasks. ```dart final count = await hiveService.getTaskCount(); ``` -------------------------------- ### Get Completed Task Count from HiveService Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/hive-service.md Gets the number of completed tasks. Returns the count of completed tasks. ```dart final completedCount = await hiveService.getCompletedTaskCount(); ``` -------------------------------- ### HiveService.initialize Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/hive-service.md Initializes Hive and opens the required boxes for tasks and preferences. May throw if Hive adapter registration or box opening fails. ```APIDOC ## HiveService.initialize ### Description Initializes Hive and opens the required boxes for tasks and preferences. ### Method Future ### Parameters None ### Throws May throw if Hive adapter registration or box opening fails. ### Example ```dart final hiveService = HiveService(); await hiveService.initialize(); ``` ``` -------------------------------- ### Initialize HiveService Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/hive-service.md Initializes Hive and opens the required boxes for tasks and preferences. May throw if Hive adapter registration or box opening fails. ```dart final hiveService = HiveService(); await hiveService.initialize(); ``` -------------------------------- ### Typical Usage in App Initialization Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/app-badge-service.md Shows how to integrate AppBadgeService calls into the main app initialization by listening to task and preference changes. ```dart // In main.dart FocusApp initialization _tasksSubscription = ref.listenManual>( taskProvider, (previous, next) { _latestTasks = next; _syncAppBadge(); // Call on every task change }, fireImmediately: true, ); _badgePrefSubscription = ref.listenManual>( appIconBadgeProvider, (previous, next) { _badgeEnabled = next.value ?? true; _syncAppBadge(); // Call when preference changes }, fireImmediately: true, ); Future _syncAppBadge() async { await ref .read(appBadgeServiceProvider) .syncBadge(tasks: _latestTasks, enabled: _badgeEnabled); } ``` -------------------------------- ### WindowsShellService Initialization Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/windows-shell-service.md Initializes the Windows shell service, setting up the tray menu, global hotkey, and event listeners. This method is platform-guarded and only runs on Windows. ```APIDOC ## initialize ### Description Initializes the Windows shell service including tray menu, global hotkey, and event listeners. ### Method `initialize()` ### Platform Guard Only runs on Windows, safe to call on other platforms (no-op). ### Behavior 1. Registers tray listener and window listener 2. Sets tray icon (ICO file, with PNG fallback) 3. Creates context menu 4. Registers global hotkey (Ctrl+K) for command palette 5. Sets tooltip text ### Throws Errors are caught and logged but don't prevent initialization from completing. ### Example ```dart if (!kIsWeb && Platform.isWindows) { try { await WindowsShellService.instance.initialize(); } catch (e) { debugPrint('Shell initialization failed: $e'); } } ``` ``` -------------------------------- ### Windows Notification GUID Source: https://github.com/appaxaap/focus/blob/main/_autodocs/configuration.md Unique identifier for Windows notifications. ```plaintext 1f0ea55f-2695-4f68-9f5f-0b8d3e20b913 ``` -------------------------------- ### Tray Listener Methods Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/windows-shell-service.md Methods for handling interactions with the system tray icon and menu. ```APIDOC ## Tray Listener Methods ### Description Implements `TrayListener` to handle tray menu interactions and icon events. ### Methods #### `onTrayMenuItemClick` - **Description**: Called when a tray menu item is clicked. - **Parameters**: `MenuItem menuItem` #### `onTrayIconMouseDown` - **Description**: Called when the tray icon is clicked (mouse down event). ``` -------------------------------- ### Get All Tasks from HiveService Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/hive-service.md Retrieves all tasks from the database. Returns a list of all `Task` objects in the database. ```dart final allTasks = await hiveService.getAllTasks(); print('Total tasks: ${allTasks.length}'); ``` -------------------------------- ### Get Quadrant Key Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/quadrant.md Returns the enum's name as a string, useful for identification or serialization. ```dart String get key // Example: print(Quadrant.notUrgentImportant.key); // "notUrgentImportant" ``` -------------------------------- ### Get Quadrant Title Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/quadrant.md Provides a human-readable, localized title for each Quadrant, suitable for UI display. ```dart String get title // Example: print(Quadrant.urgentImportant.title); // "Urgent & Important" ``` -------------------------------- ### Find and check GTK, GLIB, and GIO modules Source: https://github.com/appaxaap/focus/blob/main/linux/flutter/CMakeLists.txt This snippet uses PkgConfig to find and check for the required GTK, GLIB, and GIO libraries, making them available for linking. ```cmake find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) ``` -------------------------------- ### Get Completed Tasks from HiveService Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/hive-service.md Retrieves all completed tasks. Returns a list of tasks where `isCompleted` is true. ```dart final completedTasks = await hiveService.getCompletedTasks(); ``` -------------------------------- ### Get Active Tasks from HiveService Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/hive-service.md Retrieves all incomplete tasks. Returns a list of tasks where `isCompleted` is false. ```dart final openTasks = await hiveService.getActiveTasks(); print('Open tasks: ${openTasks.length}'); ``` -------------------------------- ### Include Directories and Link Libraries Source: https://github.com/appaxaap/focus/blob/main/third_party/hotkey_manager_linux/linux/CMakeLists.txt Specifies include paths and links necessary libraries including Flutter, GTK, and Keybinder. ```cmake target_include_directories(${PLUGIN_NAME} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include") target_link_libraries(${PLUGIN_NAME} PRIVATE flutter) target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::GTK) target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::KEYBINDER) ``` -------------------------------- ### Get Tasks in a Quadrant Source: https://github.com/appaxaap/focus/blob/main/_autodocs/README.md Retrieve tasks filtered by a specific quadrant using `filteredTasksProvider`. This is a read-only operation. ```dart final urgentTasks = ref.watch( filteredTasksProvider(Quadrant.urgentImportant), ); ``` -------------------------------- ### Initialize WindowsShellService Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/windows-shell-service.md Initializes the Windows shell service, including setting up the tray menu, global hotkey, and event listeners. This method is platform-guarded and only runs on Windows. ```dart Future initialize() ``` ```dart if (!kIsWeb && Platform.isWindows) { try { await WindowsShellService.instance.initialize(); } catch (e) { debugPrint('Shell initialization failed: $e'); } } ``` -------------------------------- ### Get Quadrant Color Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/quadrant.md Returns a specific Flutter Color associated with each Quadrant for visual representation in the UI. ```dart Color get color // Example: final color = Quadrant.urgentImportant.color; // Returns Color(0xFFFF4757) ``` -------------------------------- ### Watch Multiple Providers Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/providers.md Demonstrates how to watch multiple providers simultaneously to react to changes in theme, task completion status, and the task list. ```dart final theme = ref.watch(themeProvider); final showCompleted = ref.watch(showCompletedTasksProvider); final tasks = ref.watch(taskProvider); ``` -------------------------------- ### State Management with Riverpod Source: https://github.com/appaxaap/focus/blob/main/_autodocs/README.md Demonstrates how to watch and update state using Riverpod. Use `ref.watch` to observe changes and `ref.read` to trigger state modifications. ```dart final tasks = ref.watch(taskProvider); // List final theme = ref.watch(themeProvider); // AppTheme // Update state await ref.read(taskProvider.notifier).addTask(...); // Listen to changes ref.listen(taskProvider, (previous, next) { print('Tasks changed'); }); ``` -------------------------------- ### Window Options Configuration Source: https://github.com/appaxaap/focus/blob/main/_autodocs/configuration.md Configures various window properties such as size, centering, background, taskbar visibility, and title bar style. ```dart const WindowOptions( size: Size(1200, 800), center: true, backgroundColor: Colors.transparent, skipTaskbar: false, titleBarStyle: TitleBarStyle.hidden, ) ``` -------------------------------- ### Enable Unicode Support Source: https://github.com/appaxaap/focus/blob/main/windows/CMakeLists.txt Adds preprocessor definitions to enable Unicode support for all projects. ```cmake add_definitions(-DUNICODE -D_UNICODE) ``` -------------------------------- ### Get Tasks by Quadrant from HiveService Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/hive-service.md Retrieves all tasks in a specific quadrant. Returns a list of tasks in the specified quadrant. ```dart final urgentImportant = await hiveService.getTasksByQuadrant( Quadrant.urgentImportant, ); ``` -------------------------------- ### Listen to Provider Changes Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/providers.md Shows how to listen for changes in a specific provider, like the themeProvider, and execute a callback when the value changes. ```dart ref.listen(themeProvider, (previous, next) { if (previous != next) { print('Theme changed to $next'); } }); ``` -------------------------------- ### Apply Standard Build Settings Source: https://github.com/appaxaap/focus/blob/main/linux/runner/CMakeLists.txt Applies a standard set of build settings to the specified target. This can be customized or removed if the application requires different build configurations. ```cmake apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Locale Type Example Source: https://github.com/appaxaap/focus/blob/main/_autodocs/types.md Dart's built-in Locale type for specifying language and region. Used by localeProvider. ```dart class Locale { final String languageCode; final String? countryCode; } ``` -------------------------------- ### Theme Provider Override Source: https://github.com/appaxaap/focus/blob/main/_autodocs/configuration.md Initializes the theme notifier, loading a saved theme preference or defaulting to light. ```dart themeProvider.overrideWith((ref) { return ThemeNotifier(hiveService) ..setTheme(savedTheme ?? AppTheme.light); }) ``` -------------------------------- ### Watching AsyncValue Provider in Flutter Source: https://github.com/appaxaap/focus/blob/main/_autodocs/types.md Example of watching an `AsyncValue` provider in Flutter using Riverpod. Checks for a value before accessing it. ```dart final badgeEnabled = ref.watch(appIconBadgeProvider); // AsyncValue if (badgeEnabled.hasValue) { print(badgeEnabled.value); // true or false } ``` -------------------------------- ### Listen to Desktop Shell Events Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/windows-shell-service.md Listens for events from the DesktopEventBus, such as showing the window, opening the command palette, or handling quick add tasks. Ensure the DesktopEventBus is initialized before listening. ```dart // Listen to events final bus = DesktopEventBus.instance; bus.stream.listen((event) { switch (event.type) { case DesktopShellEventType.showWindow: windowManager.show(); break; case DesktopShellEventType.openCommandPalette: // Show command palette break; case DesktopShellEventType.quickAddTask: // Show quick add dialog break; } }); ``` -------------------------------- ### Save and Get Sunrise Timestamp Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/hive-service.md Manages the timestamp of when the sunrise screen was last shown. Returns milliseconds since epoch, defaulting to 0 if never saved. ```dart Future saveSunriseTimestamp() Future getLastSunriseTimestamp() ``` ```dart await hiveService.saveSunriseTimestamp(); final lastTimestamp = await hiveService.getLastSunriseTimestamp(); final lastDate = DateTime.fromMillisecondsSinceEpoch(lastTimestamp); ``` -------------------------------- ### themeProvider Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/providers.md Manages the application theme preference, supporting light, dark, AMOLED, and system themes. It persists the selected theme using Hive. ```APIDOC ## themeProvider ### Description Manages the application theme preference (light, dark, AMOLED, system). Persists the theme to Hive. ### State Type `AppTheme` enum ### Methods on Notifier - `setTheme(AppTheme theme)`: Sets the application theme. ### Example ```dart // Watch theme changes final theme = ref.watch(themeProvider); // Change theme await ref.read(themeProvider.notifier).setTheme(AppTheme.dark); ``` ### Persistence Automatically saves to Hive preferences. ``` -------------------------------- ### Define Application Metadata Source: https://github.com/appaxaap/focus/blob/main/linux/CMakeLists.txt Sets variables for the executable name, GTK application ID, application name, comment, and icon path. These are crucial for packaging and identifying the application on the system. ```cmake set(BINARY_NAME "focus") set(APPLICATION_ID "com.appaxaap.focus") set(APPLICATION_NAME "Focus") set(APPLICATION_COMMENT "Offline Eisenhower Matrix task manager") set(APPLICATION_ICON "${CMAKE_CURRENT_SOURCE_DIR}/../assets/images/rounded_logo.png") ``` -------------------------------- ### Set and Get Show Completed Tasks Preference Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/hive-service.md Controls the visibility of completed tasks in the UI. Use `setShowCompletedPreference` to enable or disable this feature and `getShowCompletedPreference` to retrieve the current setting. ```dart Future setShowCompletedPreference(bool value) Future getShowCompletedPreference() ``` ```dart await hiveService.setShowCompletedPreference(true); final show = await hiveService.getShowCompletedPreference(); ``` -------------------------------- ### SDK Requirements Configuration Source: https://github.com/appaxaap/focus/blob/main/_autodocs/configuration.md Specifies the required SDK and Flutter versions for the project. Ensure your environment meets these minimums. ```yaml sdk: ^3.8.1 flutter: "3.32.5" ``` -------------------------------- ### Set and Get App Icon Badge Enabled Preference Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/hive-service.md Controls whether the app icon badge is enabled. Use `setAppIconBadgeEnabledPreference` to toggle the badge and `getAppIconBadgeEnabledPreference` to check its current status. ```dart Future setAppIconBadgeEnabledPreference(bool value) Future getAppIconBadgeEnabledPreference() ``` ```dart await hiveService.setAppIconBadgeEnabledPreference(true); final enabled = await hiveService.getAppIconBadgeEnabledPreference(); ``` -------------------------------- ### Configure Flutter Interface Library Source: https://github.com/appaxaap/focus/blob/main/windows/flutter/CMakeLists.txt Creates an interface library target for Flutter, specifying include directories and linking against the Flutter DLL. ```cmake add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Set and Get Locale Preference Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/hive-service.md Saves and retrieves the application locale preference. Use `setLocalePreference` to set a specific locale code (e.g., 'en_US') and `getLocalePreference` to retrieve the current locale. ```dart Future setLocalePreference(String localeCode) Future getLocalePreference() ``` ```dart await hiveService.setLocalePreference('de_DE'); final locale = await hiveService.getLocalePreference(); // Returns: "en_US" (default) ``` -------------------------------- ### Add Plugin Library Source: https://github.com/appaxaap/focus/blob/main/third_party/hotkey_manager_linux/linux/CMakeLists.txt Adds the shared library for the plugin, including its source files. Standard build settings are applied. ```cmake list(APPEND PLUGIN_SOURCES "hotkey_manager_linux_plugin.cc" ) add_library(${PLUGIN_NAME} SHARED ${PLUGIN_SOURCES} ) apply_standard_settings(${PLUGIN_NAME}) ``` -------------------------------- ### Enums Source: https://github.com/appaxaap/focus/blob/main/_autodocs/INDEX.md Enumerations for task categorization, theme settings, view filters, and desktop events. ```APIDOC ## Enums ### Quadrant Task categorization. ### AppTheme Light, dark, AMOLED theme options. ### TaskViewFilter Filters for viewing tasks: Daily, weekly, monthly, all. ### DesktopShellEventType Events related to the desktop shell. ``` -------------------------------- ### Set and Get Theme Preference Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/hive-service.md Saves and retrieves the application theme preference. Supported themes include Light, Dark, and AMOLED. Use `setThemePreference` to save a theme and `getThemePreference` to retrieve the currently saved theme. ```dart Future setThemePreference(AppTheme theme) Future getThemePreference() ``` ```dart await hiveService.setThemePreference(AppTheme.dark); final savedTheme = await hiveService.getThemePreference(); ``` -------------------------------- ### Apply Standard Compiler Settings Source: https://github.com/appaxaap/focus/blob/main/linux/CMakeLists.txt Applies standard C++14, warning flags, optimization, and NDEBUG definition to a target. Use this for common settings across targets. ```cmake function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_14) target_compile_options(${TARGET} PRIVATE -Wall -Werror) target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") endfunction() ``` -------------------------------- ### Filter Tasks by Date Range Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/utilities.md Filter lists of tasks based on their due dates. This example shows how to filter for tasks due today, this week, and this month using helper functions like isSameDay, isSameWeek, and isSameMonth. ```dart final now = DateTime.now(); // Today's tasks final today = tasks.where((task) { return task.dueDate != null && isSameDay(task.dueDate!, now); }).toList(); // This week's tasks final thisWeek = tasks.where((task) { return task.dueDate != null && isSameWeek(task.dueDate!, now); }).toList(); // This month's tasks final thisMonth = tasks.where((task) { return task.dueDate != null && isSameMonth(task.dueDate!, now); }).toList(); ``` -------------------------------- ### Extract and Inspect Focus AppImage for Missing Libraries Source: https://github.com/appaxaap/focus/blob/main/README.md These commands help diagnose issues with the Focus AppImage on Linux. First, extract the AppImage contents, then use 'ldd' to check for any 'not found' shared libraries, specifically looking for 'keybinder'. ```bash # extract the AppImage (creates squashfs-root/) ./Focus.AppImage --appimage-extract # inspect the main binary and check for "not found" entries ldd squashfs-root/usr/bin/focus | grep "not found\|keybinder" ``` -------------------------------- ### Minimum Window Size (Windows) Source: https://github.com/appaxaap/focus/blob/main/_autodocs/configuration.md Sets the minimum allowable dimensions for the application window on Windows. Use DesktopWindow.setMinWindowSize() to apply. ```dart const Size(1068, 873) ``` -------------------------------- ### Initialize Hive Service Provider Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/providers.md Defines the HiveService provider. This must be overridden at app startup with the actual HiveService instance. ```dart final hiveServiceProvider = Provider((ref) { throw UnimplementedError('hiveServiceProvider must be overridden'); }); ``` -------------------------------- ### Tray Listener Methods Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/windows-shell-service.md Callback methods for handling tray menu item clicks and tray icon mouse down events. ```dart @override void onTrayMenuItemClick(MenuItem menuItem) ``` ```dart @override void onTrayIconMouseDown() ``` -------------------------------- ### Listen to Multiple Providers Simultaneously Source: https://github.com/appaxaap/focus/blob/main/_autodocs/README.md This pattern demonstrates how to subscribe to changes in multiple providers, such as task updates and theme changes, allowing for reactive updates across different parts of the application. ```dart ref.listen(taskProvider, (prev, next) { // Tasks changed }); ref.listen(themeProvider, (prev, next) { // Theme changed }); ``` -------------------------------- ### Include Generated Plugin Rules Source: https://github.com/appaxaap/focus/blob/main/windows/CMakeLists.txt Includes the CMake file that manages building and adding generated plugins to the application. ```cmake include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Initialize Windows Shell Service Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/windows-shell-service.md Initializes the Windows Shell Service. This should be called after app startup on Windows platforms and within a try-catch block to handle potential initialization errors gracefully. ```dart if (!kIsWeb && Platform.isWindows) { try { await WindowsShellService.instance.initialize(); } catch (e) { if (kDebugMode) { debugPrint('Windows shell init skipped: $e'); } } } ``` -------------------------------- ### Configure Cross-Building Sysroot Source: https://github.com/appaxaap/focus/blob/main/linux/CMakeLists.txt Sets up CMake variables for cross-compiling by defining the sysroot and search paths. This is used when building for a different architecture or environment than the host system. ```cmake if(FLUTTER_TARGET_PLATFORM_SYSROOT) set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) endif() ``` -------------------------------- ### showNow Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/notification-service.md Displays a notification immediately to the user. This is useful for time-sensitive alerts. ```APIDOC ## showNow ### Description Displays a notification immediately to the user. This is useful for time-sensitive alerts. ### Method Future ### Parameters #### Path Parameters - **id** (int) - Required - Unique notification ID - **title** (String) - Required - Notification title - **body** (String) - Required - Notification body text - **payload** (String?) - Optional - Optional data payload ### Request Example ```dart await NotificationService().showNow( id: 1, title: 'Quick Alert', body: 'This is an immediate notification', payload: 'task-data', ); ``` ``` -------------------------------- ### Listen to Desktop Events Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/desktop-event-bus.md Subscribe to the event stream to react to shell events like showing the window, opening the command palette, or quick task addition. Ensure proper disposal of the subscription when no longer needed. ```dart final bus = DesktopEventBus.instance; final subscription = bus.stream.listen((event) { switch (event.type) { case DesktopShellEventType.showWindow: windowManager.show(); windowManager.focus(); break; case DesktopShellEventType.openCommandPalette: // Trigger command palette UI showCommandPalette(); break; case DesktopShellEventType.quickAddTask: // Trigger quick add dialog showQuickAddDialog(); break; } }); ``` -------------------------------- ### Access and Listen to Filtered Tasks Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/providers.md Demonstrates how to retrieve tasks for a specific quadrant using the filteredTasksProvider and how to set up a listener to detect changes in that quadrant's task list. ```dart // Get tasks in a specific quadrant final urgentImportant = ref.watch( filteredTasksProvider(Quadrant.urgentImportant), ); // Rebuild when that quadrant's tasks change ref.listen( filteredTasksProvider(Quadrant.urgentImportant), (previous, next) { print('Quadrant tasks changed'); }, ); ``` -------------------------------- ### Set Include Directories Source: https://github.com/appaxaap/focus/blob/main/linux/runner/CMakeLists.txt Specifies include directories for the application target. The source directory is added for general access to headers. ```cmake target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") ``` -------------------------------- ### Combine Providers for Filtering Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/providers.md Illustrates combining multiple providers to derive a filtered list of tasks based on completion status and a show completed flag. ```dart final visibleTasks = ref.watch(taskProvider).where((task) { final show = ref.watch(showCompletedTasksProvider); return show.value == true || !task.isCompleted; }).toList(); ``` -------------------------------- ### Project and Plugin Naming Source: https://github.com/appaxaap/focus/blob/main/third_party/hotkey_manager_linux/linux/CMakeLists.txt Defines the project name and the shared library plugin name. These are used for build system identification. ```cmake set(PROJECT_NAME "hotkey_manager_linux") project(${PROJECT_NAME} LANGUAGES CXX) # This value is used when generating builds using this plugin, so it must # not be changed. set(PLUGIN_NAME "hotkey_manager_linux_plugin") ``` -------------------------------- ### Link Libraries and Include Directories Source: https://github.com/appaxaap/focus/blob/main/windows/runner/CMakeLists.txt Links necessary Flutter libraries and the wrapper application library. Also adds the source directory to include directories. Add any application-specific dependencies here. ```cmake target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) ``` ```cmake target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") ``` ```cmake target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") ``` -------------------------------- ### Include Flutter Managed Directory Source: https://github.com/appaxaap/focus/blob/main/linux/CMakeLists.txt Includes the Flutter managed directory for building Flutter library and tool components. Ensure the 'flutter' subdirectory exists. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) ``` -------------------------------- ### Utility Functions Source: https://github.com/appaxaap/focus/blob/main/_autodocs/INDEX.md Helper functions for date formatting and comparison. ```APIDOC ## Utility Functions ### formatDate Formats a DateTime object to a string. ### isSameDay Compares two dates to check if they are the same day. ### isSameWeek Compares two dates to check if they are in the same week. ### isSameMonth Compares two dates to check if they are in the same month. ``` -------------------------------- ### HiveService.getAllTasks Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/hive-service.md Retrieves all tasks from the database. Returns a list of all Task objects in the database. ```APIDOC ## HiveService.getAllTasks ### Description Retrieves all tasks from the database. ### Method Future> ### Parameters None ### Returns A list of all `Task` objects in the database. ### Example ```dart final allTasks = await hiveService.getAllTasks(); print('Total tasks: ${allTasks.length}'); ``` ``` -------------------------------- ### Apply Standard Compilation Settings Source: https://github.com/appaxaap/focus/blob/main/windows/CMakeLists.txt A function to apply common compilation settings to a target, including C++ standard, warning levels, and exception handling. ```cmake function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_17) target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") target_compile_options(${TARGET} PRIVATE /EHsc) target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") target_compile_definitions(${TARGET} PRIVATE ") endfunction() ``` -------------------------------- ### Emit UI Events via DesktopEventBus Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/windows-shell-service.md Demonstrates emitting various UI-related events through the DesktopEventBus instance. These events can be subscribed to by UI listeners for actions like showing the window, opening the command palette, or adding a quick task. ```dart DesktopEventBus.instance.emit(DesktopShellEventType.showWindow); DesktopEventBus.instance.emit(DesktopShellEventType.openCommandPalette); DesktopEventBus.instance.emit(DesktopShellEventType.quickAddTask); ``` -------------------------------- ### Theme Preference Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/hive-service.md Saves and retrieves the application theme preference. ```APIDOC ## setThemePreference / getThemePreference ### Description Saves and retrieves the application theme preference. ### Methods - `setThemePreference(AppTheme theme)`: Sets the application theme. - `getThemePreference()`: Retrieves the saved application theme. ### Parameters #### Request Body (for setThemePreference) - **theme** (AppTheme) - Required - Light, dark, or AMOLED theme ### Example ```dart await hiveService.setThemePreference(AppTheme.dark); final savedTheme = await hiveService.getThemePreference(); ``` ``` -------------------------------- ### Task Model Methods Source: https://github.com/appaxaap/focus/blob/main/_autodocs/api-reference/task.md This section details the methods available for interacting with the Task model, including copying tasks with updated fields, converting tasks to JSON, and reconstructing tasks from JSON. ```APIDOC ## Task Model Methods ### copyWith Creates a copy of this task with optionally updated fields. ```dart Task copyWith({ String? id, String? title, String? notes, Quadrant? quadrant, DateTime? dueDate, bool? isCompleted, DateTime? createdAt, DateTime? updatedAt, }) ``` **Returns:** A new `Task` instance with specified fields updated, others preserved from the original. **Example:** ```dart final updatedTask = task.copyWith( title: 'New Title', isCompleted: true, updatedAt: DateTime.now(), ); ``` ### toJson Converts the task to a JSON-serializable map. ```dart Map toJson() ``` **Returns:** A map with keys: `id`, `title`, `notes`, `quadrant`, `dueDate`, `isCompleted`, `createdAt`, `updatedAt`. **Example:** ```dart final json = task.toJson(); // Output: { // 'id': '123e4567-e89b-12d3-a456-426614174000', // 'title': 'Complete project', // 'notes': 'Finish by Friday', // 'quadrant': 'urgentImportant', // 'dueDate': '2026-06-30T17:30:00.000', // 'isCompleted': false, // 'createdAt': '2026-06-26T10:00:00.000', // 'updatedAt': '2026-06-26T10:00:00.000' // } ``` ### fromJson Static method to reconstruct a task from a JSON map. ```dart static Task fromJson(Map json) ``` **Parameters:** | Parameter | Type | Description | |-----------|------|-------------| | json | Map | JSON object with task data | **Returns:** A reconstructed `Task` instance. **Throws:** May throw if required fields are missing or invalid quadrant string is provided. **Example:** ```dart final json = { 'id': '123e4567-e89b-12d3-a456-426614174000', 'title': 'Complete project', 'quadrant': 'urgentImportant', 'dueDate': '2026-06-30T17:30:00.000', 'isCompleted': false, 'createdAt': '2026-06-26T10:00:00.000', 'updatedAt': '2026-06-26T10:00:00.000', }; final task = Task.fromJson(json); ``` ```