### Basic TutorialCoachMark Usage Source: https://github.com/rafaelbarbosatec/tutorial_coach_mark/blob/master/README.md Demonstrates how to initialize and display a tutorial using `TutorialCoachMark`. It shows the basic setup with targets and event handlers like `onFinish` and `onClickTargetWithTapPosition`. The snippet also highlights various optional parameters for customization. ```dart import 'package:flutter/material.dart'; import 'package:tutorial_coach_mark/tutorial_coach_mark.dart'; void showTutorial(BuildContext context) { TutorialCoachMark tutorial = TutorialCoachMark( targets: targets, // List colorShadow: Colors.red, // DEFAULT Colors.black // opacityShadow = 0.8, // alignSkip: Alignment.bottomRight, // textSkip: "SKIP", // textStyleSkip: const TextStyle(color: Colors.white), // skipWidget: MyWidget(), // hideSkip: false // showSkipInLastTarget: true, // paddingFocus: 10, // focusAnimationDuration: Duration(milliseconds: 500), // unFocusAnimationDuration: Duration(milliseconds: 500), // pulseAnimationDuration: Duration(milliseconds: 500), // pulseVariation: Tween(begin: 1.0, end: 0.99), // pulseEnable: true, // imageFilter: ImageFilter.blur(sigmaX: 8, sigmaY: 8), // initialFocus: 0, // useSafeArea: true, // finish: (){}, // clickTarget: (TargetFocus) {}, // onClickTargetWithTapPosition: (TargetFocus, TapDownDetails) {}, // clickOverlay: (TargetFocus) {}, onFinish: (){ print("finish"); }, onClickTargetWithTapPosition: (target, tapDetails) { print("target: $target"); print("clicked at position local: ${tapDetails.localPosition} - global: ${tapDetails.globalPosition}"); }, onClickTarget: (target){ print(target); }, onSkip: (){ print("skip"); return true; } )..show(context:context); // tutorial.skip(); // tutorial.finish(); // tutorial.next(); // call next target programmatically // tutorial.previous(); // call previous target programmatically // tutorial.goTo(3); // call target programmatically by index } ``` -------------------------------- ### CMakeLists.txt Configuration Source: https://github.com/rafaelbarbosatec/tutorial_coach_mark/blob/master/example/linux/CMakeLists.txt This snippet details the CMake configuration for a Flutter application. It sets up the project, defines build settings, links necessary libraries (Flutter, GTK), and specifies installation paths for creating a deployable bundle. It includes modern CMake practices and platform-specific settings. ```cmake # Project-level configuration. 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 "example") # The unique GTK application identifier for this application. See: # https://wiki.gnome.org/HowDoI/ChooseApplicationID set(APPLICATION_ID "com.rafaelbarbosatec.example") # 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() # 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() # 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 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) # === 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) # Copy the native assets provided by the build.dart from all packages. set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) # Fully re-copy the assets directory on each build to avoid having stale files ``` -------------------------------- ### CMake: Install Flutter Asset Directory Source: https://github.com/rafaelbarbosatec/tutorial_coach_mark/blob/master/example/linux/CMakeLists.txt Installs the Flutter asset directory to the application bundle. This copies the assets from the project's build directory to the runtime data directory. ```cmake install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### CMake: Install AOT Library (Non-Debug) Source: https://github.com/rafaelbarbosatec/tutorial_coach_mark/blob/master/example/linux/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library on non-Debug builds. This ensures performance optimizations are included only when not in a debug configuration. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### CMake: Remove Flutter Asset Directory Source: https://github.com/rafaelbarbosatec/tutorial_coach_mark/blob/master/example/linux/CMakeLists.txt Removes the Flutter asset directory from the installation bundle. This ensures a clean installation by deleting any pre-existing assets before copying new ones. ```cmake set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) ``` -------------------------------- ### Set Flutter Library and Related Paths Source: https://github.com/rafaelbarbosatec/tutorial_coach_mark/blob/master/example/linux/flutter/CMakeLists.txt Defines key variables for the Flutter build: the path to the shared library (`FLUTTER_LIBRARY`), the ICU data file (`FLUTTER_ICU_DATA_FILE`), the project build directory (`PROJECT_BUILD_DIR`), and the AOT library (`AOT_LIBRARY`). These are published to the parent scope for use in installation steps. ```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) ``` -------------------------------- ### Dart: Define Tutorial Coach Mark Targets Source: https://github.com/rafaelbarbosatec/tutorial_coach_mark/blob/master/README.md This snippet illustrates how to define tutorial targets using the `tutorial_coach_mark` package in Flutter. It shows the creation of `TargetFocus` objects, each associated with a `keyTarget` and a list of `TargetContent` elements, which include text and styling for the tutorial overlay. Dependencies include `flutter/material.dart` and `tutorial_coach_mark/tutorial_coach_mark.dart`. Assumes `keyButton`, `keyButton4`, and `keyButton5` are defined `GlobalKey`s elsewhere in the application. ```dart import 'package:flutter/material.dart'; import 'package:tutorial_coach_mark/tutorial_coach_mark.dart'; List targets = List(); @override void initState() { targets.add( TargetFocus( identify: "Target 1", keyTarget: keyButton, contents: [ TargetContent( align: ContentAlign.bottom, child: Container( child:Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "Titulo lorem ipsum", style: TextStyle( fontWeight: FontWeight.bold, color: Colors.white, fontSize: 20.0 ), ), Padding( padding: const EdgeInsets.only(top: 10.0), child: Text("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin pulvinar tortor eget maximus iaculis.", style: TextStyle( color: Colors.white ), ), ) ], ), ) ) ] ) ); targets.add( TargetFocus( identify: "Target 2", keyTarget: keyButton4, contents: [ TargetContent( align: ContentAlign.left, child: Container( child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "Multiples content", style: TextStyle( fontWeight: FontWeight.bold, color: Colors.white, fontSize: 20.0 ), ), Padding( padding: const EdgeInsets.only(top: 10.0), child: Text("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin pulvinar tortor eget maximus iaculis.", style: TextStyle( color: Colors.white ), ), ) ], ), ) ), TargetContent( align: ContentAlign.top, child: Container( child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "Multiples content", style: TextStyle( fontWeight: FontWeight.bold, color: Colors.white, fontSize: 20.0 ), ), Padding( padding: const EdgeInsets.only(top: 10.0), child: Text("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin pulvinar tortor eget maximus iaculis.", style: TextStyle( color: Colors.white ), ), ) ], ), ) ) ] ) ); targets.add( TargetFocus( identify: "Target 3", keyTarget: keyButton5, contents: [ TargetContent( align: ContentAlign.right, child: Container( child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "Title lorem ipsum", style: TextStyle( fontWeight: FontWeight.bold, color: Colors.white, fontSize: 20.0 ), ), Padding( padding: const EdgeInsets.only(top: 10.0), child: Text("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin pulvinar tortor eget maximus iaculis.", style: TextStyle( ``` -------------------------------- ### Open Flutter Xcode Workspace Source: https://github.com/rafaelbarbosatec/tutorial_coach_mark/blob/master/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md Opens the Flutter project's Xcode workspace to access and modify the Assets.xcassets catalog for customizing launch screen images. ```shell open ios/Runner.xcworkspace ``` -------------------------------- ### Tutorial Coach Mark Widget Structure Source: https://github.com/rafaelbarbosatec/tutorial_coach_mark/blob/master/README.md Defines the structure and configuration options for the Tutorial Coach Mark widget in Dart. It includes parameters for targets, shadow color, and click handlers. ```dart TutorialCoachMark( targets: targets, // List colorShadow: Colors.red, // DEFAULT Colors.black // alignSkip: Alignment.bottomRight, // textSkip: "SKIP", // paddingFocus: 10, // opacityShadow: 0.8, onClickTarget: (target){ print(target); }, onClickTargetWithTapPosition: (target, tapDetails) { print("target: $target"); print("clicked at position local: ${tapDetails.localPosition} - global: ${tapDetails.globalPosition}"); }, onClickOverlay: (target){ print(target); }, onSkip: (){ print("skip"); return true; }, onFinish: (){ print("finish"); }, )..show(context:context); ``` -------------------------------- ### Find and Check GTK, GLIB, GIO Packages Source: https://github.com/rafaelbarbosatec/tutorial_coach_mark/blob/master/example/linux/flutter/CMakeLists.txt Uses PkgConfig to find and check for required system libraries: GTK, GLIB, and GIO. This ensures necessary dependencies are available and provides their build information 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) ``` -------------------------------- ### Create Flutter Interface Library Source: https://github.com/rafaelbarbosatec/tutorial_coach_mark/blob/master/example/linux/flutter/CMakeLists.txt Creates an INTERFACE library target named 'flutter'. It specifies include directories and links against the Flutter shared library and required system packages (GTK, GLIB, GIO). It also adds a dependency on the `flutter_assemble` target. ```CMake add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") target_link_libraries(flutter INTERFACE PkgConfig::GTK PkgConfig::GLIB PkgConfig::GIO ) add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Configure Flutter Tool Backend Custom Command Source: https://github.com/rafaelbarbosatec/tutorial_coach_mark/blob/master/example/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, using environment variables and build type. The `_phony_` output ensures it runs every time. ```CMake 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 ) ``` -------------------------------- ### Include Generated Configuration Source: https://github.com/rafaelbarbosatec/tutorial_coach_mark/blob/master/example/linux/flutter/CMakeLists.txt Includes a CMake configuration file generated by the Flutter tool. This file provides project-specific settings, variables, and targets necessary for the build process. ```CMake include(${EPHEMERAL_DIR}/generated_config.cmake) ``` -------------------------------- ### Define CMake list_prepend Function Source: https://github.com/rafaelbarbosatec/tutorial_coach_mark/blob/master/example/linux/flutter/CMakeLists.txt Implements a custom CMake function `list_prepend` to add a prefix to each element of a list. This serves as a workaround for older CMake versions (prior to 3.10) that lack the `list(TRANSFORM ... PREPEND ...)` command. ```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() ``` -------------------------------- ### Define Ephemeral Directory Variable Source: https://github.com/rafaelbarbosatec/tutorial_coach_mark/blob/master/example/linux/flutter/CMakeLists.txt Sets a variable `EPHEMERAL_DIR` to point to the 'ephemeral' subdirectory within the current source directory. This directory typically contains generated build artifacts and configuration files. ```CMake set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") ``` -------------------------------- ### Create Flutter Assemble Custom Target Source: https://github.com/rafaelbarbosatec/tutorial_coach_mark/blob/master/example/linux/flutter/CMakeLists.txt Creates a custom target named `flutter_assemble`. This target depends on the Flutter library and its associated headers, ensuring they are built or generated before other targets that might rely on them. ```CMake add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ) ``` -------------------------------- ### Define Flutter Library Headers Source: https://github.com/rafaelbarbosatec/tutorial_coach_mark/blob/master/example/linux/flutter/CMakeLists.txt Appends a list of Flutter Linux GTK header file names to the `FLUTTER_LIBRARY_HEADERS` variable. These headers are essential for compiling applications that use the Flutter engine. ```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 CMake Minimum Version Source: https://github.com/rafaelbarbosatec/tutorial_coach_mark/blob/master/example/linux/flutter/CMakeLists.txt Specifies the minimum required version of CMake for the project. This ensures compatibility with features used in the script, such as specific list commands or variable handling. ```CMake cmake_minimum_required(VERSION 3.10) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.