Perplexity Dart & Flutter SDKs
Perplexity Dart & Flutter SDKs provide a 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)
For Flutter Projects (Full Widget Support)
Environment variables
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 managementPerplexityChatView
for real-time message displayPerplexityChatInput
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