DEV Community

Christian Findlay
Christian Findlay

Posted on

Flutter: How To Mock Functions For Testing

This article explains how to mock top-level functions in Dart for Flutter widget tests.

https://www.christianfindlay.com/blog/flutter-mock-functions-for-testing

Functions don't have to be second-class citizens in Dart, and you don't have to make a new class every time you want to mock a dependency. Pass your functions into your widgets with dependency injection and replace them with substitutes for testing.

Top comments (0)