Have you tried creating your first Flutter app yet?
This is as simple as running
flutter create billion_dollar_app on the terminal (or doing the same directly from VSCode or Android Studio).
After creating the project, you’ll notice that some files and folders have been generated:
The most important file is called
pubspec.yaml. This is used to specify your application’s dependencies. These resources explain how this file works and how to use it to install packages:
Installing Packages from pub.dev
But apps are made of more than just UI.
And rather than reinventing the wheel, you’ll want to install packages from pub.dev, the official package repository for Dart and Flutter apps.
Installing packages is easy, and you can do it directly from the command line:
# Install http package as a dependency
dart pub add http
# Install build_runner package as a dev dependency
dart pub add build_runner --dev
Or, if you use VSCode, you can hit
CMD+SHIFT+P to open the command palette and use the “Dart: Add Dependency” command:
Then, you can enter a comma-separated list of packages, and VSCode will suggest all the available matches:
How to choose which packages to install?
When deciding if a package suits your needs, there are a few factors to consider:
- Is it listed as a Flutter Favorite?
- Does it have a high pub score? (here’s an example)
- Is it well maintained on GitHub? (look at the ratio of open / closed issues)
- Is it well documented?
Remember that when you install a package, you depend on it. And depending on packages that are buggy, not maintained, and poorly documented won’t make you a happy bunny. So try to choose high-quality packages from reputable authors and organizations.
A great way to discover the best packages is to check out the Package of the Week playlist on YouTube.
When you create a Flutter project, the flutter_lints package will be installed by default.
Lints are rules that are used to encourage good coding practices, and they help you write better and safer code.
To learn how to make the most of Flutter lints, right in your IDE, watch this video:
flutter_lints may be the default linter package - and a good one when you’re just starting.
If you want to go deeper into this topic, read this guide:
If you really want to, you can even write your own lint rules using the custom_lint package.
Checklist for New Flutter Projects
Enabling linter rules is one of the best things you can do when you start a new Flutter project.
But if you want to build some serious apps with a backend, multiple environments, automated tests, and more, there are many things to consider. We’ll cover some of these things in the upcoming emails. But for now, here’s a helpful checklist: