Run either of the following commands in the terminal ( inside your project directory) to add the package to your project.
dart pub add package_name or flutter pub add package_name
- go to pub.dev
- search your package
- go to installing tab and copy the package name and version under dependencies
pubspec.yamlfile present in root directory
- paste it under dependencies.(be careful about the indentation)
- save and your ide will download the package in the project.
- go to the dart file where you want to use it and import at the top
That's it. Now you can use the package however you like.