Skip to content

Added Library Values #176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
83 changes: 83 additions & 0 deletions docs/resources/projects/libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,89 @@ You can easily upgrade to newer versions of the libraries as they become availab

![update-library](imgs/update-library.avif)

## Library Values

**Library values** are essentially variables created and used by a library publisher and intended to have their values set by the library consumer. These values allow library publishers to create configurable variables that are useful in different contexts, such as API keys, global settings, or other project-specific configurations. These values allow consumers to input specific data required for the library to function properly in their project.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we say "library author" and "library user" instead of library publisher and library consumer?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, updated now.


For example, If someone has built a library that uses OpenAI API, they would define a Library Value for the OpenAI API key. As the consumer of the library, when you import, you must provide your own API key to ensure the library functions properly.

By using Library Values, the publisher allows consumers to adapt the library to their own configurations without hardcoding sensitive or project-specific data, like API keys, into the library itself.

### Create Library Values as Publisher

The publisher defines the variable name, data type (e.g., string, enum), whether the variable is nullable, and an optional default value.

To create library values, navigate to **Settings and Integrations > App Settings > Publish as Library > Library Values** section and click **+ Add Value**.

<div style={{
position: 'relative',
paddingBottom: 'calc(56.67989417989418% + 41px)', // Keeps the aspect ratio and additional padding
height: 0,
width: '100%'}}>
<iframe
src="https://demo.arcade.software/vGIveMr1UmSlaiOreYmR?embed&show_copy_link=true"
title=""
style={{
position: 'absolute',
top: 0,
left: 0,
width: '100%',
height: '100%',
colorScheme: 'light'
}}
frameborder="0"
loading="lazy"
webkitAllowFullScreen
mozAllowFullScreen
allowFullScreen
allow="clipboard-write">
</iframe>
</div>
<p></p>

#### Use Library Values
After setting Library Values, they function just like any other variable in FlutterFlow. You can bind them to components, actions, API calls, or any property that allows you to configure dynamic values across your library project. You can access Library Values via the ****Set from Variable**** menu.

:::tip
Library values are used only within the library project and are not available for use in the consumer project. The library consumer can only set their values.
:::

![access-library-values](imgs/access-library-values.avif)

### Set Library Values as Consumer

To set library values, navigate to **Settings and Integrations > Project Setup > Project Dependencies** page. When you import a library, you'll be prompted to set values for required Library Values. If the library has already been added, click on **View Details**, which will open a dialog and then you can enter a value.

<div style={{
position: 'relative',
paddingBottom: 'calc(56.67989417989418% + 41px)', // Keeps the aspect ratio and additional padding
height: 0,
width: '100%'}}>
<iframe
src="https://demo.arcade.software/JG68MN6oBpZpPvHnKDmh?embed&show_copy_link=true"
title=""
style={{
position: 'absolute',
top: 0,
left: 0,
width: '100%',
height: '100%',
colorScheme: 'light'
}}
frameborder="0"
loading="lazy"
webkitAllowFullScreen
mozAllowFullScreen
allowFullScreen
allow="clipboard-write">
</iframe>
</div>
<p></p>

:::tip
For different [**development environments**](../../testing-deployment-publishing/development-environments/development-environments.md) (e.g., development vs. production), you can bind Library Values to [**environment values**](../../testing-deployment-publishing/development-environments/development-environments.md#use-environment-values). For instance, you could have two different Library Values for an API key, such as `DEV_OPENAI_API_KEY` and `PROD_OPENAI_API_KEY`, and bind them to the development and production environments to track API usage separately.
:::

## FAQs

<details>
Expand Down