### Installation Rules Source: https://github.com/iamriajul/adhan-dart/blob/master/example/adhan_example_flutter_app/linux/CMakeLists.txt Configures the installation process, setting the install prefix to a bundle directory, cleaning the build bundle, and installing the executable, ICU data, Flutter library, and bundled plugin libraries. ```cmake # === Installation === # By default, "installing" just makes a relocatable bundle in the build # directory. 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() # Start with a clean build bundle directory every time. install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) # Fully re-copy the assets directory on each build to avoid having stale files ``` -------------------------------- ### CMake Project Setup Source: https://github.com/iamriajul/adhan-dart/blob/master/example/adhan_example_flutter_app/windows/CMakeLists.txt Initializes the CMake project with a minimum version and project name. Sets the binary name for the application. ```cmake cmake_minimum_required(VERSION 3.14) project(adhan_example_flutter_app LANGUAGES CXX) set(BINARY_NAME "adhan_example_flutter_app") cmake_policy(SET CMP0063 NEW) ``` -------------------------------- ### CMake Installation Rules Source: https://github.com/iamriajul/adhan-dart/blob/master/example/adhan_example_flutter_app/windows/CMakeLists.txt Defines installation rules for the application executable, ICU data, Flutter library, bundled plugin libraries, and assets. Ensures files are copied to the correct locations for runtime execution. ```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(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() 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(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Install Flutter Assets Directory Source: https://github.com/iamriajul/adhan-dart/blob/master/example/adhan_example_flutter_app/linux/CMakeLists.txt Installs the Flutter assets directory to the application's data directory. Removes any existing directory before installation. ```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) ``` -------------------------------- ### Get Pre-configured Calculation Methods Source: https://context7.com/iamriajul/adhan-dart/llms.txt Retrieve pre-configured calculation parameters for various regional standards used by Islamic organizations worldwide. ```dart import 'package:adhan/adhan.dart'; // Muslim World League (Fajr: 18, Isha: 17) final mwlParams = CalculationMethod.muslim_world_league.getParameters(); // Egyptian General Authority (Fajr: 19.5, Isha: 17.5) final egyptianParams = CalculationMethod.egyptian.getParameters(); // University of Karachi (Fajr: 18, Isha: 18) final karachiParams = CalculationMethod.karachi.getParameters(); // Umm al-Qura, Makkah (Fajr: 18.5, Isha interval: 90 min) // Note: Add +30 min custom adjustment for Isha during Ramadan final ummAlQuraParams = CalculationMethod.umm_al_qura.getParameters(); // Dubai (Fajr: 18.2, Isha: 18.2) final dubaiParams = CalculationMethod.dubai.getParameters(); // Moon Sighting Committee (Fajr: 18, Isha: 18 with seasonal adjustments) final mscParams = CalculationMethod.moon_sighting_committee.getParameters(); // ISNA North America (Fajr: 15, Isha: 15) - not recommended final isnaParams = CalculationMethod.north_america.getParameters(); // Kuwait (Fajr: 18, Isha: 17.5) final kuwaitParams = CalculationMethod.kuwait.getParameters(); // Qatar (Fajr: 18, Isha interval: 90 min) final qatarParams = CalculationMethod.qatar.getParameters(); // Singapore (Fajr: 20, Isha: 18) final singaporeParams = CalculationMethod.singapore.getParameters(); // Turkey/Diyanet (Fajr: 18, Isha: 17) final turkeyParams = CalculationMethod.turkey.getParameters(); // Tehran (Fajr: 17.7, Isha: 14, Maghrib: 4.5) final tehranParams = CalculationMethod.tehran.getParameters(); ``` -------------------------------- ### Install AOT Library Conditionally Source: https://github.com/iamriajul/adhan-dart/blob/master/example/adhan_example_flutter_app/linux/CMakeLists.txt Installs the AOT library to the application's library directory, but only for non-Debug builds. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Set ephemeral directory and include generated config Source: https://github.com/iamriajul/adhan-dart/blob/master/example/adhan_example_flutter_app/windows/flutter/CMakeLists.txt Sets the ephemeral directory and includes the generated configuration file. This is part of the Flutter-level build setup. ```cmake cmake_minimum_required(VERSION 3.14) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") # Configuration provided via flutter tool. include(${EPHEMERAL_DIR}/generated_config.cmake) ``` -------------------------------- ### Configure Flutter Linux GTK Dependencies in CMake Source: https://github.com/iamriajul/adhan-dart/blob/master/example/adhan_example_flutter_app/linux/flutter/CMakeLists.txt Configures system-level dependencies for Flutter Linux GTK development using PkgConfig. It checks for GTK, GLIB, and GIO libraries and sets up variables for the Flutter library and ICU data file. Ensure PkgConfig is installed and the GTK development files are available. ```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) 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) ``` -------------------------------- ### Get Specific Prayer Time Source: https://context7.com/iamriajul/adhan-dart/llms.txt Retrieve the `DateTime` for a specific prayer using the `Prayer` enum. `Prayer.none` will return `null`. This method is useful for iterating through all prayers or fetching a single prayer's time. ```dart import 'package:adhan/adhan.dart'; import 'package:intl/intl.dart'; final coordinates = Coordinates(51.5074, -0.1278); // London final params = CalculationMethod.muslim_world_league.getParameters(); final prayerTimes = PrayerTimes.today(coordinates, params); // Get time for each prayer final fajrTime = prayerTimes.timeForPrayer(Prayer.fajr); final sunriseTime = prayerTimes.timeForPrayer(Prayer.sunrise); final dhuhrTime = prayerTimes.timeForPrayer(Prayer.dhuhr); final asrTime = prayerTimes.timeForPrayer(Prayer.asr); final maghribTime = prayerTimes.timeForPrayer(Prayer.maghrib); final ishaTime = prayerTimes.timeForPrayer(Prayer.isha); // Prayer.none returns null final noneTime = prayerTimes.timeForPrayer(Prayer.none); // null // Iterate through all prayers for (final prayer in [Prayer.fajr, Prayer.sunrise, Prayer.dhuhr, Prayer.asr, Prayer.maghrib, Prayer.isha]) { final time = prayerTimes.timeForPrayer(prayer); print('$prayer: ${DateFormat.jm().format(time!)}'); } ``` -------------------------------- ### Project-level CMake Configuration Source: https://github.com/iamriajul/adhan-dart/blob/master/example/adhan_example_flutter_app/linux/CMakeLists.txt Sets up the minimum CMake version, project name, executable name, and application ID. It also configures build policies and library paths. ```cmake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) # The name of the executable created for the application. Change this to change # the on-disk name of your application. set(BINARY_NAME "adhan_example_flutter_app") # The unique GTK application identifier for this application. See: # https://wiki.gnome.org/HowDoI/ChooseApplicationID set(APPLICATION_ID "com.example.adhan_example_flutter_app") # Explicitly opt in to modern CMake behaviors to avoid warnings with recent # versions of CMake. cmake_policy(SET CMP0063 NEW) # Load bundled libraries from the lib/ directory relative to the binary. set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") # Root filesystem for cross-building. 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() # Define build configuration options. if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif() ``` -------------------------------- ### Apply Standard Build Settings Source: https://github.com/iamriajul/adhan-dart/blob/master/example/adhan_example_flutter_app/windows/runner/CMakeLists.txt Applies a standard set of build settings to the application target. This can be customized or removed if the application requires different build configurations. ```cmake # Apply the standard set of build settings. This can be removed for applications # that need different build settings. apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Flutter and System Dependencies Source: https://github.com/iamriajul/adhan-dart/blob/master/example/adhan_example_flutter_app/linux/CMakeLists.txt Includes the Flutter managed directory and finds PkgConfig for GTK dependencies. It also defines the application ID as a preprocessor macro. ```cmake # Flutter library and tool build rules. set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) # System-level dependencies. find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") ``` -------------------------------- ### Define Application Target Source: https://github.com/iamriajul/adhan-dart/blob/master/example/adhan_example_flutter_app/linux/CMakeLists.txt Defines the main executable target for the application, including source files and generated plugin registration. It applies standard build settings and links necessary libraries. ```cmake # Define the application target. To change its name, change BINARY_NAME above, # not the value here, or `flutter run` will no longer work. # # Any new source files that you add to the application should be added here. add_executable(${BINARY_NAME} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) # Apply the standard set of build settings. This can be removed for applications # that need different build settings. apply_standard_settings(${BINARY_NAME}) # Add dependency libraries. Add any application-specific dependencies here. target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) # Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) # Only the install-generated bundle's copy of the executable will launch # correctly, since the resources must in the right relative locations. To avoid # people trying to run the unbundled copy, put it in a subdirectory instead of # the default top-level location. set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) # Generated plugin build rules, which manage building the plugins and adding # them to the application. include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Initialize DateComponents for Prayer Times Source: https://github.com/iamriajul/adhan-dart/blob/master/README.md Create a DateComponents object for the desired date. Use the convenience method `DateComponents.from()` to convert a DateTime object. ```dart final date = DateComponents(2015, 11, 1); // or final date = DateComponents.from(DateTime.now()); ``` -------------------------------- ### Profile Build Mode Settings Source: https://github.com/iamriajul/adhan-dart/blob/master/example/adhan_example_flutter_app/windows/CMakeLists.txt Configures linker and compiler flags for the Profile build mode, mirroring Release settings. This ensures consistent performance characteristics for profiling. ```cmake set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") ``` -------------------------------- ### Link Libraries and Include Directories Source: https://github.com/iamriajul/adhan-dart/blob/master/example/adhan_example_flutter_app/windows/runner/CMakeLists.txt Specifies the libraries and include directories required for the application. This includes Flutter's core libraries, wrapper, and Windows-specific libraries like `dwmapi.lib`. ```cmake # Add dependency libraries and include directories. Add any application-specific # dependencies here. target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") ``` -------------------------------- ### Standard Compilation Settings Source: https://github.com/iamriajul/adhan-dart/blob/master/example/adhan_example_flutter_app/windows/CMakeLists.txt Applies standard compilation features and options to targets, including C++17 support, warning levels, and exception handling. Use with caution as plugins may inherit these settings. ```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() ``` -------------------------------- ### Define Executable Target and Source Files Source: https://github.com/iamriajul/adhan-dart/blob/master/example/adhan_example_flutter_app/windows/runner/CMakeLists.txt Defines the main executable target for the Windows application and lists all source files, including Flutter-generated ones and resource files. Ensure BINARY_NAME is consistent with the top-level CMakeLists.txt for `flutter run` compatibility. ```cmake cmake_minimum_required(VERSION 3.14) project(runner LANGUAGES CXX) # Define the application target. To change its name, change BINARY_NAME in the # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer # work. # # Any new source files that you add to the application should be added here. add_executable(${BINARY_NAME} WIN32 "flutter_window.cpp" "main.cpp" "utils.cpp" "win32_window.cpp" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" "Runner.rc" "runner.exe.manifest" ) ``` -------------------------------- ### Initialize PrayerTimes with Timezone Offset Source: https://github.com/iamriajul/adhan-dart/blob/master/README.md Initialize the PrayerTimes object with coordinates, date, calculation parameters, and an optional UTC offset to display times in a specific timezone. ```dart final kushtiaUtcOffset = Duration(hours: 6); final newYorkUtcOffset = Duration(hours: -4); // then pass your offset to PrayerTimes like this: final prayerTimes = PrayerTimes(coordinates, date, params, utcOffset: newYorkUtcOffset); ``` -------------------------------- ### Apply Standard Build Settings Function Source: https://github.com/iamriajul/adhan-dart/blob/master/example/adhan_example_flutter_app/linux/CMakeLists.txt Defines a function to apply standard compilation features, options, and definitions to a target. It sets C++ standard to 14, enables Wall and Werror, applies optimization for non-Debug builds, and defines NDEBUG for non-Debug builds. ```cmake # Compilation settings that should be applied to most targets. # # Be cautious about adding new options here, as plugins use this function by # default. In most cases, you should add new options to specific targets instead # of modifying this function. 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() ``` -------------------------------- ### Calculate Sunnah Times with PrayerTimes Source: https://github.com/iamriajul/adhan-dart/blob/master/README.md Instantiate PrayerTimes with coordinates, date, parameters, and an optional UTC offset. Then, create a SunnahTimes object from the PrayerTimes instance to access properties like middleOfTheNight and lastThirdOfTheNight. ```dart final prayerTimes = PrayerTimes(coordinates, date, params, utcOffset: newYorkUtcOffset); final sunnahTimes = SunnahTimes(prayerTimes); // and then access /// The midpoint between Maghrib and Fajr sunnahTimes.middleOfTheNight /// The beginning of the last third of the period between Maghrib and Fajr, /// a recommended time to perform Qiyam sunnahTimes.lastThirdOfTheNight ``` -------------------------------- ### Flutter Tool Backend Custom Command Source: https://github.com/iamriajul/adhan-dart/blob/master/example/adhan_example_flutter_app/windows/flutter/CMakeLists.txt Defines a custom command to run the Flutter tool backend. This command is designed to run every time due to the use of a phony output file, ensuring the build is always up-to-date. ```cmake # _phony_ is a non-existent file to force this command to run every time, since currently there's no way to get a full input/output list from the flutter tool. set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) add_custom_command( OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ${PHONY_OUTPUT} COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" windows-x64 $ VERBATIM ) ``` -------------------------------- ### Add Adhan Package to pubspec.yaml Source: https://context7.com/iamriajul/adhan-dart/llms.txt Add the adhan package to your project's pubspec.yaml file to include it as a dependency. ```yaml dependencies: adhan: ^2.0.0 ``` -------------------------------- ### Custom Command for Flutter Tool Backend in CMake Source: https://github.com/iamriajul/adhan-dart/blob/master/example/adhan_example_flutter_app/linux/flutter/CMakeLists.txt Defines a custom CMake command to execute the Flutter tool backend script. This command is triggered to generate the Flutter library and headers. The `_phony_` output is a workaround to ensure the command runs on every build, as direct input/output tracking for the Flutter tool is not yet supported. ```cmake # _phony_ is a non-existent file to force this command to run every time, since currently there's no way to get a full input/output list from the flutter tool. add_custom_command( OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/_phony_ COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} VERBATIM ) add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ) ``` -------------------------------- ### Add Flutter Build Dependencies Source: https://github.com/iamriajul/adhan-dart/blob/master/example/adhan_example_flutter_app/windows/runner/CMakeLists.txt Ensures that the Flutter build process, specifically `flutter_assemble`, is executed as a dependency for the application target. This step is crucial and should not be removed. ```cmake # Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Calculate Sunnah Times Source: https://context7.com/iamriajul/adhan-dart/llms.txt Calculate recommended Sunnah times, including the middle of the night and the last third of the night for Qiyam prayer. These are derived from the `PrayerTimes` object. ```dart import 'package:adhan/adhan.dart'; import 'package:intl/intl.dart'; final coordinates = Coordinates(24.7136, 46.6753); // Riyadh final params = CalculationMethod.umm_al_qura.getParameters(); final prayerTimes = PrayerTimes.today(coordinates, params); // Calculate Sunnah times from prayer times final sunnahTimes = SunnahTimes(prayerTimes); // The midpoint between Maghrib and Fajr print('Middle of the Night: ${DateFormat.jm().format(sunnahTimes.middleOfTheNight)}'); // The last third of the night (recommended time for Qiyam/Tahajjud) print('Last Third of Night: ${DateFormat.jm().format(sunnahTimes.lastThirdOfTheNight)}'); // Example output: // Maghrib: 6:30 PM // Fajr (next day): 4:30 AM // Middle of the Night: 11:30 PM // Last Third of Night: 1:10 AM ``` -------------------------------- ### Add Preprocessor Definitions for Build Version Source: https://github.com/iamriajul/adhan-dart/blob/master/example/adhan_example_flutter_app/windows/runner/CMakeLists.txt Sets preprocessor definitions to embed Flutter build version information directly into the compiled application. This is useful for runtime version checks or logging. ```cmake # Add preprocessor definitions for the build version. target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") ``` -------------------------------- ### Configure High Latitude Prayer Rules Source: https://context7.com/iamriajul/adhan-dart/llms.txt Configure rules for calculating Fajr and Isha times in high latitude regions. Demonstrates Middle of the Night, Seventh of the Night, and Twilight Angle rules. ```dart import 'package:adhan/adhan.dart'; import 'package:intl/intl.dart'; // High latitude location (Oslo, Norway - 59.9°N) final oslo = Coordinates(59.9139, 10.7522); final date = DateComponents(2024, 6, 21); // Summer solstice // Middle of the night rule (default) // Fajr will never be earlier than middle of night // Isha will never be later than middle of night final paramsMiddle = CalculationMethod.muslim_world_league.getParameters(); paramsMiddle.highLatitudeRule = HighLatitudeRule.middle_of_the_night; final timesMiddle = PrayerTimes(oslo, date, paramsMiddle); // Seventh of the night rule // Fajr won't be earlier than last 1/7 of night // Isha won't be later than first 1/7 of night final paramsSeventh = CalculationMethod.muslim_world_league.getParameters(); paramsSeventh.highLatitudeRule = HighLatitudeRule.seventh_of_the_night; final timesSeventh = PrayerTimes(oslo, date, paramsSeventh); // Twilight angle rule // Uses fajrAngle/60 and ishaAngle/60 as night fractions final paramsTwilight = CalculationMethod.muslim_world_league.getParameters(); paramsTwilight.highLatitudeRule = HighLatitudeRule.twilight_angle; final timesTwilight = PrayerTimes(oslo, date, paramsTwilight); print('Oslo Summer Solstice Prayer Times:'); print('Middle Rule - Fajr: ${DateFormat.jm().format(timesMiddle.fajr)}, Isha: ${DateFormat.jm().format(timesMiddle.isha)}'); print('Seventh Rule - Fajr: ${DateFormat.jm().format(timesSeventh.fajr)}, Isha: ${DateFormat.jm().format(timesSeventh.isha)}'); print('Twilight Rule- Fajr: ${DateFormat.jm().format(timesTwilight.fajr)}, Isha: ${DateFormat.jm().format(timesTwilight.isha)}'); ``` -------------------------------- ### Define C++ Wrapper for Plugins Source: https://github.com/iamriajul/adhan-dart/blob/master/example/adhan_example_flutter_app/windows/flutter/CMakeLists.txt Defines a static C++ library for Flutter plugins. It includes core wrapper sources and plugin-specific sources, linking against the Flutter library. ```cmake list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_PLUGIN "plugin_registrar.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") # Wrapper sources needed for a plugin. add_library(flutter_wrapper_plugin STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ) apply_standard_settings(flutter_wrapper_plugin) set_target_properties(flutter_wrapper_plugin PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(flutter_wrapper_plugin PROPERTIES CXX_VISIBILITY_PRESET hidden) target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) target_include_directories(flutter_wrapper_plugin PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_plugin flutter_assemble) ``` -------------------------------- ### Initialize Coordinates Source: https://github.com/iamriajul/adhan-dart/blob/master/README.md Create a Coordinates object for a specific location. Optional validation can be enabled to throw an ArgumentError for invalid latitude or longitude values. ```dart final coordinates = new Coordinates(35.78056, -78.6389); ``` ```dart /// Coordinates Validation Support [Optional], /// to Support validation, use [validate: true] param, default: false final validateTrue = new Coordinates(91.78056, -78.6389, validate: true); // Invalid Coordinates, will throw ArgumentError final validateFalse = new Coordinates(91.78056, -78.6389, validate: false); // Invalid Coordinates, won't throw ArgumentError ``` -------------------------------- ### Customize Calculation Parameters Source: https://github.com/iamriajul/adhan-dart/blob/master/README.md Obtain CalculationParameters from a predefined CalculationMethod and customize settings like Madhab and Fajr angle adjustments. ```dart final params = CalculationMethod.muslim_world_league.getParameters(); params.madhab = Madhab.hanafi; params.adjustments.fajr = 2; ``` -------------------------------- ### Create DateComponents Object Source: https://context7.com/iamriajul/adhan-dart/llms.txt Create a DateComponents object to represent the date for prayer time calculations. This can be done from year, month, day, or a DateTime object. ```dart import 'package:adhan/adhan.dart'; // Create from year, month, day final date = DateComponents(2024, 1, 15); // Create from DateTime (uses local timezone) final today = DateComponents.from(DateTime.now()); // Create from specific DateTime final specificDate = DateComponents.from(DateTime(2024, 6, 21)); ``` -------------------------------- ### Define Flutter Library Source: https://github.com/iamriajul/adhan-dart/blob/master/example/adhan_example_flutter_app/windows/flutter/CMakeLists.txt Defines the Flutter library, including its DLL, headers, and ICU data file. This section sets up the core Flutter library for use in the project. ```cmake set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") # 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/windows/app.so" PARENT_SCOPE) list(APPEND FLUTTER_LIBRARY_HEADERS "flutter_export.h" "flutter_windows.h" "flutter_messenger.h" "flutter_plugin_registrar.h" "flutter_texture_registrar.h" ) list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Create Coordinates Object Source: https://context7.com/iamriajul/adhan-dart/llms.txt Instantiate a Coordinates object with latitude and longitude. Validation can be enabled to throw an error for invalid values. ```dart import 'package:adhan/adhan.dart'; // Basic coordinate creation final coordinates = Coordinates(35.78056, -78.6389); // With validation enabled (throws ArgumentError for invalid values) final validatedCoords = Coordinates(23.9088, 89.1220, validate: true); // This will throw ArgumentError: latitude must be between -90 and 90 try { final invalid = Coordinates(91.78056, -78.6389, validate: true); } catch (e) { print('Invalid coordinates: $e'); } ``` -------------------------------- ### Define List Prepend Function in CMake Source: https://github.com/iamriajul/adhan-dart/blob/master/example/adhan_example_flutter_app/linux/flutter/CMakeLists.txt Defines a custom CMake function `list_prepend` to add a prefix to each element of a list. This is used as a workaround for older CMake versions that do not support `list(TRANSFORM ... PREPEND ...)`. Ensure this function is available before it's called. ```cmake function(list_prepend LIST_NAME PREFIX) set(NEW_LIST "") foreach(element ${${LIST_NAME}}) list(APPEND NEW_LIST "${PREFIX}${element}") endforeach(element) set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) endfunction() ``` -------------------------------- ### Flutter Subdirectory Inclusion Source: https://github.com/iamriajul/adhan-dart/blob/master/example/adhan_example_flutter_app/windows/CMakeLists.txt Includes the Flutter managed directory and the runner subdirectory for building the application. Also includes generated plugin build rules. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) add_subdirectory("runner") include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Apply Custom Prayer Time Adjustments Source: https://context7.com/iamriajul/adhan-dart/llms.txt Apply custom time adjustments in minutes to individual prayer times. Positive values shift times later, negative values shift times earlier. Demonstrates adjustments for Fajr, Sunrise, Dhuhr, Asr, Maghrib, and Isha. ```dart import 'package:adhan/adhan.dart'; import 'package:intl/intl.dart'; final coordinates = Coordinates(33.4484, -112.0740); // Phoenix, AZ final date = DateComponents(2024, 1, 15); // Get base parameters final params = CalculationMethod.north_america.getParameters(); params.madhab = Madhab.shafi; // Apply adjustments (positive = later, negative = earlier) params.adjustments.fajr = 2; // 2 minutes later params.adjustments.sunrise = -1; // 1 minute earlier params.adjustments.dhuhr = 3; // 3 minutes later params.adjustments.asr = 0; // no adjustment params.adjustments.maghrib = 1; // 1 minute later params.adjustments.isha = -2; // 2 minutes earlier // Calculate adjusted prayer times final prayerTimes = PrayerTimes(coordinates, date, params); print('Adjusted Prayer Times for Phoenix:'); print('Fajr (+2min): ${DateFormat.jm().format(prayerTimes.fajr)}'); print('Sunrise (-1min): ${DateFormat.jm().format(prayerTimes.sunrise)}'); print('Dhuhr (+3min): ${DateFormat.jm().format(prayerTimes.dhuhr)}'); print('Asr (no adj): ${DateFormat.jm().format(prayerTimes.asr)}'); print('Maghrib (+1min): ${DateFormat.jm().format(prayerTimes.maghrib)}'); print('Isha (-2min): ${DateFormat.jm().format(prayerTimes.isha)}'); // Umm al-Qura during Ramadan - add 30 min to Isha final ramadanParams = CalculationMethod.umm_al_qura.getParameters(); ramadanParams.adjustments.isha = 30; // Per Umm al-Qura recommendation ``` -------------------------------- ### Calculate Today's Prayer Times Source: https://github.com/iamriajul/adhan-dart/blob/master/README.md Use this snippet to calculate and print today's prayer times for a given location using default or custom calculation parameters. Ensure you have the 'adhan' package imported. ```dart import 'package:adhan/adhan.dart'; main() { print('My Prayer Times'); final myCoordinates = Coordinates(23.9088, 89.1220); // Replace with your own location lat, lng. final params = CalculationMethod.karachi.getParameters(); params.madhab = Madhab.hanafi; final prayerTimes = PrayerTimes.today(myCoordinates, params); print("---Today's Prayer Times in Your Local Timezone(${prayerTimes.fajr.timeZoneName})---"); print(DateFormat.jm().format(prayerTimes.fajr)); print(DateFormat.jm().format(prayerTimes.sunrise)); print(DateFormat.jm().format(prayerTimes.dhuhr)); print(DateFormat.jm().format(prayerTimes.asr)); print(DateFormat.jm().format(prayerTimes.maghrib)); print(DateFormat.jm().format(prayerTimes.isha)); print('---'); // Custom Timezone Usage. (Most of you won't need this). print('NewYork Prayer Times'); final newYork = Coordinates(35.7750, -78.6336); final nyUtcOffset = Duration(hours: -4); final nyDate = DateComponents(2015, 7, 12); final nyParams = CalculationMethod.north_america.getParameters(); nyParams.madhab = Madhab.hanafi; final nyPrayerTimes = PrayerTimes(newYork, nyDate, nyParams, utcOffset: nyUtcOffset); print(nyPrayerTimes.fajr.timeZoneName); print(DateFormat.jm().format(nyPrayerTimes.fajr)); print(DateFormat.jm().format(nyPrayerTimes.sunrise)); print(DateFormat.jm().format(nyPrayerTimes.dhuhr)); print(DateFormat.jm().format(nyPrayerTimes.asr)); print(DateFormat.jm().format(nyPrayerTimes.maghrib)); print(DateFormat.jm().format(nyPrayerTimes.isha)); } ``` -------------------------------- ### Define C++ Wrapper for Runner Source: https://github.com/iamriajul/adhan-dart/blob/master/example/adhan_example_flutter_app/windows/flutter/CMakeLists.txt Defines a static C++ library for the Flutter runner application. It includes core wrapper sources and app-specific sources, linking against the Flutter library. ```cmake list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_APP "flutter_engine.cc" "flutter_view_controller.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") # Wrapper sources needed for the runner. add_library(flutter_wrapper_app STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_APP} ) apply_standard_settings(flutter_wrapper_app) target_link_libraries(flutter_wrapper_app PUBLIC flutter) target_include_directories(flutter_wrapper_app PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_app flutter_assemble) ``` -------------------------------- ### Calculate Qibla Direction Source: https://context7.com/iamriajul/adhan-dart/llms.txt Calculate the Qibla direction (compass heading) to Makkah from various global locations. Requires Coordinates object. ```dart import 'package:adhan/adhan.dart'; // Calculate Qibla direction from various cities final london = Coordinates(51.5074, -0.1278); final newYork = Coordinates(40.7128, -74.0060); final tokyo = Coordinates(35.6762, 139.6503); final sydney = Coordinates(-33.8688, 151.2093); final qiblaLondon = Qibla(london); final qiblaNewYork = Qibla(newYork); final qiblaTokyo = Qibla(tokyo); final qiblaSydney = Qibla(sydney); print('Qibla Direction (compass degrees):'); print('From London: ${qiblaLondon.direction.toStringAsFixed(2)}°'); // ~119° print('From New York: ${qiblaNewYork.direction.toStringAsFixed(2)}°'); // ~58° print('From Tokyo: ${qiblaTokyo.direction.toStringAsFixed(2)}°'); // ~293° print('From Sydney: ${qiblaSydney.direction.toStringAsFixed(2)}°'); // ~278° // Access Makkah coordinates constant print('Makkah coordinates: ${Qibla.MAKKAH.latitude}, ${Qibla.MAKKAH.longitude}'); ``` -------------------------------- ### CMake Build Configuration Source: https://github.com/iamriajul/adhan-dart/blob/master/example/adhan_example_flutter_app/windows/CMakeLists.txt Defines build configuration options for multi-config generators and sets the default build type if not specified. Ensures Flutter build modes are available. ```cmake get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(IS_MULTICONFIG) set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" CACHE STRING "" FORCE) else() if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif() endif() ``` -------------------------------- ### Determine Current or Next Prayer Source: https://context7.com/iamriajul/adhan-dart/llms.txt Use `currentPrayer()` and `nextPrayer()` to find the active or upcoming prayer based on the current time. You can also check for a specific `DateTime` using `currentPrayerByDateTime()` and `nextPrayerByDateTime()`. ```dart import 'package:adhan/adhan.dart'; final coordinates = Coordinates(21.4225, 39.8262); // Makkah final params = CalculationMethod.umm_al_qura.getParameters(); final prayerTimes = PrayerTimes.today(coordinates, params); // Get current prayer based on now final current = prayerTimes.currentPrayer(); print('Current prayer: $current'); // e.g., Prayer.dhuhr // Get next prayer based on now final next = prayerTimes.nextPrayer(); print('Next prayer: $next'); // e.g., Prayer.asr // Check prayer at a specific time final specificTime = DateTime(2024, 1, 15, 14, 30); // 2:30 PM final currentAtTime = prayerTimes.currentPrayerByDateTime(specificTime); final nextAtTime = prayerTimes.nextPrayerByDateTime(specificTime); print('At 2:30 PM - Current: $currentAtTime, Next: $nextAtTime'); ``` -------------------------------- ### Calculate Qibla Direction Source: https://github.com/iamriajul/adhan-dart/blob/master/README.md Create a Qibla object using coordinates. The direction property provides the Qibla direction in degrees, measured clockwise from North. ```dart final qibla = Qibla(coordinates); /// Qibla direction degree (Compass/Clockwise) qibla.direction ``` -------------------------------- ### Customize Calculation Parameters Source: https://context7.com/iamriajul/adhan-dart/llms.txt Modify calculation parameters such as madhab, high latitude rules, and prayer time adjustments. Fully custom parameters can also be created. ```dart import 'package:adhan/adhan.dart'; // Get base parameters from a calculation method final params = CalculationMethod.karachi.getParameters(); // Set madhab (affects Asr time calculation) params.madhab = Madhab.hanafi; // Later Asr time // params.madhab = Madhab.shafi; // Earlier Asr time (default) // Set high latitude rule for extreme latitudes params.highLatitudeRule = HighLatitudeRule.middle_of_the_night; // params.highLatitudeRule = HighLatitudeRule.seventh_of_the_night; // params.highLatitudeRule = HighLatitudeRule.twilight_angle; // Add custom adjustments in minutes params.adjustments.fajr = 2; // Add 2 minutes to Fajr params.adjustments.sunrise = 0; params.adjustments.dhuhr = 1; params.adjustments.asr = 0; params.adjustments.maghrib = 3; // Add 3 minutes to Maghrib params.adjustments.isha = 0; // Create fully custom parameters final customParams = CalculationParameters( fajrAngle: 18.0, ishaAngle: 17.0, maghribAngle: null, // Optional, for Tehran method ishaInterval: 0, // Minutes after Maghrib (alternative to ishaAngle) madhab: Madhab.hanafi, highLatitudeRule: HighLatitudeRule.middle_of_the_night, ); ``` -------------------------------- ### Calculate Prayer Times Source: https://context7.com/iamriajul/adhan-dart/llms.txt Calculate prayer times for today or a specific date using coordinates and calculation parameters. Supports local timezone, UTC, and custom UTC offsets. ```dart import 'package:adhan/adhan.dart'; import 'package:intl/intl.dart'; // Calculate today's prayer times in local timezone final coordinates = Coordinates(23.9088, 89.1220); final params = CalculationMethod.karachi.getParameters(); params.madhab = Madhab.hanafi; final prayerTimes = PrayerTimes.today(coordinates, params); print("Today's Prayer Times (${prayerTimes.fajr.timeZoneName}):"); print('Fajr: ${DateFormat.jm().format(prayerTimes.fajr)}'); print('Sunrise: ${DateFormat.jm().format(prayerTimes.sunrise)}'); print('Dhuhr: ${DateFormat.jm().format(prayerTimes.dhuhr)}'); print('Asr: ${DateFormat.jm().format(prayerTimes.asr)}'); print('Maghrib: ${DateFormat.jm().format(prayerTimes.maghrib)}'); print('Isha: ${DateFormat.jm().format(prayerTimes.isha)}'); // Calculate for a specific date final date = DateComponents(2024, 6, 21); final specificPrayerTimes = PrayerTimes(coordinates, date, params); // With custom UTC offset for different timezone final newYork = Coordinates(40.7128, -74.0060); final nyOffset = Duration(hours: -4); // EDT final nyParams = CalculationMethod.north_america.getParameters(); final nyPrayerTimes = PrayerTimes(newYork, date, nyParams, utcOffset: nyOffset); // Get UTC times directly final utcPrayerTimes = PrayerTimes.utc(coordinates, date, params); // Get times with specific UTC offset final offsetPrayerTimes = PrayerTimes.utcOffset( coordinates, date, params, Duration(hours: 6) ); ``` -------------------------------- ### Flutter Assemble Custom Target Source: https://github.com/iamriajul/adhan-dart/blob/master/example/adhan_example_flutter_app/windows/flutter/CMakeLists.txt Defines a custom target 'flutter_assemble' that depends on the Flutter library, headers, and wrapper sources. This target ensures that all necessary components are assembled. ```cmake add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ) ```