Skip to content

docs(showcase): add Perplexity Dart & Flutter SDKs showcase #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions docs/showcase/perplexity-flutter.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
title: Perplexity Dart & Flutter SDKs
description: Lightweight, type-safe SDKs for seamless Perplexity API integration in Dart and Flutter applications
sidebar_position: 3
keywords: [Perplexity, Flutter, Dart, SDK, API, streaming, chat-completions, sonar, type-safe, widgets]
---

# Perplexity Dart & Flutter SDKs

**Perplexity Dart & Flutter SDKs** provide comprehensive toolkit for integrating Perplexity's AI capabilities into Dart and Flutter applications. Built specifically for the Flutter community, these packages include a lightweight core API client and ready-to-use Flutter widgets with BLoC state management.

## Features

* Type-safe API client with fully typed models and compile-time safety
* Streaming and non-streaming chat completions with real-time response handling
* Support for all Perplexity models (Sonar, Sonar Pro, Deep Research, Reasoning variants)
* Multi-image processing with base64, data URI, and HTTPS URL support
* Ready-to-use Flutter widgets with BLoC state management integration
* Advanced configuration options (temperature, top-p, search filters, domain restrictions)
* Cross-platform support for iOS, Android, Web, and Desktop
* Future-proof design with custom model string support for new Perplexity releases

## Prerequisites

* Dart SDK 2.17.0 or newer
* Flutter SDK 3.0.0 or newer (for Flutter-specific features)
* Perplexity API key from Perplexity API Console
* Basic knowledge of Flutter BLoC pattern for widget integration

## Installation

### For Dart Projects (Core API Only)

```bash
dart pub add perplexity_dart
```

### For Flutter Projects (Full Widget Support)

```bash
flutter pub add perplexity_flutter
```

### Environment variables

```dart
// Add to your app's configuration
const String perplexityApiKey = 'your_perplexity_api_key_here';
```

## Usage

**Core API Integration:**
- Type-safe client with all Perplexity models (Sonar, Sonar Pro, Deep Research, Reasoning)
- Streaming and non-streaming chat completions
- Multimodal processing with flexible MessagePart system for text + images

**Flutter Widget Layer:**
- `ChatWrapperWidget` for BLoC state management
- `PerplexityChatView` for real-time message display
- `PerplexityChatInput` for user interaction handling

## Code Explanation

* Core Layer: Pure Dart API client (`perplexity_dart`) for cross-platform Perplexity API integration
* UI Layer: Flutter widgets (`perplexity_flutter`) with BLoC state management for rapid development
* Type Safety: Fully typed models and responses prevent runtime errors and provide IntelliSense
* Multimodal: Flexible MessagePart system for combining text and images in single requests
* Streaming: Built-in support for real-time chat completions with proper chunk handling
* Architecture: Two-layer design allows lightweight API usage or full Flutter widget integration

## Architecture

**Two-layer design:**
- **Core (`perplexity_dart`)** - Pure Dart API client for all platforms
- **UI (`perplexity_flutter`)** - Flutter widgets + BLoC state management

Uses flexible MessagePart system for multimodal content combining text and images.
## Links

**Packages:**
- [perplexity_dart on pub.dev](https://pub.dev/packages/perplexity_dart) | [GitHub](https://github.com/vishnu32510/perplexity_dart)
- [perplexity_flutter on pub.dev](https://pub.dev/packages/perplexity_flutter) | [GitHub](https://github.com/vishnu32510/perplexity_flutter)

**Examples:**
- [Flutter Example App](https://github.com/vishnu32510/perplexity_dart/tree/main/example_flutter_app)
- [Dart Examples](https://github.com/vishnu32510/perplexity_dart/tree/main/example)

**Contributing:** Issues and PRs welcome on both repositories.