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 14px
  • ButtonSize.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:

  1. Read our coding standards
  2. Ensure all tests pass
  3. Add necessary comments and documentation

πŸ“„ License

This project uses MIT License - see LICENSE file for details.

πŸ†˜ Support

If you encounter issues, please:

  1. Check documentation and example code
  2. Search for similar issues in GitHub Issues
  3. Create a new Issue describing your problem

πŸ“– δΈ­ζ–‡ζ–‡ζ‘£

For Chinese documentation, please see README_CN.md (δΈ­ζ–‡ζ–‡ζ‘£)