Packages are published to pub.dev. You can search for any packages in that website and you can find a lot of information about the package.
To install a package open pubspec.yaml
file and under dependencies
add the package name with the version. For example, to install SQFLite
in flutter you need to add the line below the dependencies attribute:
dependencies: ... sqflite: ^1.3.0
The line sqflite: ^1.3.0
specifies that we are going to install sqflite
and the version is 1.3.0
.
After that run the following code from the project directory:
flutter pub get
This will take some time and will install automatically.
To check if the package has been successfully installed in your project, open pubspec.lock
file and check if the package has been listed in that file.
When running flutter pub get
for the first time after adding a package, Flutter saves the concrete package version found in the pubspec.lock
lockfile. This ensures that you get the same version again if you, or another developer on your team, run flutter pub get
.