### Run Example App Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/CLAUDE.md Navigates to the example directory, installs dependencies, and runs the example application. Use only when explicitly instructed. ```bash cd example && flutter pub get && flutter run ``` -------------------------------- ### Installation Bundle Configuration Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/example/linux/CMakeLists.txt Configures the installation prefix to create a relocatable bundle in the build directory and ensures a clean build bundle directory on each install. ```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(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 Dependencies Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/CLAUDE.md Installs the necessary dependencies for the Flutter project. ```bash flutter pub get ``` -------------------------------- ### Install Application Components Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/example/linux/CMakeLists.txt Installs the main executable, ICU data, Flutter library, bundled plugin libraries, and native assets into the application bundle. ```cmake 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) set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### AI Assistant Response Example Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/doc/usage_guide.md Showcase an AI assistant's response using streaming text with markdown formatting. This example uses a fast typing speed and fade-in effect for a dynamic feel. ```dart StreamingTextMarkdown( text: '''# Welcome to AI Assistant I can help you with: * Writing code * Answering questions * **Formatting** text with *markdown* What would you like to know?''', fadeInEnabled: true, typingSpeed: Duration(milliseconds: 30), padding: EdgeInsets.all(16), ) ``` -------------------------------- ### Install flutter_streaming_text_markdown Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/README.md Add this to your package's pubspec.yaml file to include the library in your project. ```yaml dependencies: flutter_streaming_text_markdown: ^1.9.0 ``` -------------------------------- ### Install Flutter Assets Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/example/linux/CMakeLists.txt Installs the Flutter assets directory into the application bundle, ensuring it's re-copied on each build to avoid stale files. ```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 AOT Library Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/example/linux/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compilation library on non-Debug builds. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Chat Bubble Integration Example Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/doc/usage_guide.md Display streaming text within a chat bubble UI. This example uses a Container with BoxDecoration to style the bubble and applies word-by-word animation. ```dart Container( decoration: BoxDecoration( color: Colors.blue[100], borderRadius: BorderRadius.circular(12), ), margin: EdgeInsets.symmetric(vertical: 8, horizontal: 16), child: StreamingTextMarkdown( text: 'This is a message in a **chat bubble** with *formatting*.', padding: EdgeInsets.all(12), wordByWord: true, typingSpeed: Duration(milliseconds: 150), ), ) ``` -------------------------------- ### Scientific Documentation Example with LaTeX Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/README.md A practical example demonstrating the use of LaTeX for scientific formulas in physics, including Newton's laws, energy conservation, and the wave equation. This snippet utilizes the `StreamingTextMarkdown.claude` constructor and enables LaTeX rendering. ```dart StreamingTextMarkdown.claude( text: '''# Physics Fundamentals ## Newton's Laws Newton's second law states that force equals mass times acceleration: $$F = ma$$ ## Energy Conservation The relationship between kinetic and potential energy: $$KE + PE = \text{constant}$$ Where kinetic energy is $KE = \frac{1}{2}mv^2$ and potential energy varies by system. ## Wave Equation The fundamental wave equation in physics: $$\frac{\partial^2 y}{\partial t^2} = \frac{1}{v^2}\frac{\partial^2 y}{\partial x^2}$$ This describes how waves propagate through different media.''', latexEnabled: true, ) ``` -------------------------------- ### Accessibility Implementation for Streaming Text Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/doc/tasks.md Proposed Dart code structure for implementing screen reader support in streaming text components. This serves as a starting point for building accessible UI elements. ```dart // Proposed implementation for screen reader support class AccessibleStreamingText extends StatefulWidget { // Implementation details } ``` -------------------------------- ### Find and Link System Libraries Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/example/linux/flutter/CMakeLists.txt Uses PkgConfig to find and check for required system libraries like GTK, GLIB, and GIO, 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) ``` -------------------------------- ### Apply Standard Build Settings Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/example/windows/runner/CMakeLists.txt Applies a predefined set of standard build settings to the executable target. This can be removed if custom build settings are required. ```cmake apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Dry Run and Verification Commands Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/doc/PUBLISHING_CHECKLIST.md Execute these commands to verify your package's readiness for publishing and to perform essential checks. ```bash dart pub publish --dry-run ``` ```bash flutter analyze ``` ```bash flutter test ``` ```bash cd example && flutter run ``` ```bash flutter pub deps ``` -------------------------------- ### Project and Build Configuration Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/example/linux/CMakeLists.txt Sets the minimum CMake version, project name, executable name, and application ID. It also configures build types and opts into modern CMake behaviors. ```cmake cmake_minimum_required(VERSION 3.13) project(runner LANGUAGES CXX) set(BINARY_NAME "example") set(APPLICATION_ID "com.example.example") cmake_policy(SET CMP0063 NEW) set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 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() 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/hooshyar/flutter_streaming_text_markdown/blob/main/example/linux/runner/CMakeLists.txt Applies a standard set of build settings to the application target. This can be removed if custom build settings are required. ```cmake # Apply the standard set of build settings. This can be removed for applications # that need different build settings. apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Run Single Test File Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/CLAUDE.md Executes tests from a specific file, useful for targeted testing. ```bash flutter test test/latex_processor_test.dart ``` -------------------------------- ### Flutter and System Dependencies Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/example/linux/CMakeLists.txt Includes the Flutter managed directory and finds system-level GTK dependencies using PkgConfig. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) add_subdirectory("runner") add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Include Generated Plugins Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/example/linux/CMakeLists.txt Includes the CMake script that manages the building and integration of generated plugins. ```cmake include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Animation Presets Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/README.md Provides built-in and custom presets for animating streaming text and markdown. Presets like chatGPT, claude, and typewriter offer different animation styles and speeds. Custom presets can be created using `LLMAnimationPresets` or by specifying speed with `bySpeed`. ```APIDOC ## Animation Presets ### Built-in Constructors | Constructor | Speed | Style | Best For | |-------------|-------|--------|----------| | `.chatGPT()` | Fast (15ms) | Character-by-character with fade | ChatGPT-like responses | | `.claude()` | Smooth (80ms) | Word-by-word with gentle fade | Claude-like detailed explanations | | `.typewriter()` | Classic (50ms) | Character-by-character, no fade | Retro typewriter effect | | `.instant()` | Immediate | No animation | When speed is priority | ### Custom Presets ```dart // Using preset configurations StreamingTextMarkdown.fromPreset( text: response, preset: LLMAnimationPresets.professional, ) // Available presets LLMAnimationPresets.chatGPT // Fast, character-based LLMAnimationPresets.claude // Smooth, word-based LLMAnimationPresets.typewriter // Classic typing LLMAnimationPresets.gentle // Slow, elegant LLMAnimationPresets.bouncy // Playful bounce effect LLMAnimationPresets.chunks // Fast chunk-based LLMAnimationPresets.rtlOptimized // Optimized for Arabic/RTL LLMAnimationPresets.professional // Business presentations // Speed-based presets LLMAnimationPresets.bySpeed(AnimationSpeed.fast) LLMAnimationPresets.bySpeed(AnimationSpeed.medium) LLMAnimationPresets.bySpeed(AnimationSpeed.slow) ``` ``` -------------------------------- ### Basic LaTeX Usage in StreamingTextMarkdown Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/README.md Demonstrates how to render inline and block LaTeX equations within the text. Ensure both `latexEnabled` and `markdownEnabled` are set to true. ```dart StreamingTextMarkdown( text: '''# Mathematical Equations Inline equations work great: $E = mc^2$ and $x = 5$. Block equations are perfect for complex formulas: $$x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$$ This is the quadratic formula!''', latexEnabled: true, markdownEnabled: true, ) ``` -------------------------------- ### Applying StreamingTextTheme with ThemeData Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/doc/api_reference.md Demonstrates how to integrate `StreamingTextTheme` into your application's `ThemeData` using the `extensions` property. This allows for global theme configuration. ```dart MaterialApp( theme: ThemeData( extensions: [ StreamingTextTheme( textStyle: TextStyle(/* ... */), markdownStyleSheet: MarkdownStyleSheet(/* ... */), ), ], ), ) ``` -------------------------------- ### Use Built-in Animation Presets Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/README.md Instantiate StreamingTextMarkdown with a predefined animation preset. Available presets include chatGPT, claude, typewriter, gentle, bouncy, chunks, rtlOptimized, and professional. ```dart StreamingTextMarkdown.fromPreset( text: response, preset: LLMAnimationPresets.professional, ) ``` -------------------------------- ### Run All Tests Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/CLAUDE.md Executes all tests defined within the Flutter project. ```bash flutter test ``` -------------------------------- ### Create Static Library for Flutter Wrapper Plugin Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/example/windows/flutter/CMakeLists.txt Builds a static library for the Flutter C++ wrapper, specifically for plugin integration. It includes core and plugin-specific source files and links 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}/") 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) ``` -------------------------------- ### Themed LaTeX Styling Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/README.md Illustrates how to apply global LaTeX styling using a `StreamingTextTheme`. This allows consistent styling for inline and block LaTeX across multiple widgets. ```dart // Global LaTeX styling through theme final customTheme = StreamingTextTheme( inlineLatexStyle: TextStyle(color: Colors.blue), blockLatexStyle: TextStyle(color: Colors.purple), latexScale: 1.3, latexFadeInEnabled: false, ); StreamingTextMarkdown( text: 'Themed math: $\alpha + \beta = \gamma$', theme: customTheme, latexEnabled: true, ) ``` -------------------------------- ### Configure Flutter Tool Backend Custom Command Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/example/windows/flutter/CMakeLists.txt Sets up a custom command to execute the Flutter tool backend script. This command generates necessary build artifacts like the Flutter library and headers, and it's triggered by the flutter_assemble custom target. ```cmake 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" ${FLUTTER_TARGET_PLATFORM} $ VERBATIM ) add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ) ``` -------------------------------- ### Set Include Directories Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/example/linux/runner/CMakeLists.txt Specifies the include directories for the application target, ensuring that header files can be found during compilation. The source directory is added for general access. ```cmake target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") ``` -------------------------------- ### Add Preprocessor Definitions Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/example/linux/runner/CMakeLists.txt Adds preprocessor definitions for the application ID, making it available during compilation. ```cmake # Add preprocessor definitions for the application ID. add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") ``` -------------------------------- ### List of Available Animation Presets Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/README.md This snippet lists the available LLMAnimationPresets for customizing text streaming effects. Presets range from fast character-based animations to slower, more elegant styles. ```dart LLMAnimationPresets.chatGPT // Fast, character-based LLMAnimationPresets.claude // Smooth, word-based LLMAnimationPresets.typewriter // Classic typing LLMAnimationPresets.gentle // Slow, elegant LLMAnimationPresets.bouncy // Playful bounce effect LLMAnimationPresets.chunks // Fast chunk-based LLMAnimationPresets.rtlOptimized // Optimized for Arabic/RTL LLMAnimationPresets.professional // Business presentations ``` -------------------------------- ### Link Libraries and Include Directories Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/example/windows/runner/CMakeLists.txt Links the necessary Flutter libraries and the Windows Desktop SDK library. It also adds the source directory to the include paths for accessing project headers. ```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}") ``` -------------------------------- ### Static Analysis Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/CLAUDE.md Performs static analysis on the Flutter project to identify potential issues. ```bash flutter analyze ``` -------------------------------- ### Link Dependency Libraries Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/example/linux/runner/CMakeLists.txt Links the application target against necessary libraries, including the Flutter engine and GTK for Linux integration. Add any other application-specific dependencies here. ```cmake # Add dependency libraries. Add any application-specific dependencies here. target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) ``` -------------------------------- ### DefaultStreamProvider Class Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/doc/api_reference.md Default implementation of the StreamProvider interface, handling text streaming with configurable typing speed and chunking. ```APIDOC ## DefaultStreamProvider Class ### Description Default implementation of the StreamProvider interface, handling text streaming with configurable typing speed and chunking. ### Constructor ```dart DefaultStreamProvider({ required this.typingSpeed, this.wordByWord = false, this.chunkSize = 1, }) ``` ### Parameters #### Constructor Parameters - **typingSpeed** (Duration) - Required - Speed at which each unit appears - **wordByWord** (bool) - Optional - Whether to animate word by word (Default: false) - **chunkSize** (int) - Optional - Characters to reveal at once (when not wordByWord) (Default: 1) ### Implemented Method ```dart @override Stream provideStream(String text); ``` ``` -------------------------------- ### Import Package Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/doc/usage_guide.md Import the package into your Dart file to use its widgets. ```dart import 'package:flutter_streaming_text_markdown/flutter_streaming_text_markdown.dart'; ``` -------------------------------- ### StreamingTextMarkdown Widget Constructor Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/doc/api_reference.md Defines the parameters for the `StreamingTextMarkdown` widget, used for displaying streaming text with markdown support. Configure text content, styling, animation, and markdown rendering. ```dart StreamingTextMarkdown( text: String, initialText: String, styleSheet: MarkdownStyleSheet?, theme: StreamingTextTheme?, padding: EdgeInsets?, autoScroll: bool, fadeInEnabled: bool, fadeInDuration: Duration, fadeInCurve: Curve, wordByWord: bool, chunkSize: int, typingSpeed: Duration, textDirection: TextDirection?, textAlign: TextAlign?, markdownEnabled: bool, ) ``` -------------------------------- ### Executable Output Directory Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/example/linux/CMakeLists.txt Sets the runtime output directory for the executable to a subdirectory to prevent users from running the unbundled copy. ```cmake set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) ``` -------------------------------- ### DefaultStreamProvider Class Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/doc/api_reference.md Default implementation of the `StreamProvider` interface. Configurable with typing speed, word-by-word animation, and chunk size for text streaming. ```dart class DefaultStreamProvider implements StreamProvider { DefaultStreamProvider({ required this.typingSpeed, this.wordByWord = false, this.chunkSize = 1, }); final Duration typingSpeed; final bool wordByWord; final int chunkSize; @override Stream provideStream(String text); } ``` -------------------------------- ### Create Static Library for Flutter Wrapper App Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/example/windows/flutter/CMakeLists.txt Builds a static library for the Flutter C++ wrapper, intended for the application runner. It includes core and application-specific source files and links 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}/") 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" ) ``` -------------------------------- ### Configuring LaTeX Appearance Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/README.md Shows how to customize the appearance of LaTeX expressions using `latexStyle`, `latexScale`, and `latexFadeInEnabled`. Setting `latexFadeInEnabled` to false is recommended for performance. ```dart StreamingTextMarkdown( text: 'Mathematical content with $x^2 + y^2 = z^2$', latexEnabled: true, // Enable LaTeX rendering latexStyle: TextStyle( // Style for LaTeX expressions color: Colors.blue, fontSize: 18, ), latexScale: 1.2, // Scale factor for LaTeX latexFadeInEnabled: false, // Disable fade-in for LaTeX (recommended) markdownEnabled: true, ) ``` -------------------------------- ### Define Executable Target Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/example/windows/runner/CMakeLists.txt Defines the main executable for the Windows application. Ensure BINARY_NAME is consistent with the top-level CMakeLists.txt for `flutter run` to function correctly. Add any new source files to this list. ```cmake 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" ) ``` -------------------------------- ### Format Code Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/CLAUDE.md Formats Dart code in the specified directories according to project standards. ```bash dart format lib/ test/ ``` -------------------------------- ### ChatGPT-Style Streaming Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/README.md Use this widget for fast character-by-character streaming, similar to ChatGPT's response style. It supports Markdown formatting. ```dart StreamingTextMarkdown.chatGPT( text: '''# Flutter Development Tips **1. State Management** - Use **Provider** for simple apps - **Riverpod** for complex state - **BLoC** for enterprise applications **2. Performance** - Use `const` constructors - Implement `ListView.builder` for long lists - Avoid unnecessary widget rebuilds''', ) ``` -------------------------------- ### Custom Command for Flutter Tool Backend Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/example/linux/flutter/CMakeLists.txt A custom CMake command to execute the Flutter tool backend script, generating necessary files like the Flutter library and headers. It uses a phony target to ensure execution on every build. ```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 ) ``` -------------------------------- ### StreamingTextTheme Constructor Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/doc/api_reference.md Constructor for `StreamingTextTheme`, allowing customization of text styles and markdown sheet for streaming text widgets. Use this to define a consistent look and feel. ```dart StreamingTextTheme({ TextStyle? textStyle, MarkdownStyleSheet? markdownStyleSheet, EdgeInsets? defaultPadding, }) ``` -------------------------------- ### Initialize and Control Streaming Animation Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/README.md Initialize a StreamingTextController to manage the animation. Use its methods to pause, resume, restart, skip, or stop the animation. State monitoring and callbacks are also available. ```dart final controller = StreamingTextController(); // Control methods controller.pause(); // Pause animation controller.resume(); // Resume from pause controller.restart(); // Start over controller.skipToEnd(); // Jump to end controller.stop(); // Stop and reset // State monitoring controller.isAnimating; // Currently running? controller.isPaused; // Currently paused? controller.isCompleted; // Animation finished? controller.progress; // Progress (0.0 to 1.0) controller.state; // Current state enum // Callbacks controller.onStateChanged((state) => print('State: $state')); controller.onProgressChanged((progress) => print('Progress: $progress')); controller.onCompleted(() => print('Finished!')); // Speed control controller.speedMultiplier = 2.0; // 2x speed controller.speedMultiplier = 0.5; // Half speed ``` -------------------------------- ### StreamingTextTheme Extension on BuildContext Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/doc/api_reference.md Provides convenient access to the current StreamingTextTheme from a BuildContext. ```APIDOC ## StreamingTextTheme Extension on BuildContext ### Description Provides convenient access to the current StreamingTextTheme from a BuildContext. ### Extension Method ```dart extension StreamingTextThemeExtension on BuildContext { StreamingTextTheme get streamingTextTheme; } ``` ### Usage Access the theme using `context.streamingTextTheme`. ``` -------------------------------- ### StreamingTextMarkdown Widget Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/doc/api_reference.md The primary widget for displaying streaming text with markdown support. It offers various customization options for text content, styling, and animation. ```APIDOC ## StreamingTextMarkdown Widget ### Description The primary widget for displaying streaming text with markdown support. It offers various customization options for text content, styling, and animation. ### Widget Signature ```dart StreamingTextMarkdown({ required String text, String initialText = '', MarkdownStyleSheet? styleSheet, StreamingTextTheme? theme, EdgeInsets? padding, bool autoScroll = true, bool fadeInEnabled = false, Duration fadeInDuration = const Duration(milliseconds: 300), Curve fadeInCurve = Curves.easeOut, bool wordByWord = false, int chunkSize = 1, Duration typingSpeed = const Duration(milliseconds: 50), TextDirection? textDirection, TextAlign? textAlign, bool markdownEnabled = false, }) ``` ### Parameters #### Widget Parameters - **text** (String) - Required - The markdown text to be displayed - **initialText** (String) - Optional - Initial text to show before animation starts (Default: '') - **styleSheet** (MarkdownStyleSheet?) - Optional - Custom markdown style sheet (Default: null) - **theme** (StreamingTextTheme?) - Optional - Custom theme for the widget (Default: null) - **padding** (EdgeInsets?) - Optional - Padding around the text (Default: null) - **autoScroll** (bool) - Optional - Whether to scroll automatically as text appears (Default: true) - **fadeInEnabled** (bool) - Optional - Enable fade-in animation for each character (Default: false) - **fadeInDuration** (Duration) - Optional - Duration of fade-in animation (Default: 300ms) - **fadeInCurve** (Curve) - Optional - The curve to use for fade-in animation (Default: Curves.easeOut) - **wordByWord** (bool) - Optional - Whether to animate word by word (Default: false) - **chunkSize** (int) - Optional - Characters to reveal at once (when not wordByWord) (Default: 1) - **typingSpeed** (Duration) - Optional - Speed at which each unit appears (Default: 50ms) - **textDirection** (TextDirection?) - Optional - Text direction (LTR or RTL) (Default: null) - **textAlign** (TextAlign?) - Optional - Text alignment (Default: null) - **markdownEnabled** (bool) - Optional - Whether to enable markdown rendering (Default: false) ``` -------------------------------- ### Basic Streaming Text Markdown Widget Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/doc/usage_guide.md Use the StreamingTextMarkdown widget to display text with markdown support and a typing effect. Configure the typing speed for the animation. ```dart StreamingTextMarkdown( text: '# Hello World This is a **simple** example with *markdown* support.', typingSpeed: Duration(milliseconds: 50), ) ``` -------------------------------- ### Apply Standard Compilation Settings Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/example/linux/CMakeLists.txt Defines a function to apply common compilation features and options to targets, including C++ standard, warning levels, optimization, and NDEBUG definition. ```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() ``` -------------------------------- ### Configure Flutter Interface Library Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/example/linux/flutter/CMakeLists.txt Defines an INTERFACE library for Flutter, specifying include directories and linking against system libraries and the Flutter engine library. ```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 ) ``` -------------------------------- ### Define Custom StreamingTextTheme Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/doc/usage_guide.md Create a custom theme by extending StreamingTextTheme to define default text styles, markdown styles, and padding for multiple widgets. ```dart final customTheme = StreamingTextTheme( textStyle: TextStyle( fontSize: 16, color: Colors.grey[800], height: 1.5, ), markdownStyleSheet: MarkdownStyleSheet( h1: TextStyle(fontSize: 24, fontWeight: FontWeight.bold, color: Colors.blue), h2: TextStyle(fontSize: 20, fontWeight: FontWeight.w600, color: Colors.blue[700]), strong: TextStyle(fontWeight: FontWeight.bold, color: Colors.red), em: TextStyle(fontStyle: FontStyle.italic, color: Colors.green), ), defaultPadding: EdgeInsets.all(16), ); ``` -------------------------------- ### Define Executable Target Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/example/linux/runner/CMakeLists.txt Defines the main executable for the Flutter Linux application. Source files, including generated plugin registrants, are listed here. Ensure BINARY_NAME is consistent with the top-level CMakeLists.txt for `flutter run` to function correctly. ```cmake cmake_minimum_required(VERSION 3.13) 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} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) ``` -------------------------------- ### Speed-Based Animation Presets Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/README.md Create animation presets based on predefined speed levels: fast, medium, or slow. This allows for fine-grained control over the animation's pace. ```dart LLMAnimationPresets.bySpeed(AnimationSpeed.fast) LLMAnimationPresets.bySpeed(AnimationSpeed.medium) LLMAnimationPresets.bySpeed(AnimationSpeed.slow) ``` -------------------------------- ### Add Dependency to pubspec.yaml Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/doc/usage_guide.md Add the package to your pubspec.yaml file to include it in your project. ```yaml dependencies: flutter_streaming_text_markdown: ^1.1.0 ``` -------------------------------- ### Set Version Preprocessor Definitions Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/example/windows/runner/CMakeLists.txt Adds preprocessor definitions to the build configuration, embedding Flutter version information directly into the compiled code. This allows the application to access version details at runtime. ```cmake target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") ``` ```cmake target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") ``` ```cmake target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") ``` ```cmake target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") ``` ```cmake target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") ``` -------------------------------- ### StreamingTextTheme Extension on BuildContext Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/doc/api_reference.md Provides an extension method to easily access the current `StreamingTextTheme` from a `BuildContext`. This simplifies theme retrieval within your widget tree. ```dart // Get the current StreamingTextTheme from a BuildContext extension StreamingTextThemeExtension on BuildContext { StreamingTextTheme get streamingTextTheme; } ``` -------------------------------- ### Claude-Style Streaming Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/README.md Use this widget for smooth word-by-word animation, mimicking Claude's response style. It also supports Markdown. ```dart StreamingTextMarkdown.claude( text: '''# Understanding Flutter Architecture I'd be happy to explain Flutter's widget tree and how it impacts performance. ## Widget Tree Fundamentals Flutter's architecture revolves around three core trees: - **Widget Tree**: Configuration and description - **Element Tree**: Lifecycle management - **Render Tree**: Layout and painting This separation enables Flutter's excellent performance...''', ) ``` -------------------------------- ### Dry Run Publish Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/CLAUDE.md Validates the package for publishing without actually publishing it. ```bash dart pub publish --dry-run ``` -------------------------------- ### StreamProvider Interface Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/doc/api_reference.md Abstract interface for custom stream providers, allowing for custom text streaming logic. ```APIDOC ## StreamProvider Interface ### Description Abstract interface for custom stream providers, allowing for custom text streaming logic. ### Abstract Method ```dart abstract class StreamProvider { Stream provideStream(String text); } ``` ### Method Signature - **provideStream** (String text) - Returns a Stream that emits text chunks for animation. ``` -------------------------------- ### Custom Streaming Text Theme Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/README.md Create and apply a custom theme to a single StreamingTextMarkdown widget to override default text and markdown styles, and padding. ```dart // Create a custom theme final customTheme = StreamingTextTheme( textStyle: TextStyle(fontSize: 16, color: Colors.blue), markdownStyleSheet: TextStyle( fontSize: 16, fontWeight: FontWeight.w400, color: Colors.black87, ), defaultPadding: EdgeInsets.all(20), ); // Apply theme to a single widget StreamingTextMarkdown( text: '# Hello\nThis is a test', theme: customTheme, ) ``` -------------------------------- ### Define Flutter Library Interface Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/example/windows/flutter/CMakeLists.txt Configures the Flutter library interface, including header directories and linking to the Flutter Windows DLL. It also adds a dependency on the flutter_assemble target. ```cmake 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) ``` -------------------------------- ### Global Theme Application Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/README.md Apply a StreamingTextTheme globally to your application by adding it to the ThemeData extensions. ```dart // Or apply globally through your app's theme MaterialApp( theme: ThemeData( extensions: [ StreamingTextTheme( textStyle: TextStyle(/* ... */), markdownStyleSheet: TextStyle(/* ... */), ), ], ), // ... ) ``` -------------------------------- ### Controller API Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/README.md The `StreamingTextController` allows programmatic control over the streaming text animation. You can pause, resume, restart, skip to the end, or stop the animation. It also provides state monitoring for animation progress and completion, and allows for speed adjustments. ```APIDOC ## Controller API ```dart final controller = StreamingTextController(); // Control methods controller.pause(); // Pause animation controller.resume(); // Resume from pause controller.restart(); // Start over controller.skipToEnd(); // Jump to end controller.stop(); // Stop and reset // State monitoring controller.isAnimating; // Currently running? controller.isPaused; // Currently paused? controller.isCompleted; // Animation finished? controller.progress; // Progress (0.0 to 1.0) controller.state; // Current state enum // Callbacks controller.onStateChanged((state) => print('State: $state')); controller.onProgressChanged((progress) => print('Progress: $progress')); controller.onCompleted(() => print('Finished!')); // Speed control controller.speedMultiplier = 2.0; // 2x speed controller.speedMultiplier = 0.5; // Half speed ``` ``` -------------------------------- ### StreamingTextMarkdown with TTFT Shimmer Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/README.md Display a skeleton or shimmer effect while waiting for the first token from a stream. Set the isLoading property to true to activate the shimmer. ```dart StreamingTextMarkdown( text: _buffer, isLoading: _waitingForFirstToken, // shimmer while true trailingFadeEnabled: true, ) ``` -------------------------------- ### Bridge OpenAI SSE to Stream Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/README.md Convert OpenAI chat completions SSE stream (stream: true) into a plain Stream of content deltas. This function handles the HTTP request and parsing of SSE data. ```dart // OpenAI chat completions (stream: true) — yield content deltas Stream openAiChat(String prompt) async* { final req = http.Request('POST', Uri.parse('https://api.openai.com/v1/chat/completions')) ..headers.addAll({ 'Authorization': 'Bearer $apiKey', 'Content-Type': 'application/json', }) ..body = jsonEncode({ 'model': 'gpt-4o-mini', 'stream': true, 'messages': [{'role': 'user', 'content': prompt}], }); final res = await http.Client().send(req); await for (final line in res.stream.transform(utf8.decoder).transform(const LineSplitter())) { if (!line.startsWith('data: ')) continue; final payload = line.substring(6); if (payload == '[DONE]') break; final delta = (jsonDecode(payload)['choices'][0]['delta']['content']) as String?; if (delta != null && delta.isNotEmpty) yield delta; } } ``` -------------------------------- ### Use StreamingTextMarkdown with LLM Stream Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/README.md Pass a Stream directly to StreamingTextMarkdown for real-time LLM chat UIs. Recommended to use trailingFadeEnabled for streams to manage memory efficiently. Configure typing speed and onComplete callbacks as needed. ```dart import 'package:flutter_streaming_text_markdown/flutter_streaming_text_markdown.dart'; StreamingTextMarkdown( stream: chatService.streamReply(prompt), // your Stream markdownEnabled: true, latexEnabled: true, trailingFadeEnabled: true, // recommended for streams typingSpeed: const Duration(milliseconds: 15), onComplete: () => setState(() => _isStreaming = false), ) ``` -------------------------------- ### StreamProvider Interface Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/doc/api_reference.md Abstract interface for custom stream providers. Implement this to define how text streams are generated for the `StreamingText` widget. ```dart abstract class StreamProvider { Stream provideStream(String text); } ``` -------------------------------- ### Apply Custom Theme to a Single Widget Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/doc/usage_guide.md Apply a pre-defined custom theme to a specific StreamingTextMarkdown widget to override default styles. ```dart StreamingTextMarkdown( text: '# Themed Content This uses a **custom theme** with *styled* elements.', theme: customTheme, ) ``` -------------------------------- ### Widget-Level Styling with MarkdownStyleSheet Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/doc/usage_guide.md Apply custom styles to markdown elements like headings and paragraphs directly on the widget. This allows for fine-grained control over appearance. ```dart StreamingTextMarkdown( text: '# Custom Styled This text has custom styling.', styleSheet: MarkdownStyleSheet( h1: TextStyle(color: Colors.blue, fontSize: 24), p: TextStyle(color: Colors.black87, fontSize: 16), ), padding: EdgeInsets.all(20), ) ``` -------------------------------- ### StreamingText Widget Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/doc/api_reference.md The core widget that handles text animation and display. It can be used independently or as a base for other text-based widgets. ```APIDOC ## StreamingText Widget ### Description The core widget that handles text animation and display. It can be used independently or as a base for other text-based widgets. ### Widget Signature ```dart StreamingText({ required String text, TextStyle? style, bool markdownEnabled, MarkdownStyleSheet? markdownStyleSheet, bool fadeInEnabled, Duration fadeInDuration, Curve fadeInCurve, bool wordByWord, int chunkSize, Duration typingSpeed, TextDirection? textDirection, TextAlign? textAlign, VoidCallback? onComplete, StreamProvider? streamProvider, }) ``` ### Parameters #### Widget Parameters - **text** (String) - Required - The text to be displayed - **style** (TextStyle?) - Optional - The text style to apply (Default: null) - **markdownEnabled** (bool) - Optional - Whether to enable markdown rendering (Default: false) - **markdownStyleSheet** (MarkdownStyleSheet?) - Optional - Custom markdown style sheet (Default: null) - **fadeInEnabled** (bool) - Optional - Enable fade-in animation for each character (Default: false) - **fadeInDuration** (Duration) - Optional - Duration of fade-in animation (Default: null) - **fadeInCurve** (Curve) - Optional - The curve to use for fade-in animation (Default: null) - **wordByWord** (bool) - Optional - Whether to animate word by word (Default: false) - **chunkSize** (int) - Optional - Characters to reveal at once (when not wordByWord) (Default: null) - **typingSpeed** (Duration) - Optional - Speed at which each unit appears (Default: null) - **textDirection** (TextDirection?) - Optional - Text direction (LTR or RTL) (Default: null) - **textAlign** (TextAlign?) - Optional - Text alignment (Default: null) - **onComplete** (VoidCallback?) - Optional - Callback function when the text animation is complete (Default: null) - **streamProvider** (StreamProvider?) - Optional - Custom stream provider for text animation (Default: null) ``` -------------------------------- ### Define List Prepend Function Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/example/linux/flutter/CMakeLists.txt A custom CMake function to prepend elements to a list, as the standard 'list(TRANSFORM ... PREPEND ...)' is not available in CMake version 3.10. ```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() ``` -------------------------------- ### StreamingTextTheme Class Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/doc/api_reference.md Theme extension for customizing the appearance of StreamingTextMarkdown widgets. Allows for defining base text styles and markdown styles. ```APIDOC ## StreamingTextTheme Class ### Description Theme extension for customizing the appearance of StreamingTextMarkdown widgets. Allows for defining base text styles and markdown styles. ### Constructor ```dart StreamingTextTheme({ TextStyle? textStyle, MarkdownStyleSheet? markdownStyleSheet, EdgeInsets? defaultPadding, }) ``` ### Parameters #### Constructor Parameters - **textStyle** (TextStyle?) - Optional - Base text style for the widget (Default: null) - **markdownStyleSheet** (MarkdownStyleSheet?) - Optional - Style sheet for markdown elements (Default: null) - **defaultPadding** (EdgeInsets?) - Optional - Default padding for the widget (Default: null) ### Usage with ThemeData ```dart MaterialApp( theme: ThemeData( extensions: [ StreamingTextTheme( textStyle: TextStyle(/* ... */), markdownStyleSheet: MarkdownStyleSheet(/* ... */), ), ], ), ) ``` ``` -------------------------------- ### Word-by-Word Animation Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/doc/usage_guide.md Enable word-by-word animation for a different visual effect. Adjust the typing speed to control the animation pace. ```dart StreamingTextMarkdown( text: 'This text will appear word by word instead of character by character.', wordByWord: true, typingSpeed: Duration(milliseconds: 200), ) ``` -------------------------------- ### Add Flutter Tool Build Dependency Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/example/windows/runner/CMakeLists.txt Ensures that the Flutter tool's assembly process is completed before the application target is built. This is a mandatory step for Flutter Windows applications. ```cmake add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Custom Chunk Size for Character Reveal Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/doc/usage_guide.md Control how many characters are revealed at once by setting a custom chunkSize. This affects the animation's granularity. ```dart StreamingTextMarkdown( text: 'This text will appear three characters at a time.', chunkSize: 3, typingSpeed: Duration(milliseconds: 100), ) ``` -------------------------------- ### RTL Text Direction and Alignment Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/README.md Configure the widget for right-to-left languages by setting textDirection to TextDirection.rtl and textAlign to TextAlign.right. ```dart StreamingTextMarkdown( text: '''# مرحباً بكم! 👋 هذا **عرض توضيحي** للنص المتدفق.''', textDirection: TextDirection.rtl, textAlign: TextAlign.right, ) ``` -------------------------------- ### StreamingText Widget Constructor Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/doc/api_reference.md Constructor for the `StreamingText` widget, the core component for text animation. It accepts text content, styling, animation properties, and optional callbacks or stream providers. ```dart StreamingText({ required String text, TextStyle? style, bool markdownEnabled, MarkdownStyleSheet? markdownStyleSheet, bool fadeInEnabled, Duration fadeInDuration, Curve fadeInCurve, bool wordByWord, int chunkSize, Duration typingSpeed, TextDirection? textDirection, TextAlign? textAlign, VoidCallback? onComplete, StreamProvider? streamProvider, }) ``` -------------------------------- ### Set Flutter Target Platform Fallback Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/example/windows/flutter/CMakeLists.txt Sets a fallback value for FLUTTER_TARGET_PLATFORM if it's not already defined, ensuring a default platform is used for older Flutter tool versions. ```cmake if (NOT DEFINED FLUTTER_TARGET_PLATFORM) set(FLUTTER_TARGET_PLATFORM "windows-x64") endif() ``` -------------------------------- ### Apply StreamingTextTheme App-wide Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/doc/usage_guide.md Integrate the custom StreamingTextTheme into your MaterialApp's theme extensions to apply it globally across the application. ```dart MaterialApp( theme: ThemeData( extensions: [ StreamingTextTheme( textStyle: TextStyle(/* ... */), markdownStyleSheet: MarkdownStyleSheet(/* ... */), ), ], ), home: MyHomePage(), ) ``` -------------------------------- ### Right-to-Left (RTL) Text Direction Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/doc/usage_guide.md Configure the widget to support right-to-left text direction and alignment for languages like Arabic. ```dart StreamingTextMarkdown( text: 'مرحبا بالعالم! هذا نص بالعربية.', textDirection: TextDirection.rtl, textAlign: TextAlign.right, ) ``` -------------------------------- ### Programmatic Control of Streaming Animation Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/README.md Control the streaming animation programmatically using a StreamingTextController. This allows for pausing, resuming, and skipping to the end of the animation. ```dart final controller = StreamingTextController(); StreamingTextMarkdown.claude( text: llmResponse, controller: controller, onComplete: () => print('Streaming complete!'), ) // Control the animation ElevatedButton( onPressed: controller.isAnimating ? controller.pause : controller.resume, child: Text(controller.isAnimating ? 'Pause' : 'Resume'), ) ElevatedButton( onPressed: controller.skipToEnd, child: Text('Skip to End'), ) ``` -------------------------------- ### Custom Target for Flutter Assembly Source: https://github.com/hooshyar/flutter_streaming_text_markdown/blob/main/example/linux/flutter/CMakeLists.txt Defines a custom target 'flutter_assemble' that depends on the generated Flutter library and its headers, ensuring they are built before other targets that might use them. ```cmake add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ) ```