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: ^1.0.0
Then run:
flutter pub get
Configuration
API Key Setup
You can provide the IWS API key either at compile time via --dart-define (recommended for static builds):
flutter run --dart-define=IWS_API_KEY=your_api_key_here
Or initialize it dynamically at runtime in your main() or bootstrap logic:
void main() {
IwsFeedback.init(apiKey: 'your_api_key_here');
runApp(const MyApp());
}
Usage
Method 1: Feedback Button Widget
Returns a pre-configured button that opens the feedback form in a modal bottom sheet:
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: Open Modal Programmatically
Trigger the feedback bottom sheet from any custom button, AppBar action, or event:
IconButton(
icon: Icon(Icons.feedback_outlined),
onPressed: () {
IwsFeedback.showModal(
context: context,
userIdentifier: "user123",
customerName: "John Doe",
);
},
)
Method 3: Direct API Submission (No UI)
For fully custom UIs or direct background submissions:
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.",
buttonLabel: "Send Feedback",
buttonIcon: Icon(Icons.rate_review),
)
Internationalization & Translations
The package comes with built-in Spanish (default) and English presets, or you can provide custom translations:
// Use built-in English translations
IwsFeedback().feedbackBottomSheet(
userIdentifier: "user123",
customerName: "John Doe",
translations: FeedbackTranslations.en(),
buttonLabel: "Send Feedback",
);
// Or provide fully customized strings
IwsFeedback().feedbackBottomSheet(
userIdentifier: "user123",
customerName: "John Doe",
translations: const FeedbackTranslations(
title: "How can we improve?",
messageHint: "Tell us what you think...",
sendButton: "Submit",
sendingButton: "Submitting...",
),
);
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.