Using packages – Adding a package dependency to an app using flutter pub add

To add the package css_colors to an app:

Use the pub add command from inside the project directory

flutter pub add css_colors

Import it

Add a corresponding import statement in the Dart code.

Stop and restart the app, if necessary

If the package brings platform-specific code (Kotlin/Java for Android, Swift/Objective-C for iOS), that code must be built into your app. Hot reload and hot restart only update the Dart code, so a full restart of the app might be required to avoid errors like MissingPluginException when using the package.

Leave a comment

Your email address will not be published. Required fields are marked *