Documentation Flutter SDK

Flutter SDK v1.0.1

Cross-platform SDK for integrating FeedbackKit into Flutter applications. Works seamlessly on iOS, Android, and Web with built-in widgets and Provider pattern support.

iOS Android Web Flutter 3.10+ pub.dev GitHub
$ flutter pub add feedbackkit_flutter

Installation

Add the FeedbackKit Flutter SDK to your project using the Flutter CLI or by editing your pubspec.yaml file.

terminal
# Using Flutter CLI
flutter pub add feedbackkit_flutter

# Or add to pubspec.yaml
dependencies:
  feedbackkit_flutter: ^1.0.1

Quick Start

Wrap your app with FeedbackKitProvider and start using the pre-built widgets.

main.dart
import 'package:flutter/material.dart';
import 'package:feedbackkit_flutter/feedbackkit_flutter.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return FeedbackKitProvider(
      apiKey: 'your-api-key',
      userId: 'user_12345',
      child: MaterialApp(
        home: Scaffold(
          appBar: AppBar(title: Text('Feedback')),
          body: FeedbackList(),
        ),
      ),
    );
  }
}

Configuration

Configure the SDK by creating a FeedbackKitConfig instance.

Option Type Required Default Description
apiKey String Yes Your project API key
userId String? No Default user identifier
timeout int No 30000 Request timeout in ms

Factory Configuration

config.dart
final client = FeedbackKit.configure(
  apiKey: 'sf_your_api_key',
  userId: 'user_12345',
  timeout: 10000,
);

Provider

The FeedbackKitProvider widget wraps your app and makes the SDK client available throughout your widget tree.

provider.dart
// Access the client from anywhere in your widget tree
final client = FeedbackKitProvider.of(context);

// Use the client to make API calls
final feedbacks = await client.feedback.list();

API Reference

Feedback API

client.feedback

Method Description
list(): Future<List<FeedbackItem>> List all feedback
get(String id): Future<FeedbackItem> Get single feedback by ID
create(CreateFeedbackRequest): Future<FeedbackItem> Submit new feedback
feedback_api.dart
// Get all feedback
final all = await client.feedback.list();

// Get single feedback
final feedback = await client.feedback.get('feedback-uuid');
print('${feedback.title}: ${feedback.voteCount}');

// Submit new feedback
final created = await client.feedback.create(
  CreateFeedbackRequest(
    title: 'Add dark mode',
    description: 'Please add a dark mode option.',
    category: FeedbackCategory.featureRequest,
    userId: 'user_12345',
  ),
);

Votes API

client.votes

Method Description
vote(String feedbackId): Future<VoteResponse> Vote for feedback
unvote(String feedbackId): Future<VoteResponse> Remove vote
votes_api.dart
// Vote for feedback
final result = await client.votes.vote('feedback-id');
print('Vote count: ${result.voteCount}');

// Remove a vote
final removed = await client.votes.unvote('feedback-id');
print('Has voted: ${removed.hasVoted}');

Comments API

client.comments

Method Description
list(String feedbackId): Future<List<Comment>> List comments for feedback
create(String feedbackId, CreateCommentRequest): Future<Comment> Add comment
comments_api.dart
// List all comments
final comments = await client.comments.list('feedback-id');
for (final comment in comments) {
  print('${comment.userId}: ${comment.content}');
}

// Add a comment
final comment = await client.comments.create(
  'feedback-id',
  CreateCommentRequest(
    content: 'This would be really helpful!',
    userId: 'user_12345',
  ),
);

Users API

client.users

Method Description
register(RegisterUserRequest): Future<SDKUser> Register SDK user
users_api.dart
// Register a user
final user = await client.users.register(
  RegisterUserRequest(userId: 'user_12345', mrr: 9.99),
);

Events API

client.events

Method Description
track(TrackEventRequest): Future<TrackedEvent> Track analytics event
events_api.dart
// Track an event
await client.events.track(
  TrackEventRequest(
    eventName: 'feedback_list',
    userId: 'user_12345',
    properties: {'filter': 'feature_request'},
  ),
);

Widgets

Pre-built Flutter widgets for common feedback UI patterns.

Widget Description
FeedbackList Display list of all feedback items
FeedbackDetailView Detailed view of a single feedback item
SubmitFeedbackView Form for submitting new feedback
FeedbackCard Card component for displaying feedback
VoteButton Interactive vote button with count
StatusBadge Colored badge for feedback status
CategoryBadge Badge for feedback category

Models

FeedbackItem

Field Type Description
id String Unique identifier
title String Feedback title
description String Detailed description
status FeedbackStatus Current status
category FeedbackCategory Feedback category
voteCount int Total number of votes
hasVoted bool Whether the current user has voted
commentCount int Total number of comments
userId String ID of the user who submitted
createdAt DateTime When the feedback was created
updatedAt DateTime When the feedback was last updated

Enums

FeedbackStatus

Value Can Vote
pending Yes
approved Yes
inProgress Yes
testflight Yes
completed No
rejected No

FeedbackCategory

Value Display Name
featureRequest Feature Request
bugReport Bug Report
improvement Improvement
other Other

Theming

Customize the appearance of FeedbackKit widgets with FeedbackKitTheme.

theme.dart
final customTheme = FeedbackKitTheme(
  primaryColor: Colors.blue,
  backgroundColor: Colors.white,
  cardBackgroundColor: Colors.grey[50],
  textColor: Colors.black87,
  borderRadius: 12.0,
);

// Use dark theme
final darkTheme = FeedbackKitTheme.dark;

// Apply to provider
FeedbackKitProvider(
  apiKey: 'your-api-key',
  theme: customTheme,
  child: MyApp(),
);

Error Handling

The SDK provides a typed error hierarchy extending FeedbackKitError.

Error Class Status Code Description
FeedbackKitError Base error class
AuthenticationError 401 Invalid or missing API key
PaymentRequiredError 402 Subscription limit exceeded
ForbiddenError 403 Action not allowed
NotFoundError 404 Resource not found
ConflictError 409 Duplicate action (already voted)
ValidationError 400 Request validation failed
NetworkError 0 Network connectivity issue
ServerError 5xx Server-side error
error_handling.dart
try {
  final feedback = await client.feedback.create(
    CreateFeedbackRequest(
      title: 'My feedback',
      description: 'Details here',
      category: FeedbackCategory.featureRequest,
      userId: 'user_12345',
    ),
  );
} on AuthenticationError {
  print('Invalid API key');
} on PaymentRequiredError {
  print('Upgrade your plan to continue');
} on NotFoundError {
  print('Resource not found');
} on NetworkError {
  print('Check your internet connection');
} on FeedbackKitError catch (e) {
  print('Error: ${e.message}');
}