# Referral Component

## Components Visuals&#x20;

{% tabs %}
{% tab title="Overview" %}

<figure><img src="/files/0tTh7fzWnEMxsWR6hG04" alt="" width="563"><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

{% hint style="info" %}
To unlock early access to the component                                                           [**Get Access**](https://bijfwfnqtsj.typeform.com/to/eUXDpbuh)
{% endhint %}

### Installation

To use the Referral component , you need to install `questlabs_flutter_sdk` package into your project&#x20;

* First, navigate to the root directory of your Flutter project. Open the `pubspec.yaml` file using your preferred code editor.
* Under the `dependencies` section in your `pubspec.yaml` file, add the following line to include the `questlabs_flutter_sdk` package
* After saving your changes, open your terminal or command prompt and run the following command to fetch the new dependency

```dart
dependencies:
  questlabs_flutter_sdk:
    git:
      url: "Replace with your github URL"
      ref: master  
  flutter_bloc: ^8.1.6
```

## Props of Referral Component

<table><thead><tr><th width="170">Prop Name</th><th width="178">Type</th><th width="343">Description</th><th>Required</th></tr></thead><tbody><tr><td>questProvider</td><td>QuestProvider</td><td>Provides necessary configuration such as API key, entity ID, and optional theme settings</td><td>Yes</td></tr><tr><td>apiKey</td><td>String</td><td>API key to authenticate requests.</td><td>Yes</td></tr><tr><td>entityId</td><td>String</td><td>Entity ID associated with the quest.</td><td>Yes</td></tr><tr><td>themeConfig</td><td>QuestThemeConfig</td><td>Customizes theme settings like background color, font style, border color, button color, etc.</td><td>No</td></tr><tr><td>primaryColor</td><td>Color</td><td>Sets the primary color of the component .</td><td>no</td></tr><tr><td>secondaryColor</td><td>Color</td><td>Sets the secondary color of the component .</td><td>no</td></tr><tr><td>buttonColor</td><td>Color</td><td>Defines the color of buttons within the component .</td><td>no</td></tr><tr><td>backgroundColor</td><td>Color</td><td>Specifies the background color of the component .</td><td>no</td></tr><tr><td>borderColor</td><td>Color</td><td>Defines the color of the component's border.</td><td>no</td></tr><tr><td>fontStyle</td><td>String</td><td>Sets the font style for text within the component (e.g., <code>"poppins"</code>)</td><td>no</td></tr><tr><td>shareWithComponentProps</td><td>ShareWithComponentProps</td><td>Contains user details,campaign ID, token, and display options for the "Referral Component" </td><td>Yes</td></tr><tr><td>userId</td><td>String</td><td>Unique user identifier.</td><td>Yes</td></tr><tr><td>token</td><td>String</td><td>Token for authenticating the user session.</td><td>Yes</td></tr><tr><td>campaignId</td><td>String</td><td>Unique campaign identifier.</td><td>Yes</td></tr><tr><td>showFooter</td><td>bool</td><td>Whether or not to display the footer in the "referral" component.</td><td>no</td></tr><tr><td>heading</td><td>String</td><td>Heading for the referral component.</td><td>no</td></tr><tr><td>description</td><td>String</td><td>Description for the referral component.</td><td>no</td></tr><tr><td>gradientBackgroundColor</td><td>Color</td><td>Indicates whether to use a gradient background.</td><td>no</td></tr><tr><td>primaryHeading</td><td>String</td><td>Primary heading for the gradient background.</td><td>no</td></tr><tr><td>primaryDescription</td><td>String</td><td>Primary description for the gradient background.</td><td>no</td></tr><tr><td>referralLink</td><td>String</td><td>Referral link.</td><td>no</td></tr><tr><td>shareButtonText</td><td>String</td><td>Text for the share button.</td><td>no</td></tr><tr><td></td><td></td><td></td><td></td></tr></tbody></table>

**You can customize the UI with the type of** QuestThemeConfig **would be**

```dart

          themeConfig: QuestThemeConfig(
              secondaryColor: Colors.red,
              primaryColor: Colors.blue,
              buttonColor: Colors.yellow,
              backgroundColor: Colors.yellow,
              fontStyle: "libre baskerville",
              borderColor: Colors.red
          )
```

### **Basic Usage:**

* In your `main()` function, ensure you initialize the app and dependencies as follows:

```dart
void main() {
  runApp(const MyApp());
  getItInit();
  getIt<SharedPref>().init();
}
```

* Add the following `BlocProvider` setup to your `providers` list to initialize the `ShareWithComponentCubit` for state management:

```dart
providers: [
  BlocProvider(
            create: (context) => getIt<ShareWithComponentCubit>(),
          ),
],
```

{% hint style="info" %}
Ensure you provide your entity ID, API key, token, user ID, and quest ID
{% endhint %}

```dart
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:quest_interview/token.dart';
import 'package:questlabs_flutter_sdk/questlabs_flutter_sdk.dart';

void main() {
  runApp(const MyApp());
  getItInit();
  getIt<SharedPref>().init();
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  @override
  Widget build(BuildContext context) {
    return MultiBlocProvider(
      providers: [
        BlocProvider(
          create: (context) => getIt<ShareWithComponentCubit>(),
        ),
      ],
      child: MaterialApp(
        title: 'Flutter Demo',
        home:   ShareWithComponent(
          questProvider: QuestProvider(
              apiKey: "apiKey",
              entityId: "entityId",
              // themeConfig: QuestThemeConfig(
              //     secondaryColor: Colors.green,
              //     primaryColor: Colors.blue,
              //     backgroundColor: Colors.white,
              //     buttonColor: Colors.yellow,
              //     fontStyle: "dancing script",
              //     borderColor: Colors.red
              // )
          ),
          shareWithComponentProps: ShareWithComponentProps(
              userId: "userId",
              token: "token",
              campaignId: "campaignId",
              // heading: "hhhhh",
              // showFooter: true,
              // description: "nothing is scary",
              // gradientBackgroundColor: Colors.red,
              // primaryDescription: "testing",
              // primaryHeading: "jjjjjj",
              // referralLink: "linkdin",
              // shareButtonText: "share this",
              // showRefferalLogo: false
          ),
        )
      ),
    );
  }
}



```

Watch the YouTube video below for a step-by-step guide on testing the Referral  component in your Flutter project.

{% embed url="<https://www.loom.com/share/b015330ade794873a7ff0b69e617ee00?sid=1a161dc1-bf23-48cd-9c6a-caa3b9f8f15e>" %}


---

# 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.questera.ai/questera-ai-sdks/flutter-sdk-components/expansion/referral-component.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.
