Add any Flutter package from pub.dev to FlutterFlow via Custom Code → Pubspec Dependencies → Add Dependency. Then use the package in a Custom Widget (for UI-rendering packages like fl_chart), Custom Action (for side-effect packages like share_plus or url_launcher), or Custom Function (for pure data transformation packages like intl). Always check the package's Flutter SDK version constraint on pub.dev before adding to avoid compile errors.
Add any pub.dev package to FlutterFlow using Custom Code and Pubspec Dependencies
FlutterFlow's built-in widget library covers the most common UI patterns, but there are thousands of Flutter packages on pub.dev that add capabilities your app might need: charts, PDF generation, QR code scanning, barcode readers, audio players, image editors, local notifications, and more. Adding these packages to FlutterFlow follows a consistent three-step pattern: add the package name and version in Pubspec Dependencies, import it in a Custom Widget, Custom Action, or Custom Function, and wire the custom code to your UI. This tutorial explains all three usage patterns with real examples and covers the most common integration mistakes.
Prerequisites
- A FlutterFlow project on any plan — Pubspec Dependencies are available on all plans
- Basic understanding of Dart syntax for reading package documentation and examples
- A pub.dev package you want to add (use pub.dev/flutter to browse)
Step-by-step guide
Find a compatible package on pub.dev and check Flutter SDK support
Find a compatible package on pub.dev and check Flutter SDK support
Go to pub.dev and search for the functionality you need. On the package page, look at three key indicators before adding to FlutterFlow: (1) Dart 3 compatible — should show a green checkmark (FlutterFlow uses Dart 3). (2) Flutter SDK constraint — look in the pubspec.yaml tab for 'sdk: flutter' requirement. It must be compatible with FlutterFlow's Flutter version (check Settings → Advanced → Flutter Version in FlutterFlow). (3) Pub score — packages with score over 120 and many likes are better maintained. (4) Last published date — packages not updated in 2+ years may have compatibility issues. Popular high-quality packages: fl_chart (charts), share_plus (sharing), url_launcher (links), image_picker (camera/gallery), path_provider (file paths), intl (date/number formatting).
Expected result: Identified a compatible package with Dart 3 support, high pub score, and recent updates.
Add the package via Pubspec Dependencies in FlutterFlow
Add the package via Pubspec Dependencies in FlutterFlow
In FlutterFlow, go to Custom Code in the left sidebar (the code icon). Click the Pubspec Dependencies tab. Click Add Dependency. Type the exact package name (case-sensitive, matches pub.dev). Type the version constraint — use a caret version like ^10.0.0 to allow compatible patch updates (10.x.x) while preventing breaking major version changes. Click Save. FlutterFlow will attempt to compile the dependency. A green checkmark means successful compilation. A red error means a conflict exists. Common dependency names: fl_chart ^0.68.0, share_plus ^10.0.0, url_launcher ^6.3.0, image_picker ^1.0.7, intl ^0.19.0. If compilation fails with a version conflict, try lowering the version number to match what other packages in your project already use.
Expected result: Package appears in Pubspec Dependencies list with a green compile status. No red error indicators.
Use a package as a Custom Widget for UI-rendering packages
Use a package as a Custom Widget for UI-rendering packages
Custom Widgets are used when the package renders something visual — a chart, a map, a markdown renderer, a carousel. Go to Custom Code → Custom Widgets → Add Custom Widget. Name it clearly (e.g., LineChart, QRCodeWidget). In the widget code, import the package at the top, then build a Flutter widget that uses the package. Define parameters for any data the widget needs from FlutterFlow (list of data points, colors, sizes). The widget must return a Widget from its build method. Example for fl_chart: import 'package:fl_chart/fl_chart.dart' then build a LineChart widget with your data. After saving, the Custom Widget appears in the widget palette and can be placed on any page, with its parameters bindable to Backend Query results or Page State variables.
1// Custom Widget example: SimpleLineChart using fl_chart2import 'package:fl_chart/fl_chart.dart';3import 'package:flutter/material.dart';45class SimpleLineChart extends StatelessWidget {6 final List<double> dataPoints;7 final Color lineColor;8 final double height;910 const SimpleLineChart({11 super.key,12 required this.dataPoints,13 this.lineColor = Colors.blue,14 this.height = 200,15 });1617 @override18 Widget build(BuildContext context) {19 final spots = dataPoints20 .asMap()21 .entries22 .map((e) => FlSpot(e.key.toDouble(), e.value))23 .toList();2425 return SizedBox(26 height: height,27 child: LineChart(28 LineChartData(29 lineBarsData: [30 LineChartBarData(31 spots: spots,32 color: lineColor,33 barWidth: 2,34 dotData: const FlDotData(show: false),35 )36 ],37 titlesData: const FlTitlesData(show: false),38 gridData: const FlGridData(show: false),39 borderData: FlBorderData(show: false),40 ),41 ),42 );43 }44}Expected result: Custom Widget appears in the widget palette. Drag it onto a page and bind its dataPoints parameter to a list from a Backend Query or App State.
Use a package as a Custom Action for side-effect packages
Use a package as a Custom Action for side-effect packages
Custom Actions are used when the package performs an operation but does not render UI — sharing content, opening URLs, accessing the camera, requesting permissions, playing audio, writing files. Go to Custom Code → Custom Actions → Add Custom Action. Name it descriptively (e.g., shareContent, launchUrl, pickImage). Add parameters for the inputs the action needs (text to share, URL to open, etc.). Import the package and write the action code. The action can return a value (String, bool, list) that gets used in the action flow. Example: using url_launcher to open a URL. After saving and compiling, the action appears in the Action Flow editor and can be added to any button or trigger.
Expected result: Custom Action appears in the Action Flow editor under Custom Actions. Tapping the button that triggers it performs the expected operation on device.
Use a package as a Custom Function for data transformation packages
Use a package as a Custom Function for data transformation packages
Custom Functions are used for pure data transformations — no side effects, no UI rendering, just input → output. Use them for: date formatting (intl), currency formatting, string manipulation, JSON parsing, mathematical calculations. Go to Custom Code → Custom Functions → Add Custom Function. Name it descriptively (e.g., formatCurrency, formatDate, parsePhoneNumber). Define input parameters and a return type. Import the package and write the transformation. Example using intl for date formatting: import 'package:intl/intl.dart'; then return DateFormat('MMM d, yyyy').format(date). Custom Functions appear in the Set from Variable menu and can be used in any widget property binding, not just in action flows.
Expected result: Custom Function appears in the Set from Variable menu. Binding a Text widget's value to the Custom Function shows formatted output from the raw data.
Resolve package version conflicts and compile errors
Resolve package version conflicts and compile errors
If adding a package causes a compile error mentioning 'version conflict' or 'incompatible constraints', it means the new package requires a different version of a shared dependency than another package already in your project. Click on the error in the Pubspec Dependencies panel to see the full conflict message. Common resolution strategies: (1) Try a lower version of the package you just added — often an older version has compatible constraints. (2) Check if there is a newer version of the conflicting dependency that satisfies both packages. (3) Look for a fork or alternative package that solves the same problem without the conflict. (4) Remove a less critical package if it is blocking an important new one. Never ignore compile errors in pubspec — they affect all custom code, not just the conflicting package.
Expected result: All packages in Pubspec Dependencies show green compile status. Custom Code section shows no red error indicators.
Complete working example
1// Custom Widget: SimpleLineChart2// Uses fl_chart package for sparkline charts3// Add fl_chart ^0.68.0 to Pubspec Dependencies first45import 'package:fl_chart/fl_chart.dart';6import 'package:flutter/material.dart';78class SimpleLineChart extends StatelessWidget {9 final List<double> dataPoints;10 final Color lineColor;11 final double height;12 final bool showDots;13 final bool showGrid;1415 const SimpleLineChart({16 super.key,17 required this.dataPoints,18 this.lineColor = Colors.blue,19 this.height = 200,20 this.showDots = false,21 this.showGrid = false,22 });2324 @override25 Widget build(BuildContext context) {26 if (dataPoints.isEmpty) {27 return SizedBox(28 height: height,29 child: const Center(child: Text('No data')),30 );31 }3233 final spots = dataPoints34 .asMap()35 .entries36 .map((e) => FlSpot(e.key.toDouble(), e.value))37 .toList();3839 return SizedBox(40 height: height,41 child: LineChart(42 LineChartData(43 lineBarsData: [44 LineChartBarData(45 spots: spots,46 color: lineColor,47 barWidth: 2,48 isCurved: true,49 dotData: FlDotData(show: showDots),50 belowBarData: BarAreaData(51 show: true,52 color: lineColor.withOpacity(0.1),53 ),54 )55 ],56 titlesData: const FlTitlesData(show: false),57 gridData: FlGridData(show: showGrid),58 borderData: FlBorderData(show: false),59 minX: 0,60 maxX: (dataPoints.length - 1).toDouble(),61 ),62 ),63 );64 }65}Common mistakes
Why it's a problem: Adding a package version that is incompatible with FlutterFlow's Flutter SDK version
How to avoid: Before adding a package, go to the package's page on pub.dev → Pubspec tab and read the environment constraint (sdk: '>=3.0.0 <4.0.0'). Compare against FlutterFlow's Flutter SDK version. If incompatible, try an older version of the package that supports a lower SDK version, or check pub.dev for an alternative package with compatible SDK constraints.
Why it's a problem: Using a Custom Widget for packages that should be Custom Actions (non-visual packages)
How to avoid: Use the correct code component type for each package: Custom Widget for packages that render UI, Custom Action for packages that perform operations (I/O, device APIs, background tasks), Custom Function for pure data transformation (formatting, parsing, calculating).
Why it's a problem: Not clicking Compile Code after adding or modifying Custom Code that uses new packages
How to avoid: After adding a package to Pubspec Dependencies AND after writing the Custom Code that uses it, click Compile Code (the button in the Custom Code header). Wait for the green success indicator before testing the custom code behavior in Test Mode or on a device.
Best practices
- Use caret versioning (^1.2.3) not exact versioning (1.2.3) in Pubspec Dependencies — caret allows FlutterFlow to resolve compatible minor updates that fix bugs without requiring your manual intervention
- Add packages one at a time and compile after each addition — adding five packages at once makes it impossible to know which one caused a conflict when compilation fails
- Prefer packages with 'Flutter Favorite' status or packages maintained by recognized organizations (Google, the Flutter team, supabase, firebase) — they are better maintained and less likely to break between Flutter versions
- Check the package's GitHub issues page for open bugs with FlutterFlow before adding — some popular packages have known compatibility issues with FlutterFlow's code generation that make them difficult to use
- Document which packages you are using and why in a comment at the top of the Custom Code file — makes it easier to clean up unused packages when you refactor
- Test Custom Widgets on both iOS and Android physical devices — some packages behave differently across platforms, and the FlutterFlow web preview does not accurately reflect mobile behavior for device API packages
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I am adding a third-party Flutter package to FlutterFlow. Explain the three ways packages can be used in FlutterFlow: (1) Custom Widget for UI-rendering packages like fl_chart, (2) Custom Action for side-effect packages like share_plus, and (3) Custom Function for pure transformation packages like intl. For each, write a complete example showing the correct import statements, the code structure, and how to expose parameters that FlutterFlow can bind to from the UI.
Add fl_chart version ^0.68.0 to my project's Pubspec Dependencies and create a Custom Widget named LineChartWidget that takes a List<double> dataPoints parameter and renders a smooth line chart with a light blue fill. The widget should have a height parameter with default value 200 and show no axis labels or grid lines.
Frequently asked questions
Can I add any Flutter package from pub.dev to FlutterFlow?
Most packages can be added, but there are exceptions. Packages that require native iOS/Android code modifications beyond what Flutter's plugin system handles (e.g., manual Info.plist edits, custom Gradle configurations) may compile successfully but fail at runtime. Packages that rely on native modules FlutterFlow's build system does not support will error on build. Check if the package has a FlutterFlow-specific discussion in the FlutterFlow community or package's GitHub issues before attempting complex native integrations.
What is the difference between Pubspec Dependencies and FlutterFlow's built-in widget library?
FlutterFlow's built-in widgets (Button, TextField, Image, ListView, etc.) are pre-configured Flutter widgets with a visual configuration panel in FlutterFlow's UI editor. Pubspec Dependencies are raw Flutter/Dart packages from pub.dev that you use in Custom Code. Built-in widgets need no coding. Pubspec Dependencies always require writing Custom Widget, Custom Action, or Custom Function code in Dart.
How do I know what version of a package to use in FlutterFlow?
On pub.dev, click the Versions tab for the package. Use the latest stable version (not pre-release versions ending in -beta or -dev). Always use caret syntax (^1.2.3) which allows compatible patch and minor updates. If you get a version conflict, try the second-most-recent major version. For packages like fl_chart, share_plus, and image_picker that are commonly used in FlutterFlow, search the FlutterFlow community forum for the version other developers are successfully using.
How do I remove a package from FlutterFlow that I no longer need?
In Custom Code → Pubspec Dependencies, find the package and click the trash icon to remove it. Also delete or update any Custom Widgets, Custom Actions, or Custom Functions that import that package — if they still have import statements for the removed package, compilation will fail for all custom code. After removing the package and its references, click Compile Code to verify the removal was clean.
Can I use packages that require permissions (camera, microphone, contacts) in FlutterFlow?
Yes. Packages that require device permissions work in FlutterFlow, but you must also configure the permissions in FlutterFlow's Settings panel. For iOS: Settings → iOS Settings → Info.plist Custom Values → add the relevant NSXxxUsageDescription string. For Android: Settings → Android Settings → Android Manifest → add the android.permission.XXX element. The permission request itself typically happens inside your Custom Action using the permission_handler package or directly through the device API package.
Can RapidDev help integrate a complex package that is not working in my FlutterFlow project?
Yes. Package integration issues — especially packages requiring native platform configuration, version conflicts, or packages with FlutterFlow-specific compatibility quirks — are common support requests. RapidDev has a library of tested package configurations for FlutterFlow and can resolve package integration issues that would take significant trial and error to sort out independently.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation