ky_guide Guide
A comprehensive and customizable onboarding system for Flutter applications that guides users through new features using beautiful overlays and tooltips.
โจ Features
- ๐ฏ Target Any Widget - Highlight any existing widget in your app
- ๐จ Highly Customizable - Custom colors, content, and styling
- ๐ฑ Responsive Design - Automatically adapts to different screen sizes
- ๐ Smart Positioning - Tooltips position themselves optimally
- โญ๏ธ Skip Functionality - Users can skip onboarding anytime
- ๐ญ Beautiful Animations - Smooth transitions between steps
- ๐งฉ Easy Integration - Works with existing apps without major changes
- ๐ Lightweight - Minimal performance impact
๐ฑ Screenshots
| Welcome Step | Feature Highlight | Custom Content |
|---|---|---|
๐ Getting Started
Installation
Add this to your package's pubspec.yaml file:
dependencies:
ky_guide: ^0.1.0
Then run:
flutter pub get
Import
import 'package:ky_guide/ky_guide.dart';
๐ก Quick Start
1. Create an GuideController
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final GuideController _GuideController = GuideController();
}
2. Wrap Target Widgets
// Create GlobalKeys for your target widgets
final GlobalKey _fabKey = GlobalKey();
final GlobalKey _menuKey = GlobalKey();
// Wrap widgets you want to highlight
GuideTarget(
onboardingKey: _fabKey,
child: FloatingActionButton(
onPressed: () {},
child: Icon(Icons.add),
),
)
3. Create Guide Steps
void _startGuide() {
final steps = [
GuideStep(
targetKey: _fabKey,
title: 'Create New Items',
description: 'Tap this button to create new content.',
),
GuideStep(
targetKey: _menuKey,
title: 'Access Menu',
description: 'Find more options in this menu.',
backgroundColor: Colors.blue.shade50,
),
];
_GuideController.startGuide(steps);
}
4. Start Guide
@override
void initState() {
super.initState();
// Start onboarding after first frame
WidgetsBinding.instance.addPostFrameCallback((_) {
_startGuide();
});
}
๐จ Customization
Custom Step Content
GuideStep(
targetKey: _buttonKey,
title: 'Pro Feature',
description: 'This is a premium feature.',
customContent: Container(
padding: EdgeInsets.all(12),
decoration: BoxDecoration(
color: Colors.amber.shade100,
borderRadius: BorderRadius.circular(8),
),
child: Row(
children: [
Icon(Icons.star, color: Colors.amber),
SizedBox(width: 8),
Text('Unlock with Pro!'),
],
),
),
backgroundColor: Colors.white,
showSkipButton: false, // Force users to see this step
)
Styling Options
GuideStep(
targetKey: _targetKey,
title: 'Custom Style',
description: 'This step has custom styling.',
tooltipPadding: EdgeInsets.all(20),
backgroundColor: Colors.deepPurple.shade50,
borderRadius: 12.0,
)
๐ฎ Controller Methods
| Method | Description |
|---|---|
startGuide(List<GuideStep> steps) |
Start onboarding with given steps |
nextStep() |
Move to next step |
previousStep() |
Move to previous step |
skipGuide() |
Skip entire onboarding |
finishGuide() |
Complete onboarding |
๐ฏ GuideStep Properties
| Property | Type | Default | Description |
|---|---|---|---|
targetKey |
GlobalKey |
Required | Key of widget to highlight |
title |
String |
Required | Title text |
description |
String |
Required | Description text |
customContent |
Widget? |
null |
Additional custom content |
tooltipPadding |
EdgeInsets |
EdgeInsets.all(16) |
Tooltip padding |
backgroundColor |
Color? |
null |
Tooltip background color |
borderRadius |
double |
8.0 |
Highlight border radius |
showSkipButton |
bool |
true |
Show/hide skip button |
๐ง Advanced Usage
Listen to Guide State
_GuideController.addListener(() {
if (!_GuideController.isActive) {
print('Guide completed!');
// Save completion state, show celebration, etc.
}
});
Conditional Steps
void _createConditionalGuide() {
List<GuideStep> steps = [
// Always show welcome
GuideStep(
targetKey: _welcomeKey,
title: 'Welcome!',
description: 'Let\'s get started.',
),
];
// Add premium feature step only for pro users
if (user.isPro) {
steps.add(GuideStep(
targetKey: _proFeatureKey,
title: 'Pro Feature',
description: 'This is available for pro users.',
));
}
_GuideController.startGuide(steps);
}
Multiple Guide Flows
class GuideManager {
static const String FIRST_LAUNCH = 'first_launch';
static const String NEW_FEATURE = 'new_feature_v2';
static void showAppropriateGuide(BuildContext context) {
final prefs = SharedPreferences.getInstance();
if (!prefs.getBool(FIRST_LAUNCH, false)) {
_showFirstLaunchGuide();
prefs.setBool(FIRST_LAUNCH, true);
} else if (!prefs.getBool(NEW_FEATURE, false)) {
_showNewFeatureGuide();
prefs.setBool(NEW_FEATURE, true);
}
}
}
๐งช Testing
import 'package:flutter_test/flutter_test.dart';
import 'package:ky_guide/ky_guide.dart';
void main() {
group('GuideController', () {
late GuideController controller;
setUp(() {
controller = GuideController();
});
test('should start with inactive state', () {
expect(controller.isActive, false);
expect(controller.currentStep, 0);
});
test('should activate when starting onboarding', () {
final steps = [
GuideStep(
targetKey: GlobalKey(),
title: 'Test',
description: 'Test description',
),
];
controller.startGuide(steps);
expect(controller.isActive, true);
});
});
}
๐ค 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.
Development Setup
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests for your changes
- Ensure tests pass (
flutter test) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ Requirements
- Flutter SDK:
>=3.0.0 <4.0.0 - Dart SDK:
>=2.17.0 <4.0.0
๐ Issues
If you encounter any issues, please file them on the GitHub issue tracker.
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Inspired by various onboarding libraries across different platforms
- Thanks to the Flutter community for feedback and contributions
- Special thanks to all contributors
๐ Related Packages
- introduction_screen - Full-screen onboarding
- showcaseview - Feature showcasing
- tutorial_coach_mark - Tutorial overlay
Made with โค๏ธ by Your Name
---
## ๐ CHANGELOG.md
```markdown
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [1.0.0] - 2024-06-12
### ๐ Initial Release
#### Added
- โจ Complete onboarding system with overlay and tooltips
- ๐ฏ `GuideController` for managing onboarding flow
- ๐ `GuideStep` model for defining onboarding steps
- ๐จ `GuideTarget` widget for marking target elements
- ๐ Navigation between steps (next, previous, skip, finish)
- ๐ฑ Responsive tooltip positioning
- ๐จ Customizable styling (colors, padding, border radius)
- ๐ Custom content support for steps
- โญ๏ธ Configurable skip button per step
- ๐ Dark overlay with spotlight effect on target widgets
- ๐ Comprehensive API documentation
- ๐งช Example implementation
- ๐ง TypeScript-like documentation with examples
#### Features
- **Smart Positioning**: Tooltips automatically position above or below targets
- **Customizable Content**: Add custom widgets to any step
- **Skip Functionality**: Allow users to skip onboarding entirely
- **Step Control**: Navigate forward, backward, or jump to finish
- **Responsive Design**: Works on all screen sizes
- **Easy Integration**: Minimal code changes to existing apps
- **Performance Optimized**: Efficient overlay rendering and updates
#### Developer Experience
- ๐ Complete API documentation with examples
- ๐ฏ Type-safe implementation
- ๐งฉ Easy integration with existing Flutter apps
- ๐ง Highly customizable and extensible
- ๐ฑ Works with any existing Flutter widgets
### ๐ Requirements
- Flutter: `>=3.0.0 <4.0.0`
- Dart: `>=2.17.0 <4.0.0`
### ๐ Links
- [Documentation](https://pub.flutter-io.cn/documentation/ky_guide/latest/)
- [Example](https://pub.flutter-io.cn/packages/ky_guide/example)
- [GitHub Repository](https://github.com/bhangun/ky_guide)
---
## [Unreleased]
### ๐ง Planned Features
- ๐ฅ Animation customization options
- ๐ต Sound effects support
- ๐ Analytics integration
- ๐ Internationalization support
- ๐จ More built-in tooltip themes
- ๐ฑ Platform-specific adaptations
- ๐ Gesture-based navigation
- ๐พ Automatic progress persistence
### ๐ Known Issues
- None currently reported
---
## Release Notes Format
Each release follows this structure:
### [Version] - Date
#### Added โจ
- New features and capabilities
#### Changed ๐
- Changes to existing functionality
#### Deprecated โ ๏ธ
- Features marked for removal
#### Removed ๐๏ธ
- Removed features
#### Fixed ๐
- Bug fixes and corrections
#### Security ๐
- Security-related changes
---
**Note**: This project follows [Semantic Versioning](https://semver.org/). Given a version number MAJOR.MINOR.PATCH:
- **MAJOR** version changes for incompatible API changes
- **MINOR** version changes for backward-compatible functionality additions
- **PATCH** version changes for backward-compatible bug fixes
๐ Publishing Checklist
Before publishing to pub.flutter-io.cn, ensure:
All files are in correct directory structurepubspec.yamlhas correct version and metadataREADME.md is comprehensive with examplesCHANGELOG.md documents all changesLICENSE file is includedTests are written and passingDocumentation is completeExample app works correctlyNo sensitive information in codePackage analysis passes (dart pub publish --dry-run)
๐ฆ Publishing Command
# Dry run to check for issues
dart pub publish --dry-run
# Publish to pub.flutter-io.cn
dart pub publish
This package is now ready for publication to pub.flutter-io.cn with all the necessary files, documentation, and structure!