Top 5 dev_dependencies Packages in Flutter

This plugin is especially useful during development

flutter_lints (It encourages us to follow good coding practices)

It contains a list of lints for Flutter apps, packages, and plugins that encourage good coding practices.

mockito (This allows you to create Mock Dependencies between classes while testing your code.)

There are times when unit tests depend on classes that fetch data from live web services or databases. A few reasons make this inconvenient:

  • The execution of tests is slowed down when live services or databases are called.
  • If an unexpected result is returned by a web service or database, a passing test may fail. The term “flaky test” refers to this situation.
  • By using a live web service or database, it is difficult to test all possible success and failure scenarios.
  1. Add the dependencies to the package.
  2. Defining a test function is the first step.
  3. Prepare a test file that includes a mock http.Client.
  4. Test each condition by identifying it and writing a test for it.
  5. The tests should be run.

json_serializable (With this, Dart classes can be annotated in order to generate code for converting from and to JSON automatically.)

Using JSON serialization with code generation means allowing an external library to generate the encoding boilerplate on your behalf. In the first step, you create a file watcher to generate code from the model classes. There are libraries for this purpose, such as json_serializable and built_value.

build_runner (This package gives you a concrete way to generate files with Dart code, without having to use any tools like pub.)

With build_runner, you can generate files, test generated files, or serve both sources and generated files simultaneously. You can find more information about using build_runner on this page, which includes links to more information. If you want a detailed explanation of how to use build_runner with a specific package, check out its documentation.

flutter_gen (This allows you to generate codes for your assets, fonts, colors, and localizations.)

With the flutter_gen, you can generate assets, fonts, colors, etc. without using any string-based APIs.

  1. In your pubspec.yaml, you declare assets. The yaml file can be created normally; no further configuration is necessary.
  2. The Dart files will then be generated under the lib/gen directory by default by flutter_gen.
  3. Using the generated classes, you can then load your assets.

--

--

Mobile Application Developer | GDG Speaker | Technical Blogger at medium | community member at StackOverflow | Organizer @FlutterIndore

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Shirsh Shukla

Mobile Application Developer | GDG Speaker | Technical Blogger at medium | community member at StackOverflow | Organizer @FlutterIndore