### Basic CalendarDatePicker2 Widget Setup Source: https://github.com/theideasaler/calendar_date_picker2/blob/main/README.md Demonstrates the minimum required setup for the CalendarDatePicker2 widget, including providing a configuration and an initial date value. ```dart CalendarDatePicker2( config: CalendarDatePicker2Config(), value: _dates, onValueChanged: (dates) => _dates = dates, ); ``` -------------------------------- ### CMake Installation Rules for Runtime Components Source: https://github.com/theideasaler/calendar_date_picker2/blob/main/example/windows/CMakeLists.txt Defines the installation rules for the application's runtime components. This includes setting the installation prefix, installing the main executable, Flutter ICU data, libraries, bundled plugin libraries, and the asset directory. It ensures assets are re-copied on each build to prevent stale files. ```cmake # === Installation === # Support files are copied into place next to the executable, so that it can # run in place. This is done instead of making a separate bundle (as on Linux) # so that building and running from within Visual Studio will work. set(BUILD_BUNDLE_DIR "$") # Make the "install" step default, as it's required to run. 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() # Fully re-copy the assets directory on each build to avoid having stale files # from a previous install. 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 the AOT library on non-Debug builds only. install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Install calendar_date_picker2 Package Source: https://github.com/theideasaler/calendar_date_picker2/blob/main/README.md Add the calendar_date_picker2 package as a dependency in your pubspec.yaml file to include it in your Flutter project. ```yaml dependencies: calendar_date_picker2: ^2.0.1 ``` -------------------------------- ### CMake Build Configuration and Options Source: https://github.com/theideasaler/calendar_date_picker2/blob/main/example/windows/CMakeLists.txt Configures the minimum CMake version, project name, binary name, and installation paths. It dynamically sets build types based on whether the generator is multi-configuration or single-configuration. Profile build settings are derived from Release settings. Unicode support is enabled. ```cmake cmake_minimum_required(VERSION 3.14) project(example LANGUAGES CXX) set(BINARY_NAME "example") cmake_policy(SET CMP0063 NEW) set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") # Configure build options. 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() 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}") # Use Unicode for all projects. add_definitions(-DUNICODE -D_UNICODE) ``` -------------------------------- ### Date Picker with Action Buttons in Flutter Source: https://context7.com/theideasaler/calendar_date_picker2/llms.txt Shows how to use the CalendarDatePicker2WithActionButtons widget, which includes 'OK' and 'CANCEL' buttons for confirming or discarding date selections. This example configures the picker for range selection, customizes button styles, and handles the confirmed and cancelled events. It depends on the flutter/material and calendar_date_picker2 packages. ```dart import 'package:flutter/material.dart'; import 'package:calendar_date_picker2/calendar_date_picker2.dart'; class DatePickerWithButtonsExample extends StatefulWidget { @override State createState() => _DatePickerWithButtonsExampleState(); } class _DatePickerWithButtonsExampleState extends State { List _confirmedDates = []; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('Date Picker With Buttons')), body: Column( children: [ CalendarDatePicker2WithActionButtons( config: CalendarDatePicker2WithActionButtonsConfig( calendarType: CalendarDatePicker2Type.range, firstDayOfWeek: 1, gapBetweenCalendarAndButtons: 16, selectedDayHighlightColor: Colors.purple[800], selectedDayTextStyle: TextStyle(color: Colors.white, fontWeight: FontWeight.w700), okButtonTextStyle: TextStyle( color: Colors.purple[800], fontWeight: FontWeight.bold, fontSize: 16, ), cancelButtonTextStyle: TextStyle( color: Colors.grey[600], fontWeight: FontWeight.bold, fontSize: 16, ), buttonPadding: EdgeInsets.symmetric(vertical: 12, horizontal: 20), ), value: _confirmedDates, onValueChanged: (dates) { setState(() { _confirmedDates = dates; }); print('Confirmed dates: $dates'); }, onCancelTapped: () { print('Selection cancelled'); }, onOkTapped: () { print('Selection confirmed'); }, ), SizedBox(height: 20), Text('Confirmed dates: ${_confirmedDates.length}'), ], ), ); } } ``` -------------------------------- ### Flutter: Single Date Selection with CalendarDatePicker2 Source: https://context7.com/theideasaler/calendar_date_picker2/llms.txt Demonstrates how to use the `CalendarDatePicker2` widget for selecting a single date. This example configures the `calendarType` to `single` and shows how to handle the selected date changes. ```dart import 'package:flutter/material.dart'; import 'package:calendar_date_picker2/calendar_date_picker2.dart'; class SingleDatePickerExample extends StatefulWidget { @override State createState() => _SingleDatePickerExampleState(); } class _SingleDatePickerExampleState extends State { List _dates = [DateTime.now()]; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('Single Date Picker')), body: Column( children: [ CalendarDatePicker2( config: CalendarDatePicker2Config( calendarType: CalendarDatePicker2Type.single, selectedDayHighlightColor: Colors.blue[800], weekdayLabels: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], weekdayLabelTextStyle: TextStyle( color: Colors.black87, fontWeight: FontWeight.bold, ), firstDayOfWeek: 1, controlsHeight: 50, controlsTextStyle: TextStyle( color: Colors.black, fontSize: 15, fontWeight: FontWeight.bold, ), dayTextStyle: TextStyle(color: Colors.black, fontWeight: FontWeight.w400), selectedDayTextStyle: TextStyle(color: Colors.white, fontWeight: FontWeight.w700), ), value: _dates, onValueChanged: (dates) { setState(() { _dates = dates; }); print('Selected date: ${dates.first}'); }, ), SizedBox(height: 20), Text('Selected: ${_dates.first?.toString() ?? "None"}'), ], ), ); } } ``` -------------------------------- ### Custom Calendar Styling with Flutter Source: https://context7.com/theideasaler/calendar_date_picker2/llms.txt This Flutter code snippet demonstrates how to apply custom styles and themes to the CalendarDatePicker2 widget. It utilizes `CalendarDatePicker2Config` to modify various visual aspects, including text styles, colors, and border radii, to achieve a unique look and feel for the calendar component. The example focuses on range selection and integrates custom styling for a more branded user experience. ```dart import 'package:flutter/material.dart'; import 'package:calendar_date_picker2/calendar_date_picker2.dart'; class CustomStyledExample extends StatefulWidget { @override State createState() => _CustomStyledExampleState(); } class _CustomStyledExampleState extends State { List _dates = []; @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.grey[100], appBar: AppBar(title: Text('Custom Styled Calendar')), body: Center( child: Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(20), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.1), blurRadius: 10, spreadRadius: 2, ), ], ), margin: EdgeInsets.all(20), padding: EdgeInsets.all(16), child: CalendarDatePicker2( config: CalendarDatePicker2Config( calendarType: CalendarDatePicker2Type.range, firstDayOfWeek: 1, weekdayLabelTextStyle: TextStyle( color: Colors.purple[700], fontWeight: FontWeight.bold, fontSize: 14, ), controlsTextStyle: TextStyle( color: Colors.purple[900], fontSize: 16, fontWeight: FontWeight.w600, ), dayTextStyle: TextStyle( color: Colors.grey[800], fontSize: 14, ), selectedDayTextStyle: TextStyle( color: Colors.white, fontWeight: FontWeight.bold, fontSize: 16, ), todayTextStyle: TextStyle( color: Colors.purple[600], fontWeight: FontWeight.bold, fontSize: 14, ), selectedDayHighlightColor: Colors.purple[600], selectedRangeHighlightColor: Colors.purple[100], dayBorderRadius: BorderRadius.circular(12), yearBorderRadius: BorderRadius.circular(8), daySplashColor: Colors.purple[50], dynamicCalendarRows: true, ), value: _dates, onValueChanged: (dates) => setState(() => _dates = dates), ), ), ), ); } } ``` -------------------------------- ### Custom Calendar Date Picker UI (Dart) Source: https://github.com/theideasaler/calendar_date_picker2/blob/main/README.md Demonstrates creating a custom calendar date picker UI by configuring various properties like first day of the week, calendar type, text styles, and custom builders for days and years. This allows for a highly personalized user experience. ```dart CalendarDatePicker2WithActionButtons( config: CalendarDatePicker2WithActionButtonsConfig( firstDayOfWeek: 1, calendarType: CalendarDatePicker2Type.range, selectedDayTextStyle: TextStyle(color: Colors.white, fontWeight: FontWeight.w700), selectedDayHighlightColor: Colors.purple[800], centerAlignModePicker: true, customModePickerIcon: SizedBox(), dayBuilder: _yourDayBuilder, yearBuilder: _yourYearBuilder, ), value: _dates, onValueChanged: (dates) => _dates = dates, ); ``` -------------------------------- ### Configure Executable Target with CMake Source: https://github.com/theideasaler/calendar_date_picker2/blob/main/example/windows/runner/CMakeLists.txt This CMake snippet defines the main executable for the Windows runner application. It lists all source files, including C++ files, generated files, and resource scripts, and applies standard build settings. It also sets specific compile definitions and links essential libraries. ```cmake cmake_minimum_required(VERSION 3.14) project(runner LANGUAGES CXX) 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" ) apply_standard_settings(${BINARY_NAME}) target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Assemble Flutter Build Artifacts (CMake) Source: https://github.com/theideasaler/calendar_date_picker2/blob/main/example/windows/flutter/CMakeLists.txt This CMake snippet defines a custom command and target to assemble Flutter build artifacts. It uses the 'tool_backend.bat' to generate necessary files like DLLs, headers, and wrapper sources. A phony output file ensures the command runs on every build. ```cmake # === Flutter tool backend === # _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_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ) ``` -------------------------------- ### Display CalendarDatePicker2 as a Dialog Source: https://github.com/theideasaler/calendar_date_picker2/blob/main/README.md Shows how to use the built-in showCalendarDatePicker2Dialog function to display the calendar picker within a dialog. Requires context, configuration, and dialog size. ```dart ... var results = await showCalendarDatePicker2Dialog( context: context, config: CalendarDatePicker2WithActionButtonsConfig(), dialogSize: const Size(325, 400), value: _dates, borderRadius: BorderRadius.circular(15), ); ... ``` -------------------------------- ### Enable Multi-language Support in MaterialApp (Dart) Source: https://github.com/theideasaler/calendar_date_picker2/blob/main/README.md Shows how to enable multi-language support for the calendar picker by adding global material localizations delegates and defining supported locales within the MaterialApp widget. This ensures the calendar can be displayed in various languages. ```dart MaterialApp( localizationsDelegates: GlobalMaterialLocalizations.delegates, supportedLocales: const [ Locale('en', ''), Locale('zh', ''), Locale('ru', ''), Locale('es', ''), Locale('hi', ''), ], ... ); ``` -------------------------------- ### Configure Flutter Library and Headers (CMake) Source: https://github.com/theideasaler/calendar_date_picker2/blob/main/example/windows/flutter/CMakeLists.txt This snippet configures the Flutter library and its associated headers. It sets up include directories and links the Flutter library. Dependencies on 'flutter_assemble' ensure the library is ready before use. ```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) # TODO: Move the rest of this into files in ephemeral. See # https://github.com/flutter/flutter/issues/57146. set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") # === Flutter Library === 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}/ữa") add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Calendar Date Picker Properties Source: https://github.com/theideasaler/calendar_date_picker2/blob/main/README.md Configuration options for the calendar date picker component. ```APIDOC ## Calendar Date Picker Configuration ### Description This section details the properties available for configuring the Calendar Date Picker component, including display modes, text handling, styling, and selection logic. ### Method N/A (Configuration Object) ### Endpoint N/A (Component Configuration) ### Parameters #### Component Properties - **disableModePicker** (bool?) - Flag to disable mode picker and hide the toggle icon. - **modePickerTextHandler** (ModePickerTextHandler?) - Function to control mode picker displayed text. - **modePickerBuilder** (ModePickerBuilder?) - Function to provide full control over mode picker UI. - **customModePickerIcon** (Widget?) - Custom icon for the mode picker button icon. - **useAbbrLabelForMonthModePicker** (bool?) - Use Abbreviation label for month mode picker, only works when month picker is enabled. - **dayViewController** (PageController?) - Custom page controller for the calendar day view. - **dayMaxWidth** (double?) - Max width of day widget. When [dayMaxWidth] is not null, it will override default size settings. - **dayBorderRadius** (BorderRadius?) - Custom border radius for day indicator. - **dayTextStyle** (TextStyle?) - Custom text style for calendar day(s). - **todayTextStyle** (TextStyle?) - Custom text style for current calendar day(s). - **disabledDayTextStyle** (TextStyle?) - Custom text style for disabled calendar day(s). - **dayTextStylePredicate** (DayTextStylePredicate?) - Function to provide full control over calendar day(s) text style. - **selectedDayHighlightColor** (Color?) - The highlight color selected day. - **selectedDayTextStyle** (TextStyle?) - Custom text style for selected calendar day(s). - **selectableDayPredicate** (SelectableDayPredicate?) - Function to provide full control over which dates in the calendar can be selected. - **selectedRangeDayTextStyle** (TextStyle?) - Custom text style for selected range calendar day(s). - **selectedRangeHighlightColor** (Color?) - The highlight color for day(s) included in the selected range. - **selectedRangeDecorationPredicate** (SelectedRangeDecorationPredicate?) - Predicate to determine the day widget box decoration for a day in selected range. - **selectedRangeHighlightBuilder** (SelectedRangeHighlightBuilder?) - Function to provide full control over range picker highlight. - **daySplashColor** (Color?) - The splash color of the day widget. - **dayBuilder** (DayBuilder?) - Function to provide full control over day widget UI. - **dayModeScrollDirection** (Axis?) - Axis scroll direction for [CalendarDatePicker2Mode.day] mode. - **monthViewController** (ScrollController?) - Custom scroll controller for the calendar month view. - **monthBuilder** (MonthBuilder?) - Function to provide full control over month widget UI. - **hideMonthPickerDividers** (bool?) - Flag to hide dividers on month picker. - **selectableMonthPredicate** (SelectableMonthPredicate?) - Function to provide full control over which month in the month list can be selected. - **disableMonthPicker** (bool?) - Flag to disable month picker. ### Request Example ```json { "disableModePicker": true, "dayMaxWidth": 50.0, "todayTextStyle": { "fontWeight": "bold" } } ``` ### Response #### Success Response (200) N/A (This is a configuration object, not an API response) #### Response Example N/A ``` -------------------------------- ### Build Flutter C++ Wrapper for Plugins (CMake) Source: https://github.com/theideasaler/calendar_date_picker2/blob/main/example/windows/flutter/CMakeLists.txt This CMake snippet defines a static library for the Flutter C++ wrapper used by plugins. It includes core and plugin-specific source files, applies standard build settings, and configures visibility and include paths. It also links against the main Flutter library and depends on 'flutter_assemble'. ```cmake # === Wrapper === list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/ữa") list(APPEND CPP_WRAPPER_SOURCES_PLUGIN "plugin_registrar.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/ữa") list(APPEND CPP_WRAPPER_SOURCES_APP "flutter_engine.cc" "flutter_view_controller.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/ữa") # 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) ``` -------------------------------- ### Build Flutter C++ Wrapper for Runner (CMake) Source: https://github.com/theideasaler/calendar_date_picker2/blob/main/example/windows/flutter/CMakeLists.txt This CMake snippet defines a static library for the Flutter C++ wrapper used by the application runner. It includes core and application-specific source files, links against the main Flutter library, and sets up include paths. It also depends on 'flutter_assemble'. ```cmake # 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) ``` -------------------------------- ### CMake Function for Standard Compilation Settings Source: https://github.com/theideasaler/calendar_date_picker2/blob/main/example/windows/CMakeLists.txt Defines a reusable CMake function `APPLY_STANDARD_SETTINGS` that applies common compilation features, options, and definitions to a target. This includes setting the C++ standard to C++17, applying specific compiler warnings and error flags, and defining exception handling behavior. ```cmake # Compilation settings that should be applied to most targets. 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 "$<$:_DEBUG>") endfunction() ``` -------------------------------- ### Flutter Multi-Language Calendar Date Picker Source: https://context7.com/theideasaler/calendar_date_picker2/llms.txt Demonstrates how to enable multi-language support for the calendar using Flutter's localization delegates. It configures supported locales and sets a default locale for the calendar widget. No external dependencies are required beyond the standard Flutter localization packages. ```dart import 'package:flutter/material.dart'; import 'package:calendar_date_picker2/calendar_date_picker2.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Multi-Language Calendar', localizationsDelegates: [ GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, GlobalCupertinoLocalizations.delegate, ], supportedLocales: [ Locale('en', ''), // English Locale('zh', ''), // Chinese Locale('ru', ''), // Russian Locale('es', ''), // Spanish Locale('hi', ''), // Hindi Locale('he', ''), // Hebrew Locale('ko', ''), // Korean ], locale: Locale('es', ''), // Set Spanish as default home: MultiLanguageExample(), ); } } class MultiLanguageExample extends StatefulWidget { @override State createState() => _MultiLanguageExampleState(); } class _MultiLanguageExampleState extends State { List _dates = []; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('Calendario en Español')), body: CalendarDatePicker2( config: CalendarDatePicker2Config( calendarType: CalendarDatePicker2Type.single, firstDayOfWeek: 1, selectedDayHighlightColor: Colors.orange[800], ), value: _dates, onValueChanged: (dates) => setState(() => _dates = dates), ), ); } } ``` -------------------------------- ### Multi Date Picker Configuration Source: https://github.com/theideasaler/calendar_date_picker2/blob/main/README.md Configures the CalendarDatePicker2 widget to allow the selection of multiple dates by setting the calendarType to CalendarDatePicker2Type.multi. ```dart CalendarDatePicker2( config: CalendarDatePicker2Config( calendarType: CalendarDatePicker2Type.multi, ), value: _dates, onValueChanged: (dates) => _dates = dates, ); ``` -------------------------------- ### Load Main Dart JS with Service Worker Fallback - JavaScript Source: https://github.com/theideasaler/calendar_date_picker2/blob/main/example/web/index.html This JavaScript code snippet handles the dynamic loading of 'main.dart.js'. It first attempts to register and utilize a service worker to serve the application. If the service worker registration or activation fails after a timeout, it falls back to directly appending the 'main.dart.js' script tag to the document body. This ensures application availability even if service workers are not supported or encounter issues. ```javascript var serviceWorkerVersion = null; var scriptLoaded = false; function loadMainDartJs() { if (scriptLoaded) { return; } scriptLoaded = true; var scriptTag = document.createElement('script'); scriptTag.src = 'main.dart.js'; scriptTag.type = 'application/javascript'; document.body.append(scriptTag); } if ('serviceWorker' in navigator) { // Service workers are supported. Use them. window.addEventListener('load', function () { // Wait for registration to finish before dropping the