flutter_hello_widget 0.1.1
flutter_hello_widget: ^0.1.1 copied to clipboard
A feature-rich Flutter component library providing customizable Hello series UI components with focus on accessibility and semantic labeling support.
Flutter Hello Widget #
A feature-rich Flutter component library providing customizable Hello series UI components with focus on accessibility and semantic labeling support.
β¨ Features #
- π― HelloButton - Accessible button supporting multiple sizes, colors, and loading states
- βΏ Full Accessibility Support - Built-in semantic labels and screen reader support
- π± Responsive Design - Adapts to different screen sizes and devices
- π¨ Highly Customizable - Flexible color, size, and style configuration
- π§ͺ Comprehensive Test Coverage - Includes unit tests and integration tests
- π Detailed Documentation - All public APIs include detailed documentation
π¦ Installation #
Add the following dependency to your pubspec.yaml file:
dependencies:
flutter_hello_widget: ^0.1.1
Then run:
flutter pub get
π Quick Start #
Basic Usage #
import 'package:flutter_hello_widget/flutter_hello_widget.dart';
// Create a basic button
HelloButton(
text: 'Click Me',
onPressed: () {
print('Button clicked!');
},
)
Different Button Sizes #
Column(
children: [
// Small size button
HelloButton(
text: 'Small Button',
size: ButtonSize.small,
color: Colors.green,
onPressed: () {},
),
// Medium size button (default)
HelloButton(
text: 'Medium Button',
size: ButtonSize.medium,
onPressed: () {},
),
// Large size button
HelloButton(
text: 'Large Button',
size: ButtonSize.large,
color: Colors.orange,
onPressed: () {},
),
],
)
Button with Loading State #
class MyWidget extends StatefulWidget {
@override
_MyWidgetState createState() => _MyWidgetState();
}
class _MyWidgetState extends State<MyWidget> {
bool _isLoading = false;
Future<void> _handlePress() async {
setState(() => _isLoading = true);
// Simulate async operation
await Future.delayed(Duration(seconds: 2));
setState(() => _isLoading = false);
}
@override
Widget build(BuildContext context) {
return HelloButton(
text: 'Submit',
isLoading: _isLoading,
onPressed: _isLoading ? null : _handlePress,
);
}
}
Accessibility Support #
HelloButton(
text: 'Purchase',
semanticLabel: 'Purchase item button',
onPressed: () {
// Handle purchase logic
},
)
π API Reference #
HelloButton #
| Parameter | Type | Default | Description |
|---|---|---|---|
text |
String |
Required | Button display text |
onPressed |
VoidCallback? |
null |
Click callback function |
color |
Color? |
null |
Button background color |
size |
ButtonSize |
ButtonSize.medium |
Button size |
isLoading |
bool |
false |
Whether to show loading state |
semanticLabel |
String? |
null |
Accessibility semantic label |
ButtonSize Enum #
ButtonSize.small- Small size, font size 14pxButtonSize.medium- Medium size, font size 16px (default)ButtonSize.large- Large size, font size 18px
UI Utility Class #
// Show success message
HelloUiUtils.showSuccess(context, 'Operation successful!');
// Show warning message
HelloUiUtils.showWarning(context, 'Please check your input');
// Get screen size
final screenSize = HelloUiUtils.getScreenSize(context);
// Check if wide screen
final isWideScreen = HelloUiUtils.isWideScreen(context);
π§ͺ Testing #
This package includes complete test cases. You can run tests with:
# Run all tests
flutter test
# Run specific test files
flutter test test/presentation/hello_button_test.dart
flutter test test/presentation/hello_ui_utils_test.dart
π§ Development Environment #
- Flutter: ^3.7.0
- Dart: ^3.7.0
- Supports Android, iOS, Web, macOS, Windows, Linux
π± Example App #
Check the example directory for a complete example app demonstrating all features:
cd example
flutter run
π€ Contributing #
Issues and Pull Requests are welcome! Before contributing, please:
- Read our coding standards
- Ensure all tests pass
- Add necessary comments and documentation
π License #
This project uses MIT License - see LICENSE file for details.
π Support #
If you encounter issues, please:
- Check documentation and example code
- Search for similar issues in GitHub Issues
- Create a new Issue describing your problem
π δΈζζζ‘£ #
For Chinese documentation, please see README_CN.md (δΈζζζ‘£)