### Run Example Project with FVM Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/CLAUDE.md Navigates to the example directory and runs the example application using Flutter and FVM. ```bash # Run example project cd example && fvm flutter run ``` -------------------------------- ### Install Application Executable Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/example/windows/CMakeLists.txt Installs the main application executable to the specified runtime destination. It's assigned the 'Runtime' component for installation management. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Install FVM Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/CLAUDE.md Installs the Flutter Version Management tool globally if it's not already installed. ```bash # Install FVM (if not already installed) dart pub global activate fvm ``` -------------------------------- ### Install Bundled Libraries Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/example/linux/CMakeLists.txt Iterates through a list of bundled libraries and installs each one to the 'lib' subdirectory within the installation prefix. These are also runtime components. ```cmake foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) ``` -------------------------------- ### Install Flutter Library Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/example/windows/CMakeLists.txt Installs the main Flutter library file to the root of the bundle's installation directory. ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Configuration - ScreenLockConfig Example Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/DOCUMENTATION_SUMMARY.txt Provides an example of configuring the `ScreenLock` widget using `ScreenLockConfig`. ```dart ScreenLock( config: ScreenLockConfig( title: 'Enter Passcode', secrets: SecretsConfig(length: 6), ), // Other ScreenLock properties... ) ``` -------------------------------- ### Configure Installation Prefix Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/example/linux/CMakeLists.txt Sets the installation prefix to a build bundle directory by default. This ensures that 'installing' creates a relocatable bundle within the build directory. ```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() ``` -------------------------------- ### Define Installation Directories Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/example/windows/CMakeLists.txt Sets variables for the installation directories within the bundle. This helps organize data and library files. ```cmake set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") ``` -------------------------------- ### Configuration - KeyPadConfig Example Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/DOCUMENTATION_SUMMARY.txt Illustrates customization of the keypad layout and behavior using `KeyPadConfig`. ```dart KeyPadConfig( displayStrings: { 'delete': 'DEL', 'cancel': 'CANCEL', }, // Other KeyPadConfig properties... ) ``` -------------------------------- ### Show Lock Screen Example Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/06-types-reference.md Demonstrates how to invoke the screen lock function using a BuildContext. ```dart void showLock(BuildContext context) { screenLock(context: context, correctString: '1234'); } ``` -------------------------------- ### Configuration - KeyPadButtonConfig Example Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/DOCUMENTATION_SUMMARY.txt Demonstrates how to style individual keypad buttons using `KeyPadButtonConfig`. ```dart KeyPadButtonConfig( textStyle: TextStyle(color: Colors.white), backgroundColor: Colors.red, // Other KeyPadButtonConfig properties... ) ``` -------------------------------- ### EdgeInsetsGeometry Constructor Examples Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/06-types-reference.md Illustrates common constructors for EdgeInsetsGeometry to define padding or margin. Includes examples for all sides, symmetric, and specific sides. ```dart EdgeInsets.all(20) // Same padding on all sides EdgeInsets.symmetric(vertical: 20, horizontal: 10) // Vertical and horizontal EdgeInsets.only(top: 20, bottom: 50) // Specific sides ``` -------------------------------- ### Configuration Classes Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/README.md Documentation for all configuration classes with accompanying examples. ```APIDOC ## Configuration Classes Detailed documentation for all configuration classes available in the package, complete with illustrative examples. ``` -------------------------------- ### Install Dependencies with FVM Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/CLAUDE.md Installs project dependencies using Flutter, managed by FVM. ```bash # Install dependencies fvm flutter pub get ``` -------------------------------- ### Example Custom Secrets Display (Animated Progress) Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/06-types-reference.md An example of implementing `SecretsBuilderCallback` to show an animated progress indicator for the entered passcode. This example uses `LinearProgressIndicator` to visualize input completion. ```dart SecretsBuilderCallback progressBuilder = (context, config, length, input, verifyStream) { return ValueListenableBuilder( valueListenable: input, builder: (context, inputValue, _) { final progress = inputValue.length / length; return Column( mainAxisSize: MainAxisSize.min, children: [ Text('${inputValue.length}/$length digits'), const SizedBox(height: 8), SizedBox( width: 150, child: LinearProgressIndicator( value: progress, minHeight: 8, ), ), ], ); }, ); }; screenLockCreate( context: context, secretsBuilder: progressBuilder, ); ``` -------------------------------- ### Example Custom Delay UI Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/06-types-reference.md An example of implementing `DelayBuilderCallback` to display a custom UI during the retry delay. This example shows a lock icon and a countdown timer in seconds. ```dart DelayBuilderCallback myDelayBuilder = (context, delay) { final seconds = (delay.inMilliseconds / 1000).ceil(); return Column( mainAxisSize: MainAxisSize.min, children: [ const Icon(Icons.lock_clock, color: Colors.red, size: 48), const SizedBox(height: 16), Text( 'Locked for $seconds second${seconds == 1 ? '' : 's'}', style: const TextStyle(color: Colors.red, fontSize: 18), ), ], ); }; screenLock( context: context, correctString: '1234', maxRetries: 3, retryDelay: const Duration(seconds: 30), delayBuilder: myDelayBuilder, ); ``` -------------------------------- ### KeyPad Constructor Example Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/05-ui-components.md Demonstrates basic integration of the KeyPad widget with an InputController. Configure delete and cancel buttons, and enable interaction. ```dart final inputController = InputController(); inputController.initialize( digits: 4, correctString: '1234', ); KeyPad( inputState: inputController, didCancelled: () { print('User cancelled'); }, enabled: true, config: const KeyPadConfig(), deleteButton: const Icon(Icons.backspace), cancelButton: const Text('Cancel'), ) ``` -------------------------------- ### Minimal Setup for screenLock (Auto-pop) Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/00-api-index.md Use this minimal setup for the `screenLock` function when you want the screen lock to automatically dismiss upon successful input or cancellation. ```dart screenLock( context: context, correctString: '1234', // Will auto-pop on success or cancel ) ``` -------------------------------- ### Set Installation Prefix for Bundled Application Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/example/windows/CMakeLists.txt Configures the installation prefix to be next to the executable, facilitating in-place running. This is particularly useful for Visual Studio builds. ```cmake set(BUILD_BUNDLE_DIR "$") set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() ``` -------------------------------- ### Configuration - SecretConfig Example Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/DOCUMENTATION_SUMMARY.txt Shows how to configure individual secret indicators with `SecretConfig`. ```dart SecretConfig( enabledColor: Colors.blue, disabledColor: Colors.grey, // Other SecretConfig properties... ) ``` -------------------------------- ### Configure Library Installation Path Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/example/linux/CMakeLists.txt Sets the runtime search path for bundled libraries to be relative to the binary. ```cmake set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### Example: Re-enter First Passcode Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/03-input-controller.md Demonstrates how to reset the confirmed state to allow the user to re-enter the first passcode. ```dart // User wants to re-enter the first passcode controller.unsetConfirmed(); ``` -------------------------------- ### Install Native Assets Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/example/linux/CMakeLists.txt Copies native assets from the build directory to the installation bundle. This ensures that all necessary native files are included in the final application package. ```cmake set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Clean Build Bundle Directory on Install Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/example/linux/CMakeLists.txt Removes the build bundle directory before installation to ensure a clean state. This is executed as part of the installation process. ```cmake install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) ``` -------------------------------- ### ScreenLockConfig Default Configuration Example Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/04-configuration-classes.md Shows how to apply the `ScreenLockConfig.defaultConfig` to the `screenLock` widget for a pre-defined, standard appearance. ```dart screenLock( context: context, correctString: '1234', config: ScreenLockConfig.defaultConfig, ); ``` -------------------------------- ### Duration Examples Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/06-types-reference.md Shows how to create Duration objects for specifying time spans, such as delays for retries or animations. Includes examples for seconds, milliseconds, and zero duration. ```dart const Duration(seconds: 5) const Duration(milliseconds: 500) Duration.zero // No delay ``` -------------------------------- ### Configuration - SecretsConfig Example Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/DOCUMENTATION_SUMMARY.txt Demonstrates customization of the secret indicators using `SecretsConfig`. ```dart SecretsConfig( length: 4, // Other SecretsConfig properties... ) ``` -------------------------------- ### Install Bundled Plugin Libraries Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/example/windows/CMakeLists.txt Installs any bundled native libraries required by plugins to the library directory of the bundle. This is conditional on PLUGIN_BUNDLED_LIBRARIES being set. ```cmake if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Passcode Creation with screenLockCreate Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/DOCUMENTATION_SUMMARY.txt Illustrates how to use screenLockCreate to guide users through setting up a new passcode. ```dart screenLockCreate(context: context) ``` -------------------------------- ### Usage Patterns Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/README.md Common usage patterns and best practices with full code examples. ```APIDOC ## Usage Patterns Explore common usage patterns and best practices for the flutter_screen_lock package, illustrated with full code examples. ``` -------------------------------- ### Secure Storage Example Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/DOCUMENTATION_SUMMARY.txt Illustrates a pattern for securely storing and retrieving passcodes, likely involving platform-specific secure storage solutions. ```dart final savedPasscode = await readPasscode(); final enteredPasscode = await screenLock( context: context, passcode: savedPasscode, ); if (enteredPasscode == true) { // Access granted } else { // Access denied } ``` -------------------------------- ### Custom UI Example with ScreenLock Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/05-ui-components.md Demonstrates how to create a fully custom UI for the screen lock by configuring `ScreenLockConfig`, `SecretsConfig`, and `KeyPadConfig`. Use this to match your app's design. ```dart import 'package:flutter/material.dart'; import 'package:flutter_screen_lock/flutter_screen_lock.dart'; class CustomUIExample extends StatelessWidget { const CustomUIExample({Key? key}) : super(key: key); @override Widget build(BuildContext context) { final inputController = InputController(); inputController.initialize( digits: 4, correctString: '1234', ); return ScreenLock( correctString: '1234', inputController: inputController, onUnlocked: () { Navigator.of(context).pop(); }, config: ScreenLockConfig( backgroundColor: const Color(0xFF2d3748), titleTextStyle: const TextStyle( color: Colors.white, fontSize: 28, fontWeight: FontWeight.bold, ), ), secretsConfig: SecretsConfig( spacing: 16, secretConfig: SecretConfig( size: 18, borderSize: 2, borderColor: Colors.white, enabledColor: Colors.white, disabledColor: Colors.white24, erroredBorderColor: Colors.red, erroredColor: Colors.red.shade200, ), ), keyPadConfig: KeyPadConfig( buttonConfig: KeyPadButtonConfig( size: 72, fontSize: 36, backgroundColor: const Color(0xFF4a5568), foregroundColor: Colors.white, ), ), title: const Text('Enter PIN'), ); } } ``` -------------------------------- ### Install Native Assets Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/example/windows/CMakeLists.txt Installs native assets provided by build.dart from all packages into the bundle's library directory. These are essential runtime components. ```cmake set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### SecretsConfig Example: Default Configuration Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/04-configuration-classes.md Demonstrates creating a default SecretsConfig and then using copyWith to create a modified version with different spacing and padding. ```dart const defaultConfig = SecretsConfig(); final compactConfig = defaultConfig.copyWith( spacing: 8, padding: EdgeInsets.all(16), ); ``` -------------------------------- ### Install AOT Library for Release/Profile Builds Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/example/windows/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library only for Profile and Release configurations. This optimizes performance for non-debug builds. ```cmake install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Screen Lock Functions Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/README.md Documentation for the `screenLock()` and `screenLockCreate()` functions, including detailed parameter documentation and usage examples. ```APIDOC ## screenLock() ### Description Displays the screen lock interface. ### Parameters - `context` (BuildContext) - Required - The build context for the widget. - `passwordConfig` (PasswordConfig) - Optional - Configuration for the password input. - `secretsConfig` (SecretsConfig) - Optional - Configuration for the secret dots. - `keyPadConfig` (KeyPadConfig) - Optional - Configuration for the keypad. - `cancelButton` (Widget) - Optional - Custom cancel button. - `confirmButton` (Widget) - Optional - Custom confirm button. - `backgroundColor` (Color) - Optional - Background color of the screen lock. - `header` (Widget) - Optional - Custom header widget. - `footer` (Widget) - Optional - Custom footer widget. - `onSuccess` (Future Function()) - Required - Callback function executed on successful password entry. - `onClose` (Future Function()) - Optional - Callback function executed when the screen lock is closed. - `onDispose` (Future Function()) - Optional - Callback function executed when the screen lock is disposed. ### Response #### Success Response (Future) Returns the entered password string upon successful verification, or null if cancelled or an error occurs. ## screenLockCreate() ### Description Creates and returns a `ScreenLock` widget. ### Parameters - `passwordConfig` (PasswordConfig) - Optional - Configuration for the password input. - `secretsConfig` (SecretsConfig) - Optional - Configuration for the secret dots. - `keyPadConfig` (KeyPadConfig) - Optional - Configuration for the keypad. - `cancelButton` (Widget) - Optional - Custom cancel button. - `confirmButton` (Widget) - Optional - Custom confirm button. - `backgroundColor` (Color) - Optional - Background color of the screen lock. - `header` (Widget) - Optional - Custom header widget. - `footer` (Widget) - Optional - Custom footer widget. - `onSuccess` (Future Function()) - Required - Callback function executed on successful password entry. - `onClose` (Future Function()) - Optional - Callback function executed when the screen lock is closed. - `onDispose` (Future Function()) - Optional - Callback function executed when the screen lock is disposed. ### Response #### Success Response (ScreenLock) Returns an instance of the `ScreenLock` widget. ``` -------------------------------- ### Example: Custom Display Strings (Chinese Numerals) Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/04-configuration-classes.md Demonstrates customizing the display strings for keypad buttons to show Chinese numerals while retaining default numeric input values. This configuration is then passed to screenLockCreate. ```dart final keyPadConfig = KeyPadConfig( displayStrings: [ '零', '壱', '弐', '参', '肆', '伍', '陸', '質', '捌', '玖' ], // inputStrings still defaults to ['0'-'9'], so actual input is unaffected ); screenLockCreate( context: context, keyPadConfig: keyPadConfig, ); ``` -------------------------------- ### Example: Large Buttons with Custom Colors Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/04-configuration-classes.md Demonstrates creating a KeyPadButtonConfig with custom size, font size, and colors, and then using it to configure both regular and action buttons within a KeyPadConfig for the screenLock widget. ```dart final buttonConfig = KeyPadButtonConfig( size: 80, fontSize: 40, backgroundColor: Colors.deepOrange, foregroundColor: Colors.white, ); final keyPadConfig = KeyPadConfig( buttonConfig: buttonConfig, actionButtonConfig: buttonConfig.copyWith( fontSize: 20, backgroundColor: Colors.orange, ), ); screenLock( context: context, correctString: '1234', keyPadConfig: keyPadConfig, ); ``` -------------------------------- ### Manual Input Controller Example Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/03-input-controller.md Demonstrates how to use InputController to manually manage the screen lock input. Initialize the controller with the correct digits and string, then listen for input changes and verification results. Use buttons to add characters or clear the input. ```dart import 'package:flutter/material.dart'; import 'package:flutter_screen_lock/flutter_screen_lock.dart'; class ManualInputControllerExample extends StatefulWidget { @override State createState() => _ManualInputControllerExampleState(); } class _ManualInputControllerExampleState extends State { late InputController _controller; @override void initState() { super.initState(); _controller = InputController(); _controller.initialize( digits: 4, correctString: '1234', ); _controller.currentInput.addListener(() { print('Input changed: ${_controller.currentInput.value}'); }); _controller.verifyInput.listen((isValid) { if (isValid) { ScaffoldMessenger.of(context).showSnackBar( const SnackBar(content: Text('Correct!')), ); } else { ScaffoldMessenger.of(context).showSnackBar( const SnackBar(content: Text('Incorrect!')), ); _controller.clear(); } }); } @override void dispose() { _controller.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: const Text('Manual Input Control')), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ ValueListenableBuilder( valueListenable: _controller.currentInput, builder: (context, input, _) { return Text( 'Input length: ${input.length}/4', style: const TextStyle(fontSize: 18), ); }, ), const SizedBox(height: 24), ElevatedButton( onPressed: () => _controller.addCharacter('1'), child: const Text('Add 1'), ), ElevatedButton( onPressed: () => _controller.clear(), child: const Text('Clear'), ), ], ), ), ); } } ``` -------------------------------- ### Example Custom Secrets Display (Star Rating) Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/06-types-reference.md An example of implementing `SecretsBuilderCallback` to display entered secrets as star ratings. This demonstrates using `ValueListenableBuilder` to react to input changes and render the custom UI. ```dart SecretsBuilderCallback starsBuilder = (context, config, length, input, verifyStream) { return ValueListenableBuilder( valueListenable: input, builder: (context, inputValue, _) { return Row( mainAxisAlignment: MainAxisAlignment.center, children: List.generate( length, (index) => Icon( index < inputValue.length ? Icons.star : Icons.star_border, color: index < inputValue.length ? Colors.orange : Colors.grey, size: 32, ), ), ); }, ); }; screenLock( context: context, correctString: '1234', secretsBuilder: starsBuilder, ); ``` -------------------------------- ### Color Definition Examples Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/06-types-reference.md Provides examples of how to define Color objects using RGB hex and ARGB values. These are used for customizing UI element colors. ```dart Color customColor = const Color(0xFF1976D2); // RGB hex Color withAlpha = const Color.fromARGB(128, 25, 118, 210); // With alpha ``` -------------------------------- ### Example: Number Input Button Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/05-ui-components.md Demonstrates creating a number input button using KeyPadButton with custom size, font size, and colors. The onPressed callback adds a character to an input controller. ```dart KeyPadButton( config: KeyPadButtonConfig( size: 70, fontSize: 36, backgroundColor: Colors.blue, foregroundColor: Colors.white, ), onPressed: () => inputController.addCharacter('1'), child: const Text('1'), ) ``` -------------------------------- ### Example: Custom ButtonStyle with Material Effects Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/04-configuration-classes.md Illustrates configuring KeyPadButtonConfig with a custom ButtonStyle, including background color, foreground color, padding, shape, and border, to achieve specific material design effects for buttons. ```dart final customButtonConfig = KeyPadButtonConfig( size: 70, fontSize: 34, buttonStyle: OutlinedButton.styleFrom( backgroundColor: Colors.indigo, foregroundColor: Colors.white, padding: const EdgeInsets.all(0), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8), ), side: const BorderSide( color: Colors.indigo, width: 2, ), ), ); ``` -------------------------------- ### SecretsConfig Example: Large Spacing with Custom Padding and Secret Configuration Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/04-configuration-classes.md Shows how to instantiate SecretsConfig with custom spacing, padding, and individual secret configurations, then pass it to the screenLock function. ```dart final secretsConfig = SecretsConfig( spacing: 20, padding: const EdgeInsets.symmetric(vertical: 60), secretConfig: const SecretConfig( size: 18, enabledColor: Colors.blue, disabledColor: Colors.grey, ), ); screenLock( context: context, correctString: '1234', secretsConfig: secretsConfig, ); ``` -------------------------------- ### ThemeData Example for ScreenLockConfig Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/06-types-reference.md Demonstrates how to create a ThemeData object to provide a base theme for the screen lock UI. This allows for consistent styling across the application. ```dart ThemeData baseTheme = ThemeData( brightness: Brightness.dark, primaryColor: Colors.blue, scaffoldBackgroundColor: Colors.grey.shade900, ); final config = ScreenLockConfig(themeData: baseTheme); ``` -------------------------------- ### SecretsConfig Example Usage Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/04-configuration-classes.md Demonstrates how to create and use a SecretsConfig object to customize the appearance of the passcode input, including large spacing and custom padding. ```APIDOC ## Example: Large Spacing with Padding ```dart final secretsConfig = SecretsConfig( spacing: 20, padding: const EdgeInsets.symmetric(vertical: 60), secretConfig: const SecretConfig( size: 18, enabledColor: Colors.blue, disabledColor: Colors.grey, ), ); screenLock( context: context, correctString: '1234', secretsConfig: secretsConfig, ); ``` ``` -------------------------------- ### Fully Customized screenLock Setup Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/00-api-index.md Achieve a fully customized `screenLock` experience by providing custom configurations for the screen lock, secrets, and keypad, along with custom UI builders. ```dart screenLock( context: context, correctString: '1234', config: customScreenLockConfig, secretsConfig: customSecretsConfig, keyPadConfig: customKeyPadConfig, title: customTitleWidget, secretsBuilder: customSecretsBuilder, delayBuilder: customDelayBuilder, ) ``` -------------------------------- ### Example: Action Button with Icon Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/05-ui-components.md Shows how to create a transparent action button with an icon using KeyPadButton.transparent. It includes callbacks for both single press (remove character) and long press (clear input). ```dart KeyPadButton.transparent( config: KeyPadButtonConfig(fontSize: 18), onPressed: () => inputController.removeCharacter(), onLongPress: () => inputController.clear(), child: const Icon(Icons.backspace), ) ``` -------------------------------- ### ButtonStyle Definition Example Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/06-types-reference.md Demonstrates creating a ButtonStyle to customize button appearance, including foreground color, background color, padding, and shape. Useful for styling buttons. ```dart ButtonStyle customStyle = OutlinedButton.styleFrom( foregroundColor: Colors.white, backgroundColor: Colors.blue, padding: const EdgeInsets.all(16), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), ); ``` -------------------------------- ### Custom Dark Theme for ScreenLockConfig Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/04-configuration-classes.md Provides an example of creating a fully custom `ScreenLockConfig` to achieve a specific dark theme, including background color, text styles, and button styling. ```dart final darkTheme = ScreenLockConfig( backgroundColor: const Color(0xFF1a1a1a), titleTextStyle: const TextStyle( color: Colors.white, fontSize: 24, fontWeight: FontWeight.bold, ), textStyle: const TextStyle( color: Colors.white70, fontSize: 16, ), buttonStyle: OutlinedButton.styleFrom( foregroundColor: Colors.cyan, backgroundColor: const Color(0xFF2a2a2a), shape: const CircleBorder(), ), ); screenLock( context: context, correctString: '1234', config: darkTheme, ); ``` -------------------------------- ### Create New Passcode with Secure Storage Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/07-usage-patterns.md Guides the user through creating a new passcode and stores it securely using `flutter_secure_storage`. Includes confirmation and feedback. ```dart import 'package:flutter_secure_storage/flutter_secure_storage.dart'; const storage = FlutterSecureStorage(); Future createNewPasscode(BuildContext context) { return screenLockCreate( context: context, onConfirmed: (passcode) async { // Store the passcode securely await storage.write( key: 'user_passcode', value: passcode, ); if (context.mounted) { Navigator.of(context).pop(); ScaffoldMessenger.of(context).showSnackBar( const SnackBar(content: Text('Passcode created successfully')), ); } }, onCancelled: () { Navigator.of(context).pop(); }, ); } ``` -------------------------------- ### Example: Dispose Controller in Widget Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/03-input-controller.md Shows the correct way to call the dispose method of the controller within a Flutter widget's dispose lifecycle method. ```dart @override void dispose() { controller.dispose(); super.dispose(); } ``` -------------------------------- ### TextStyle Definition Example Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/06-types-reference.md Shows how to create a TextStyle object to define text appearance properties like color, size, weight, and font family. Used for customizing text elements. ```dart const textStyle = TextStyle( color: Colors.white, fontSize: 18, fontWeight: FontWeight.bold, fontFamily: 'Roboto', ); ``` -------------------------------- ### Example Custom Validation Logic Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/06-types-reference.md An example of implementing `ValidationCallback` to perform custom validation on the entered passcode. This example simulates an API call and checks for a specific length and disallowed input. ```dart ValidationCallback myValidator = (input) async { // Simulate API call await Future.delayed(const Duration(milliseconds: 500)); // Custom validation logic return input.length == 4 && input != '0000'; }; screenLock( context: context, correctString: '', onValidate: myValidator, ); ``` -------------------------------- ### Install ICU Data File Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/example/windows/CMakeLists.txt Installs the ICU data file, which is necessary for internationalization and localization, to the data directory of the bundle. ```cmake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install AOT Library Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/example/linux/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library on non-debug builds. This is conditional based on the CMAKE_BUILD_TYPE to optimize for release performance. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Main Entry Points Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/00-api-index.md These are the primary functions to display the screen lock and creation screens. ```APIDOC ## screenLock() ### Description Displays the passcode authentication screen. ### Method Function ### Endpoint N/A (Dart function) ### Parameters N/A (Function arguments are configured via `ScreenLockConfig` and other related classes) ### Request Example ```dart import 'package:flutter_screen_lock/flutter_screen_lock.dart'; // Example usage within a Flutter widget screenLock(context: context, ...); ``` ### Response N/A (This function displays a UI and handles user interaction internally.) ``` ```APIDOC ## screenLockCreate() ### Description Displays the passcode creation and confirmation screen. ### Method Function ### Endpoint N/A (Dart function) ### Parameters N/A (Function arguments are configured via `ScreenLockConfig` and other related classes) ### Request Example ```dart import 'package:flutter_screen_lock/flutter_screen_lock.dart'; // Example usage within a Flutter widget screenLockCreate(context: context, ...); ``` ### Response N/A (This function displays a UI and handles user interaction internally.) ``` -------------------------------- ### initialize() Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/03-input-controller.md Initializes the InputController with the required number of digits, the correct passcode string, and an optional custom validation callback. ```APIDOC ## initialize() ### Description Sets up the controller with validation parameters. Must be called before accepting any input. ### Method `void initialize({ required int digits, required String? correctString, ValidationCallback? onValidate, })` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **digits** (int) - Required - The required length of the passcode - **correctString** (String?) - Required - The correct passcode to validate against (null for creation mode where confirmation is self-validated) - **onValidate** (ValidationCallback?) - Optional - Custom validation callback; if provided, overrides default string comparison ### Request Example ```dart final controller = InputController(); controller.initialize( digits: 4, correctString: '1234', onValidate: null, ); ``` ### Response #### Success Response (200) None (This is a method call, not an endpoint) #### Response Example None ``` -------------------------------- ### Remote Validation with screenLock Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/DOCUMENTATION_SUMMARY.txt Example of integrating remote validation for passcodes by providing a future-based validation callback. ```dart screenLock(context: context, validatePasscode: (value) async { return await verifyPasscodeRemotely(value); }) ``` -------------------------------- ### Passcode Verification with Biometrics Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/README.md Integrate biometric authentication to unlock the screen. This example triggers local authentication when the screen opens. ```dart Future showLockWithBiometrics(BuildContext context) async { final localAuth = LocalAuthentication(); await screenLock( context: context, correctString: '1234', onOpened: () async { // Trigger biometric auth on screen open final isAuth = await localAuth.authenticate( localizedReason: 'Authenticate to unlock', ); if (isAuth && context.mounted) { Navigator.of(context).pop(); } }, ); } ``` -------------------------------- ### List application C++ wrapper sources Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/example/windows/flutter/CMakeLists.txt Appends application-specific C++ client wrapper source files to a list and prepends the wrapper root directory path. ```cmake list(APPEND CPP_WRAPPER_SOURCES_APP "flutter_engine.cc" "flutter_view_controller.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") ``` -------------------------------- ### Export Flutter library and ICU data Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/example/windows/flutter/CMakeLists.txt Makes Flutter library and ICU data file available to parent scopes for installation. ```cmake set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) ``` -------------------------------- ### Package Source File Map Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/00-api-index.md Overview of the package's directory structure and the purpose of key files. ```plaintext lib/ ├── flutter_screen_lock.dart # Package entry point └── src/ ├── functions.dart # screenLock(), screenLockCreate() ├── screen_lock.dart # ScreenLock widget + typedefs ├── input_controller.dart # InputController class ├── configurations/ │ ├── screen_lock_config.dart # ScreenLockConfig │ ├── secrets_config.dart # SecretsConfig │ ├── secret_config.dart # SecretConfig │ ├── key_pad_config.dart # KeyPadConfig │ └── key_pad_button_config.dart # KeyPadButtonConfig └── layout/ ├── key_pad.dart # KeyPad widget ├── key_pad_button.dart # KeyPadButton widget └── secrets.dart # Secrets, Secret, SecretsWithShakingAnimation ``` -------------------------------- ### Initialize InputController Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/03-input-controller.md Sets up the InputController with the required number of digits, the correct passcode string, and an optional custom validation callback. This method must be called before any input is processed. ```dart final controller = InputController(); controller.initialize( digits: 4, correctString: '1234', onValidate: null, ); ``` -------------------------------- ### Example: Long Press to Clear Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/04-configuration-classes.md Configures the keypad to clear all input on a long press of the delete button and customizes the appearance of the numeric buttons. ```dart final keyPadConfig = KeyPadConfig( clearOnLongPressed: true, buttonConfig: KeyPadButtonConfig( size: 72, fontSize: 36, backgroundColor: Colors.blue, foregroundColor: Colors.white, ), ); ``` -------------------------------- ### Configure Flutter Library and Dependencies Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/example/linux/flutter/CMakeLists.txt Sets up the Flutter library, including its headers and linking against system libraries like GTK, GLIB, and GIO. This is essential for Flutter's Linux integration. ```cmake find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") # Published to parent scope for install step. set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 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/") 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) ``` -------------------------------- ### Configuration Classes Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/README.md Documentation for all configuration classes used to customize the screen lock's appearance and behavior. ```APIDOC ## Configuration Classes ### ScreenLockConfig - **`passwordConfig`** (PasswordConfig) - Configuration for the password input. - **`secretsConfig`** (SecretsConfig) - Configuration for the secret dots. - **`keyPadConfig`** (KeyPadConfig) - Configuration for the keypad. ### PasswordConfig - **`digits`** (int) - The number of digits required for the password. - **`foregroundColor`** (Color) - The color of the password input field. - **`backgroundColor`** (Color) - The background color of the password input field. ### SecretsConfig - **`type`** (SecretType) - The type of secret display (e.g., dots, dashes). - **`color`** (Color) - The color of the secrets. - **`width`** (double) - The width of each secret. - **`height`** (double) - The height of each secret. - **`spacing`** (double) - The spacing between secrets. ### SecretConfig - **`color`** (Color) - The color of a single secret. - **`width`** (double) - The width of a single secret. - **`height`** (double) - The height of a single secret. - **`spacing`** (double) - The spacing between secrets. ### KeyPadConfig - **`displayStrings`** (List) - The strings to display on the keypad buttons. - **`buttons`** (List) - Configuration for individual keypad buttons. - **`buttonColor`** (Color) - The default color for keypad buttons. - **`foregroundColor`** (Color) - The default foreground color for keypad buttons. - **`disabledButtonColor`** (Color) - The color for disabled keypad buttons. ### KeyPadButtonConfig - **`text`** (String) - The text displayed on the button. - **`textColor`** (Color) - The color of the button text. - **`backgroundColor`** (Color) - The background color of the button. - **`disabled`** (bool) - Whether the button is disabled. ``` -------------------------------- ### Check Dependency Information with FVM Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/CLAUDE.md Displays dependency information for the project using Flutter and FVM. ```bash # Check dependency information fvm flutter pub deps ``` -------------------------------- ### Set Minimum CMake Version and Project Name Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/example/windows/CMakeLists.txt Specifies the minimum required CMake version and names the project. This is a standard starting point for CMake projects. ```cmake cmake_minimum_required(VERSION 3.14) project(example LANGUAGES CXX) ``` -------------------------------- ### Format Code with Dart and FVM Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/CLAUDE.md Formats the project's Dart code using the 'dart format' command, managed by FVM. Ensure dependencies are installed first. ```bash # Install dependencies (required before linting/formatting) fvm flutter pub get # Format code with dart format fvm dart format . ``` -------------------------------- ### Custom UI/Styling with ScreenLockConfig Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/DOCUMENTATION_SUMMARY.txt Demonstrates how to customize the appearance of the screen lock interface by providing a `ScreenLockConfig` object. ```dart screenLock(context: context, config: ScreenLockConfig(secrets: SecretsConfig(height: 20, width: 20))) ``` -------------------------------- ### Create PIN Lock with External InputController Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/01-screenlock-functions.md This example demonstrates how to manage the PIN input externally using an InputController. It allows for programmatic clearing of the input when the user cancels. ```dart void _showCreateLockWithExternalControl(BuildContext context) { final inputController = InputController(); screenLockCreate( context: context, inputController: inputController, onConfirmed: (passcode) { _savePasscode(passcode); Navigator.of(context).pop(); }, onCancelled: () { // Clear input when user cancels inputController.clear(); Navigator.of(context).pop(); }, ); } ``` -------------------------------- ### InputController Constructor Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/03-input-controller.md Creates a new InputController instance. Note that the controller must be initialized using the initialize() method before it can be used. ```APIDOC ## InputController() ### Description Creates a new `InputController` instance with no arguments. The controller must be initialized via the `initialize()` method before use. ### Method Constructor ### Code Example ```dart final controller = InputController(); ``` ``` -------------------------------- ### Configure Cross-Building Environment Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/example/linux/CMakeLists.txt Sets up the sysroot and find paths for cross-compilation based on the FLUTTER_TARGET_PLATFORM_SYSROOT variable. ```cmake if(FLUTTER_TARGET_PLATFORM_SYSROOT) set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) endif() ``` -------------------------------- ### List core C++ wrapper sources Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/example/windows/flutter/CMakeLists.txt Appends core C++ client wrapper source files to a list and prepends the wrapper root directory path. ```cmake list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") ``` -------------------------------- ### ScreenLockConfig copyWith() Method Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/04-configuration-classes.md Demonstrates how to create a new `ScreenLockConfig` instance with specific properties updated using the `copyWith()` method. This is useful for creating variations of a configuration. ```dart final lightConfig = ScreenLockConfig( backgroundColor: Colors.white, titleTextStyle: const TextStyle(color: Colors.black), ); final darkConfig = lightConfig.copyWith( backgroundColor: Colors.black, titleTextStyle: const TextStyle(color: Colors.white), ); ``` -------------------------------- ### Passcode Creation UI Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/07-usage-patterns.md This widget provides the UI for creating a new passcode. It displays a button to initiate the passcode creation flow, which then uses screenLockCreate to guide the user through setting their passcode. ```dart class _CreationFlow extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( body: Center( child: ElevatedButton( onPressed: () => _showCreationFlow(context), child: const Text('Set Up Passcode'), ), ), ); } Future _showCreationFlow(BuildContext context) { return screenLockCreate( context: context, onConfirmed: (passcode) async { await SecurePasscodeManager.setPasscode(passcode); if (context.mounted) { Navigator.of(context).pop(); ScaffoldMessenger.of(context).showSnackBar( const SnackBar(content: Text('Passcode set successfully')), ); } }, ); } } ``` -------------------------------- ### Run Static Analysis with FVM Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/CLAUDE.md Executes static code analysis on the project using Flutter and FVM. ```bash # Run static analysis fvm flutter analyze ``` -------------------------------- ### Custom UI Components - KeyPad Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/DOCUMENTATION_SUMMARY.txt Shows how to use the `KeyPad` widget for custom keypad layouts. ```dart KeyPad( // KeyPad properties... ) ``` -------------------------------- ### Custom Builder with Icons Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/04-configuration-classes.md Example of using a custom builder within SecretConfig to display icons as passcode indicators. This configuration uses stars to represent enabled and disabled states, and integrates with screenLockCreate. ```dart final secretConfig = SecretConfig( builder: (context, config, enabled) { return Icon( enabled ? Icons.star : Icons.star_border, color: enabled ? Colors.orange : Colors.grey, size: 28, ); }, ); screenLockCreate( context: context, secretsConfig: SecretsConfig( secretConfig: secretConfig, ), ); ``` -------------------------------- ### Create InputController Instance Source: https://github.com/naoki0719/flutter_screen_lock/blob/main/_autodocs/03-input-controller.md Instantiates an InputController. This controller must be initialized using the initialize() method before it can be used to manage input. ```dart InputController() ```