# Quick-Start

### Installation

You will find all instructions in [installation](https://docs.abtasty.com/server-side/sdks/flutter/archived-versions/flutter/flutter-installation) topic

### Flagship Usage

#### Start SDK

The first call you should make is to start the SDK by calling `start` method through the Flagship class.

```groovy
import 'package:flagship/flagship.dart';

// Step 1 - Start the Flagship sdk with default configuration.
Flagship.start("_ENV_ID_", "_API_KEY_");
```

In *step 1* The SDK needs to start the `environmentId` and `apiKey`. By default the Flagship start with `Decision Mode` for more details on custom configuration go to [Advanced Configuration](https://docs.abtasty.com/server-side/sdks/flutter/archived-versions/flutter-reference#advanced-configuration).// Fix url

{% hint style="info" %}
📘 API Key & Environment ID required

*You can find your apiKey and your environmentId on your Flagship account, in Parameters > Environment & Security.*
{% endhint %}

#### Create Visitor

The second step after starting the SDK is [visitor](https://docs.abtasty.com/server-side/sdks/flutter/archived-versions/flutter-reference#visitor-class) creation. This object allows you to manage visitor's context, experiments, and track events.

```groovy
// Step 2 - Create visitor with context "isVip" : true
var visitor = Flagship.newVisitor(visitorId: "visitorId", hasConsented: true)
        .withContext({"isVip": true}).build();
```

In *Step 2* We create a visitor providing his [consent](https://docs.abtasty.com/server-side/sdks/flutter/archived-versions/flutter-reference#setconsent-method) and his [context](https://docs.abtasty.com/server-side/sdks/flutter/archived-versions/flutter-reference#updatecontext-method). Go to[ builder methods](https://docs.abtasty.com/server-side/sdks/flutter/archived-versions/flutter-reference#newvisitor-method) to learn more about visitor creation.

#### Getting flags

Once we have created our visitor instance we need to fetch flags. Go to [Flag](https://docs.abtasty.com/server-side/sdks/flutter/archived-versions/flutter-reference#flag-class) to learn more about.

```groovy
// Step 3 - Fetch flags
    visitor.fetchFlags().whenComplete(() {
      // Step 4 - Get Flag key
      var flag = v.getFlag("flagKey");
      // Step 5 - Read Flag value
      var value = flag.value("defaultValue");
    });
```

When flag fetching completes in step 3 its inner code block is executed. In step 4, we are ready to process visitor's flags and read their [values](https://docs.abtasty.com/server-side/sdks/flutter/archived-versions/flutter-reference#value-method) in step 5.

Note: SDK will [report exposition](https://docs.abtasty.com/server-side/sdks/flutter/archived-versions/flutter-reference#value-method) by default when reading a Flag value.

#### Tracking hits

Then sending events tracking will allows you to validate objectives in your campaign reporting.

```groovy
// Step 6 - Send Event
visitor.sendHit( Event(action: "event_action", category: EventCategory.Action_Tracking));
```

{% hint style="info" %}
📘

In order to see your events in your campaign reporting you must define objectives kpis beforehand in the campaign configuration. For more details [Set up your KPIs](https://docs.abtasty.com/server-side/glossary#kpi).
{% endhint %}

In *step 6* Flagship is on charge of sending the *event\_action* event through the function `sendHit`. Go to [tracking](https://docs.abtasty.com/server-side/sdks/flutter/archived-versions/flutter-reference#hit-tracking) for more information.

You should see your hit using [hitStream](https://app.gitbook.com/s/PLcJUpntQruhbI1jQ2kr/reporting/verifying-your-hit-setup) feature, then on your campaign [report](https://app.gitbook.com/s/PLcJUpntQruhbI1jQ2kr/reporting).
