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
You can only add a pub dependency to Custom Action & Custom Widgets.
223
+
You can only add a pubspec dependency to [**Custom Action**](custom-actions.md) & [**Custom Widgets**](custom-widgets.md).
224
224
:::
225
225
226
-
If you plan to use a dependency from [*pub.dev*](https://pub.dev/) into a custom widget or action,
227
-
you must go through the following steps:
226
+
### Pub.dev
227
+
[Pub.dev](https://pub.dev) is the official package repository for Dart and Flutter. It hosts a wide range of packages, libraries, and tools that developers can use to extend the functionality of their Dart and Flutter applications.
Flutter Favorite packages are a curated set of packages on pub.dev that have been recognized by the Flutter team and the community for their quality, popularity, and usefulness in Flutter development. These packages are marked with a "Flutter Favorite" badge, indicating that they meet a high standard of quality, reliability, and best practices.
232
+
233
+
You can explore the Flutter Favorite packages on **[pub.dev's Flutter Favorites page](https://pub.dev/packages?q=is%3Aflutter-favorite)**.
234
+
235
+
:::
236
+
237
+
### Choosing the correct package from pub.dev
234
238
235
239
You will find varieties of dependencies for a specific requirement, and choosing the best one can be
236
240
challenging. This section helps you identify the right dependency by examining its score.
When adding a pubspec dependency to your custom code in FlutterFlow, you’ll need two pieces of information: the [package name with its version number](#copy-package-name--version-) and the [import statement](#copying-import-statement).
265
+
266
+
#### Copy Package Name & Version
261
267
262
268
To use the dependency code in our code editor, copy its name with the version. To do so, click
263
269
the **Copy to Clipboard** icon.
@@ -278,7 +284,7 @@ section at the bottom right side.
278
284
279
285

280
286
281
-
##### 3. Copying import statement
287
+
#### Copying import statement
282
288
283
289
An import statement points to where the dependency's code is located. When making a custom widget or
284
290
action, place this statement at the beginning of the code editor.
@@ -288,7 +294,44 @@ the import statement. To copy, click the **Copy to Clipboard** icon.
288
294
289
295

290
296
297
+
### Add Pubspec Dependency to Custom Code: Guide
298
+
In this example, we are using the
299
+
[**flutter_rating_bar**](https://pub.dev/packages/flutter_rating_bar) dependency to create a
300
+
`ProductRatingBar` custom widget for our
301
+
Product pages. See how we utilize the example code from pub.dev and add the customized widget in
302
+
FlutterFlow:
291
303
304
+
<div style={{
305
+
position: 'relative',
306
+
paddingBottom: 'calc(56.67989417989418% + 41px)', // Keeps the aspect ratio and additional padding
This example demonstrates how to add a [pub.dev](https://pub.dev) package to a Custom Widget snippet, but you can follow the same process for adding a package to Custom Actions. For a deep dive, explore the detailed documentation on **[Custom Widgets](custom-widgets.md)** and [Custom Actions](custom-actions.md).
Copy file name to clipboardExpand all lines: docs/ff-concepts/adding-customization/custom-widgets.md
+6-2Lines changed: 6 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,7 +61,7 @@ this example, we will create a `ProductRatingBar` widget that uses a pub.dev dep
61
61
62
62
For custom widgets, it is mandatory to specify both width and height. These properties are required to size the custom widget appropriately. Without setting these dimensions, the custom widget will not render correctly within your application.
63
63
64
-
## Adding a pub.dev dependency
64
+
## Add Dependency to Custom Widgets
65
65
66
66
In this example, we are using the
67
67
[**flutter_rating_bar**](https://pub.dev/packages/flutter_rating_bar) dependency to create a
@@ -95,6 +95,10 @@ FlutterFlow:
95
95
</iframe>
96
96
</div>
97
97
98
+
:::tip[Choosing a Pubspec Dependency]
99
+
For a comprehensive guide on navigating external packages using pub.dev, evaluating packages, and making the best choices for your app, [**follow the guide**](custom-code.md#adding-a-pubspec-dependency).
100
+
:::
101
+
98
102
## Using a Custom Widget
99
103
To add a custom widget to your page, you can drag and drop it from the Widget Palette's Components section or through the Widget Tree section. Here is a demo:
100
104
@@ -167,7 +171,7 @@ FlutterFlow also allows you to view your custom widget once it is successfully c
167
171
To learn more about Custom Widget settings, such as the
168
172
[**Exclude From Compilation toggle**](custom-code.md#exclude-from-compilation),
169
173
and other properties like [**Callback Actions**](custom-code.md#add-a-callback-action),
170
-
[**Pub Dependencies**](custom-code.md#adding-a-pub-dependency), please check out this
174
+
[**Pub Dependencies**](custom-code.md#adding-a-pubspec-dependency), please check out this
0 commit comments