Flutter & .NET Blog

Expert insights on Flutter, Dart, and .NET development

Flutter: How To Mock Functions For Testing

Flutter: How To Mock Functions For Testing

The Dart language allows us to implement and mock any class, which is essential for flutter test driven development. That’s because Dart has implicit interfaces, which is great for testing. However, some libraries give us functions that don’t belong to a class. That means we must do some work to mock or fake these functions for tests. This article explains how to do that. What is the Issue With Functions? If we call a standard top-level function in Dart, we cannot mock that function for a test. A classic case is the launchUrl function in the url_launcher library. When we run a widget test, we don’t want the launcher to open the Url physically, but we may want to put a fake in place, so we know that the app did call the function. We need an abstraction for the...
Christian Findlay Christian Findlay Dec 17, 2022
Immutability: Dart vs. F#

Immutability: Dart vs. F#

Immutability is a very important part of Functional Programming. Dart and F# are two excellent modern languages that support immutability and functional programming constructs. However, Don Syme and the...
Christian Findlay Christian Findlay Nov 05, 2022