The Key to Widget Testing

Greg Perry
Flutter Community
Published in
16 min readJan 15, 2021

--

An in-depth look at Testing in Flutter.

Unfortunately, I inadvertently deleted the source code for this article. It’s a good read, but without the code, it’s not stellar. Give it go, and I’ll have another example app to work with one day.

You’ve got to test your code. It’s a given. You’ve got to make sure it works, but like documentation, we programmers tend to write our test cases almost as an afterthought. Some shops, however, dedicate whole departments just to testing. Someone else then tests your code! Flutter offers a whole platform just for testing your code. Let’s take a look at how it’s done.

There’s A Test For That

In every new Flutter project, you‘ll find a directory called, test. In this article, we’re going to look at the test file, widget_test.dart, found in that directory for this particular Flutter project below called, mvc_template. You’ll have access to the Github account for this project (Again, I mistakenly deleted this project). It’s to produce a ‘project template’ involving the MVC design pattern for developers to start their own apps, but that’s another story. Here, we’re testing its accompanying example app.

mvc_template

I Like Screenshots…

--

--