secure_textfield 1.0.1
secure_textfield: ^1.0.1 copied to clipboard
A Flutter package that provides a secure text field widget blocking copy/paste functionality across iOS, Android, and web platforms.
Changelog #
1.0.0 - 2025-07-31 #
โ BREAKING CHANGES #
- Initial release
Features #
- add CI workflow for linting and code analysis (#1) (0dd5a19)
- add Conventional Commits guide and update README with commit conventions (#5) (ae880c9)
- add test coverage workflow and update README with coverage instructions (#3) (657ef46)
- initial release of SecureTextField package (9ad4491)
Bug Fixes #
- add permissions for issues in release workflow (bf69741)
- ci check badge (#4) (aabbdfa)
- correct action reference in release workflow (#6) (d3ad16a)
๐ Secure TextField #
A Flutter package that provides an enhanced secure text field widget designed to protect sensitive user input by preventing copy, paste, cut, and select operations across iOS, Android, and web platforms. Perfect for password fields, PINs, credit card numbers, and other confidential data entry scenarios. ๐ก๏ธ
โจ Features #
๐ Universal Platform Support: Seamlessly works across iOS, Android, and web browsers with consistent behavior
๐ซ Complete Input Protection: Intelligently blocks copy, paste, cut, and select all operations to safeguard sensitive data
โจ๏ธ Smart Keyboard Blocking: Automatically prevents common keyboard shortcuts (Ctrl+C/V/X/A, Cmd+C/V/X/A) across all platforms
๐ Context Menu Defense: Disables right-click menus on web and long-press context menus on mobile devices
๐ฏ Full TextField Compatibility: Maintains 100% compatibility with standard TextField properties, callbacks, and styling options
๐ง Zero Configuration: Works out of the box with no additional setup required - just replace TextField with SecureTextField!
๐ Getting started #
Add the package to your pubspec.yaml
:
dependencies:
secure_textfield: ^0.1.0
Then run:
flutter pub get
๐ป Usage #
Import the package and use SecureTextField
instead of the standard TextField
:
import 'package:flutter/material.dart';
import 'package:secure_textfield/secure_textfield.dart';
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return SecureTextField(
decoration: InputDecoration(
labelText: 'Secure Input',
hintText: 'Copy/paste is blocked here',
border: OutlineInputBorder(),
),
onChanged: (value) {
print('Text changed: $value');
},
);
}
}
๐ Password Field Example #
SecureTextField(
obscureText: true,
decoration: InputDecoration(
labelText: 'Password',
prefixIcon: Icon(Icons.lock),
border: OutlineInputBorder(),
),
)
๐ Multiline Example #
SecureTextField(
maxLines: 4,
decoration: InputDecoration(
labelText: 'Comments',
hintText: 'Enter your comments here...',
border: OutlineInputBorder(),
alignLabelWithHint: true,
),
)
๐ฎ With Controller #
final TextEditingController controller = TextEditingController();
SecureTextField(
controller: controller,
decoration: InputDecoration(
labelText: 'Controlled Input',
border: OutlineInputBorder(),
),
onSubmitted: (value) {
print('Submitted: $value');
},
)
๐ฑ Example App #
Check out the example app for a comprehensive demonstration of all features:
cd example
flutter run
๐งช Testing #
The package includes comprehensive tests covering:
- Widget behavior and rendering
- Platform-specific functionality
- Keyboard shortcut blocking
- All TextField property support
- Edge cases and error scenarios
Run tests with:
flutter test
๐ค Contributing #
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
๐ Commit Convention #
This project uses Conventional Commits for automated changelog generation and version bumping. Please format your commit messages as:
<type>[optional scope]: <description>
Examples:
feat: add new validation feature
fix: resolve input focus issue
docs: update README with new examples
See .github/CONVENTIONAL_COMMITS.md for detailed guidelines.
๐ Release Process #
Releases are automated using Release Please:
- Commit changes using conventional commit format
- Push to main branch
- Release Please automatically creates a release PR with updated version and changelog
- When the release PR is merged, a new GitHub release is created
- The package can then be published to pub.flutter-io.cn (currently manual)
๐ License #
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Additional Information #
- ๐ Issue Tracker: GitHub Issues
- ๐ Documentation: Check the API documentation for detailed information about all available properties and methods
- ๐ Changelog: See CHANGELOG.md for version history
๐ Security Considerations #
This package provides UI-level protection against copy/paste operations. For sensitive data:
- Use additional server-side validation
- Implement proper data encryption
- Consider using secure storage solutions
- Be aware that determined users may still find ways to extract data
The package is designed to prevent casual copy/paste operations and improve user experience, but should not be relied upon as the sole security measure for highly sensitive data.