# Flutter SDK

## AllStak Flutter SDK Documentation

We’re excited to introduce the **AllStak Flutter SDK**, a developer-friendly solution for **error tracking and monitoring** in Flutter applications.

***

### 🚀 Key Features

✅ **Exception Tracking**

* Automatically captures and reports runtime exceptions.
* Provides detailed error context, including stack traces, device details, and OS information.

✅ **Device and App Context**

* Collects device-specific data such as platform, OS version, and screen size.
* Logs application-specific details like app version, build number, and package name.

✅ **Network Request Monitoring**

* Seamlessly integrates with HTTP libraries like `http` and `dio`.
* Tracks API requests and logs failed responses.

✅ **Flutter Integration**

* Simple setup tailored for **Flutter applications**.
* Supports **Android, iOS, Web, and Desktop** platforms.

***

### 📦 Installation

Add **AllStak Flutter SDK** to your project by updating your `pubspec.yaml` file:

```yaml
dependencies:
  allstak: latest_version
```

Then, run:

```sh
flutter pub get
```

***

### 🛠 Usage

#### **1️⃣ Initialize AllStak in `main.dart`**

```dart
import 'package:flutter/material.dart';
import 'package:allstak/allstak.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  print('Initializing AllStak SDK...');

  await Allstak.init(
    AllstakOptions(
      apiKey: 'your-api-key-here',
      environment: 'production',
    ),
    appRunner: () => runApp(const MyApp()),
  );
}
```

#### **2️⃣ Capture Exceptions**

Manually catch and log exceptions:

```dart
try {
  throw Exception("Test exception for AllStak");
} catch (e, stackTrace) {
  Allstak.captureException(e, stackTrace);
}
```

***

### 🎨 Example App

Here’s a simple Flutter app that integrates AllStak:

```dart
import 'package:flutter/material.dart';
import 'package:allstak/allstak.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await Allstak.init(
    AllstakOptions(
      apiKey: 'your-api-key',
      environment: 'production',
    ),
    appRunner: () => runApp(const MyApp()),
  );
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'AllStak Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'AllStak Error Tracking Demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});
  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  Future<void> _triggerError() async {
    try {
      throw Exception("Simulated error for AllStak");
    } catch (e, stackTrace) {
      Allstak.captureException(e, stackTrace);
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text(widget.title)),
      body: Center(
        child: ElevatedButton(
          onPressed: _triggerError,
          child: const Text("Trigger Error"),
        ),
      ),
    );
  }
}
```

***

### 🔗 Links & Resources

* **📖 API Documentation:** [docs.allstak.io](https://docs.allstak.io)
* **🚀 Website:** [allstak.io](https://allstak.io)

***

### 🎯 What's Next?

We're continuously improving **AllStak**! Stay tuned for:

* 📊 **Performance Monitoring**
* 📡 **Live Issue Tracking Dashboard**

Feel free to **contribute** and **star ⭐ the repository** on GitHub!

***

#### 🚀 Start Tracking Errors Like a Pro with **AllStak Flutter SDK**! 🎉


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.allstak.io/flutter-sdk.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
