diff --git a/docs/showcase/perplexity-flutter.mdx b/docs/showcase/perplexity-flutter.mdx new file mode 100644 index 0000000..f0903c3 --- /dev/null +++ b/docs/showcase/perplexity-flutter.mdx @@ -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.