Dart SDK
Official Misar.Dev SDK for Dart — build, deploy, and manage apps via api.misar.io/dev.
The official Misar.Dev client SDK for Dart. Async, with built-in retries and typed errors. Works in Dart and Flutter apps.
Installation
Add to pubspec.yaml:
dependencies:
misar_dev: ^1.0.0Then run dart pub get (or flutter pub get).
Quick start
Construct a MisarDevClient with your API key (format mdk_…) and point it at the Misar.Dev API:
import 'package:misar_dev/misar_dev.dart';
final client = MisarDevClient(
apiKey: 'mdk_your_api_key',
baseUrl: 'https://api.misar.io/dev',
);
// List your projects
final projects = await client.projectsList();
print(projects);
Configuration
| Parameter | Default | Description |
|---|---|---|
apiKey | — | Required named parameter. Your API key (mdk_…). |
baseUrl | https://misar.dev/api | Set to https://api.misar.io/dev. Trailing slashes are trimmed. |
maxRetries | 3 | Retry attempts for retryable status codes (429, 500, 502, 503, 504) with exponential backoff. |
httpClient | null | Optional package:http Client for injection/reuse. |
Every request sends Authorization: Bearer <apiKey> and Content-Type: application/json.
Resources
This early v1.0.0 port implements the following methods. Each returns Future<Map<String, dynamic>>.
| Method | HTTP | Description |
|---|---|---|
projectsList() | GET /projects | List projects. |
projectsCreate(Map<String, dynamic> params) | POST /projects | Create a project. |
templatesList() | GET /templates | List templates. |
apiKeysList() | GET /api-keys | List API keys. |
chatComplete(Map<String, dynamic> params) | POST /chat | Send a chat completion request. |
usageGet() | GET /usage | Retrieve usage data. |
// Create a project
final project = await client.projectsCreate({
'name': 'my-app',
'template': 'nextjs',
});
// Chat completion
final reply = await client.chatComplete({
'messages': [
{'role': 'user', 'content': 'Hello'}
],
});
This is an early v1.0.0 port and intentionally exposes a subset of the full API surface (projects, templates, api-keys, chat, usage). Other resources available in the TypeScript SDK are not yet ported.
Error handling
Non-success responses throw MisarDevApiError; transport-level failures throw MisarDevNetworkError (a subclass with status == 0).
try {
final projects = await client.projectsList();
} on MisarDevNetworkError catch (e) {
print('Network error: ${e.message}');
} on MisarDevApiError catch (e) {
print('API error ${e.status} (${e.errorType}): ${e.message}');
}
Retryable status codes (429, 500, 502, 503, 504) are retried automatically up to maxRetries before the error is thrown.