iws_feedback 0.5.0
iws_feedback: ^0.5.0 copied to clipboard
Plugin to request user feedback.
IWS Feedback #
A Flutter package for collecting customer feedback through the IWS service. This package provides a ready-to-use feedback form with validation, device information collection, and a clean modal UI.
Features #
- 🚀 Quick and easy implementation
- ✅ Built-in form validation
- 📱 Automatic device information collection
- 🎨 Customizable UI (icon, title, success message)
- 🔒 Secure API integration
- 📝 Multiple feedback types (idea, comment, help, error)
- 🎯 Two implementation methods: UI widget or programmatic API
Prerequisites #
You must have an IWS API key to use this package. Contact the IWS service provider to obtain your API key.
Installation #
Add this package to your pubspec.yaml:
dependencies:
iws_feedback: ^0.4.0
Then run:
flutter pub get
Configuration #
Required: API Key Setup #
The IWS API key must be provided as a compile-time constant using --dart-define:
flutter run --dart-define=IWS_API_KEY=your_api_key_here
For Android builds:
flutter build apk --dart-define=IWS_API_KEY=your_api_key_here
For iOS builds:
flutter build ios --dart-define=IWS_API_KEY=your_api_key_here
Usage #
Method 1: Feedback Button Widget (Recommended) #
The easiest way to integrate feedback collection is using the feedbackBottomSheet() widget, which returns a pre-configured button that opens a modal feedback form:
import 'package:flutter/material.dart';
import 'package:iws_feedback/iws_feedback.dart';
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('My App')),
body: Center(
child: IwsFeedback().feedbackBottomSheet(
userIdentifier: "user123",
customerName: "John Doe",
),
),
);
}
}
Method 2: Programmatic Submission #
For custom UIs or direct feedback submission without the built-in widget:
import 'package:iws_feedback/iws_feedback.dart';
// Send feedback programmatically
await IwsFeedback().sendFeedback(
type: FeedbackType.comment,
message: "Great app! Would love to see dark mode.",
userIdentifier: "user123",
customerName: "John Doe",
contactEmail: "john@example.com", // Optional
);
Customization #
Custom Icon, Title, and Success Message #
IwsFeedback().feedbackBottomSheet(
userIdentifier: "user123",
customerName: "John Doe",
contactEmail: "john@example.com",
icon: Icon(Icons.comment, color: Colors.blue),
title: "We'd love your feedback!",
successMessage: "Thank you! We'll review your feedback soon.",
)
Device ID Tracking #
Optionally provide a custom device ID for tracking:
IwsFeedback(deviceId: "custom-device-id").feedbackBottomSheet(
userIdentifier: "user123",
customerName: "John Doe",
)
If not provided, the package will automatically collect device information using the iws_device_info package.
Feedback Types #
The package supports four types of feedback:
| Type | Description | Use Case |
|---|---|---|
FeedbackType.idea |
New feature ideas | User suggestions for improvements |
FeedbackType.comment |
General comments | General feedback or opinions |
FeedbackType.help |
Help requests | User needs assistance |
FeedbackType.error |
Problem reports | Bug reports or issues |
The user can select the feedback type from within the form UI, or you can specify it programmatically when using sendFeedback().
Complete Example #
import 'package:flutter/material.dart';
import 'package:iws_feedback/iws_feedback.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'IWS Feedback Demo',
home: Scaffold(
appBar: AppBar(title: Text('Feedback Example')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Option 1: Pre-built feedback button
IwsFeedback().feedbackBottomSheet(
userIdentifier: "demo_user",
customerName: "Demo Customer",
contactEmail: "demo@example.com",
icon: Icon(Icons.feedback_outlined),
title: "Share Your Thoughts",
successMessage: "Thanks for your feedback!",
),
SizedBox(height: 20),
// Option 2: Custom button with programmatic submission
ElevatedButton(
onPressed: () async {
await IwsFeedback().sendFeedback(
type: FeedbackType.idea,
message: "Add dark mode support",
userIdentifier: "demo_user",
customerName: "Demo Customer",
);
},
child: Text('Send Feedback Programmatically'),
),
],
),
),
),
);
}
}
Error Handling #
If the API key is not configured, the package will throw a SdkNotConfigureException at runtime. Make sure to always add the --dart-define=IWS_API_KEY parameter when building or running your app.