You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/ff-concepts/adding-customization/common-examples.md
+73-8Lines changed: 73 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -346,28 +346,93 @@ Here’s a list of other Firebase Auth variables that can be referenced in Custo
346
346
- These variables make it easy to integrate Firebase Auth data into custom functionality, enhancing the user experience.
347
347
348
348
349
-
### Get Library Values in Custom Code
349
+
### Get Dev Environment Values in Custom Code
350
+
351
+
Similar to the `FFLibraryValues` class, if you are using **[Dev Environments](../../testing-deployment-publishing/development-environments/development-environments.md)** in your FlutterFlow project, a new class called `FFDevEnvironmentValues` will be created. This class can also be accessed from custom code if needed. It is generated based on the environment selected by the user at the time of code generation.
352
+
353
+
To access any Dev Environment values in custom code, simply use:
354
+
355
+
```js
356
+
Future getWebhookId() async {
357
+
// Add your function code here!
358
+
returnFFDevEnvironmentValues().webhookId;
359
+
}
360
+
```
361
+
362
+
### Access Library Components in Custom Code
363
+
364
+
When using a library dependency in your project, you can also access its components, such as Library App State, Library Values, and Library Widgets, in the user project's custom code. Here are a few examples:
365
+
366
+
#### Get Library Values
350
367
351
368
Similar to the `FFAppState` class, FlutterFlow generates an `FFLibraryValues` class, which is also an abstract class. This class provides access to the **[Library Values](../../resources/projects/libraries.md#library-values)** if the project is a Library.
352
369
353
-
To directly access the Library Values in custom code:
370
+
To access Library Values directly in custom code:
354
371
355
372
```js
356
373
Future getSchema(StateStruct? syncStatus) async {
357
374
print(FFLibraryValues().schema);
358
375
}
359
376
```
360
377
361
-
### Get Dev Environment Values in Custom Code
378
+
#### Get Library Custom Code
362
379
363
-
Similar to the `FFLibraryValues` class, if you are using **[Dev Environments](../../testing-deployment-publishing/development-environments/development-environments.md)** in your FlutterFlow project, a new class called `FFDevEnvironmentValues` will be created. This class can also be accessed from custom code if needed. It is generated based on the environment selected by the user at the time of code generation.
380
+
When you add a library dependency to your FlutterFlow project, FlutterFlow automatically includes necessary imports, allowing you to utilize custom code resources from the library project in your user project's custom code files.
364
381
365
-
To access any Dev Environment values in custom code, simply use:
382
+
For example, if you have a library with project ID `library_hybw3o`, FlutterFlow will add the following import to your project:
366
383
367
384
```js
368
-
Future getWebhookId() async {
369
-
// Add your function code here!
370
-
returnFFDevEnvironmentValues().webhookId;
385
+
import'package:library_hybw3o/flutter_flow/custom_functions.dart' as library_hybw3o_functions;
386
+
```
387
+
388
+
389
+
Now, let's use the library’s custom functions in the user project's custom function:
390
+
391
+
```js
392
+
int getRandomIndex(List<int>indexList) {
393
+
final item =library_hybw3o_functions.getRandomItem(); // Library's custom function
394
+
// get Random Index
395
+
final randomNumber =math.Random();
396
+
return...
397
+
}
398
+
```
399
+
400
+
#### Manually add Library Imports
401
+
If you do not see a library import in your project, you can manually import it and assign a custom alias.
402
+
403
+
For example, let's import the library's custom actions into the user project's Custom Widget resource.
404
+
405
+
If the import is not already available, you can add it manually as follows:
406
+
407
+
```js
408
+
// Custom import
409
+
import'package:library_hybw3o/custom_code/actions/index.dart' as library_hybw3o_actions; // Assigning a custom alias to the import
Copy file name to clipboardExpand all lines: docs/resources/projects/libraries.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -202,6 +202,10 @@ It's important to note that these resources show up where they are instantiated.
202
202
203
203
This ensures that only relevant resources are shown where they are needed, optimizing performance and discoverability.
204
204
205
+
:::tip[Access Library Components in Custom Code]
206
+
When your project includes a library dependency, you can use its components—such as Library App State, Library Values, Library Custom Code resources, etc.—in your custom code. Explore the **[Common Custom Code Examples](../../ff-concepts/adding-customization/common-examples.md#access-library-components-in-custom-code)** directory for reference.
0 commit comments