Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find if we are running unit test in Dart (Flutter)

While calling a function from unit test in Flutter (Dart), how can I find if I am running unit test or real application? I want to pass different data if it's in unit test.

like image 257
AVEbrahimi Avatar asked Nov 25 '19 09:11

AVEbrahimi


1 Answers

You can use the following to check if you're running a test.

Platform.environment.containsKey('FLUTTER_TEST')
like image 121
Ovidiu Avatar answered Nov 13 '22 14:11

Ovidiu