ABSTRACT

In this chapter, you will learn the basics of writing unit testing for a Flutter application. Unit tests are useful for testing a unit of code or a particular functionality of a method/function or class. We will use the modified version of the default counter application to understand writing unit tests for a Flutter application. In the modified default CounterApp, we will add two buttons. The two buttons are used to increment the current value of the counter displayed on the screen. We will use a Flutter plugin font_awesome_flutter (font_awesome_flutter) to add these increment and decrement button icons. This plugin comes with a rich set of Flutter icons. We will add one green button with an increment icon for increasing the counter by one. Another red button with a decrement icon is used for reducing the counter value by one. Once this modified interface for CounterApp is ready, you will learn how to write unit tests to test the given Dart class Counter's logical functions.