Professional testing keys management and validation for Flutter projects with intelligent code analysis and automated suggestions.
- ๐ Visual Tree View - Hierarchical display of testing keys organized by categories
- ๐ฏ Smart Auto-completion - Context-aware KeyConstants suggestions with usage statistics
- โก Code Actions - Quick fixes for hardcoded keys, missing constants, and imports
- ๐ Validation Engine - Comprehensive analysis with detailed reporting
- ๐ง CLI Integration - Seamless flutter_keycheck validation support
- ๐ Real-time Updates - Auto-refresh on file changes and configuration updates
- ๐ Usage Analytics - Track key usage patterns and coverage metrics
-
From VS Code Marketplace:
- Open VS Code
- Go to Extensions (
Ctrl+Shift+X
) - Search for "Flutter Testing Keys Inspector"
- Click Install
-
From Command Line:
code --install-extension your-publisher-name.flutter-testing-keys-inspector
-
Create KeyConstants file at
lib/constants/key_constants.dart
:class KeyConstants { static const String loginButton = 'login_button'; static const String emailField = 'email_field'; static const String passwordField = 'password_field'; }
-
Use keys in your widgets:
ElevatedButton( key: Key(KeyConstants.loginButton), onPressed: () => _handleLogin(), child: Text('Login'), )
-
Check the Explorer panel for the "Testing Keys" view
The extension adds a "Testing Keys" panel to the Explorer view with:
- ๐ Statistics - Project overview with key counts and coverage metrics
- ๐ Categories - Keys organized by widget types (Buttons, TextFields, etc.)
- ๐ Key Details - Individual keys with usage information and file locations
Smart suggestions when typing:
KeyConstants.
โ Shows all available keys with usage statisticsKey(KeyConstants.
โ Auto-completes with closing parenthesiskey: Key(KeyConstants.
โ Widget key parameter completion
Right-click in Dart files for instant improvements:
- Replace hardcoded keys with constants
- Add missing keys to widgets
- Create new key constants interactively
- Import KeyConstants automatically
- Organize keys by category
Access via Ctrl+Shift+P
:
Flutter Keys: Refresh
- Rescan all keysFlutter Keys: Validate
- Run comprehensive validationFlutter Keys: Generate Report
- Create detailed analysis reportFlutter Keys: Add New Key
- Interactive key creation wizard
Configure the extension in VS Code settings:
{
"flutterTestingKeys.autoValidate": true,
"flutterTestingKeys.keyConstantsPath": "lib/constants/key_constants.dart",
"flutterTestingKeys.showUnusedKeys": true,
"flutterTestingKeys.enableDiagnostics": true
}
Setting | Default | Description |
---|---|---|
autoValidate |
true |
Automatically validate keys on file save |
keyConstantsPath |
lib/constants/key_constants.dart |
Path to KeyConstants file |
showUnusedKeys |
true |
Show unused keys in tree view |
enableDiagnostics |
true |
Enable diagnostic messages for key issues |
For enhanced performance and accuracy, the extension integrates with the flutter_keycheck
CLI tool.
The extension will automatically prompt to install flutter_keycheck
when needed:
# Added to pubspec.yaml dev_dependencies
dev_dependencies:
flutter_keycheck: ^1.0.0
Create flutter_keycheck.yaml
in your project root:
# Paths to scan for key usage
scan_paths:
- lib/
- test/
# Path to key constants file
key_constants_path: lib/constants/key_constants.dart
# Patterns to exclude from scanning
exclude_patterns:
- '**/*.g.dart'
- '**/generated/**'
# Validation options
validation:
check_unused: true
check_duplicates: true
check_naming_convention: true
naming_pattern: '^[a-zA-Z][a-zA-Z0-9_]*$'
- โก 3-5x faster validation for large projects
- ๐ฏ More accurate key usage detection
- ๐ Enhanced reporting with detailed statistics
Keys are automatically categorized based on naming patterns and usage context:
- ๐ Buttons - ElevatedButton, TextButton, IconButton
- โ๏ธ Text Fields - TextField, TextFormField
- โ๏ธ Checkboxes - Checkbox, Radio, Switch
- ๐ Dropdowns - DropdownButton, DropdownButtonFormField
- ๐งญ Navigation - AppBar, NavigationBar, BottomNavigationBar
- ๐ Lists - ListView, ListTile
- ๐ Cards - Card, Container
- ๐ฌ Dialogs - AlertDialog, BottomSheet
- ๐ฎ Game Elements - Custom game widgets
- โ๏ธ Settings - Settings and configuration widgets
- ๐ฆ Other - Miscellaneous widgets
Use descriptive, consistent names:
// โ
Good
static const String loginSubmitButton = 'login_submit_button';
static const String userEmailTextField = 'user_email_text_field';
// โ Avoid
static const String btn1 = 'b1';
static const String field = 'f';
Group keys by screen or feature:
class KeyConstants {
// Login Screen
static const String loginEmailField = 'login_email_field';
static const String loginPasswordField = 'login_password_field';
static const String loginSubmitButton = 'login_submit_button';
// Profile Screen
static const String profileNameField = 'profile_name_field';
static const String profileSaveButton = 'profile_save_button';
}
Use keys consistently in tests:
testWidgets('login button triggers authentication', (tester) async {
await tester.pumpWidget(MyApp());
await tester.enterText(
find.byKey(Key(KeyConstants.loginEmailField)),
'test@example.com'
);
await tester.tap(find.byKey(Key(KeyConstants.loginSubmitButton)));
await tester.pump();
expect(find.text('Welcome'), findsOneWidget);
});
- Ensure you're in a Flutter project (contains
pubspec.yaml
) - Verify
flutter:
is present inpubspec.yaml
- Restart VS Code if needed
- Check KeyConstants file exists at configured path
- Verify file contains
static const String
declarations - Use "Flutter Keys: Refresh" command to rescan
- Ensure Dart language support is installed
- Check KeyConstants is imported in the file
- Verify file is saved and syntax is correct
We welcome contributions! Please see our Contributing Guidelines.
git clone https://github.com/your-username/flutter-testing-keys-inspector.git
cd flutter-testing-keys-inspector
npm install
npm run watch
Press F5
to run the extension in a new Extension Development Host window.
npm test
npm run package
This project is licensed under the MIT License - see the LICENSE file for details.
- Flutter team for the amazing framework
- VS Code team for the excellent extension API
- Community contributors and feedback
- ๐ Report Issues
- ๐ก Feature Requests
- ๐ Documentation
- ๐ฌ Discussions