由于一个库会在编译时破坏调试版本,因此我需要删除 debug builds 的导入。如果感兴趣的话,则是a Flutter web one。
我知道基于库的条件导入有效(请参见article):
import 'one_thing.dart'
if (dart.library.io) 'another_thing.dart'
if (dart.library.js) 'another_thing.dart'
if (dart.library.html) 'another_thing.dart';
这些库条件对我没有帮助,因为我的构建仍将无法在调试模式下编译。
理想情况下,我会遇到这样的事情:
import 'one_thing.dart'
if (kDebugMode) 'another_thing.dart';
但是,由于条件仅允许Dart VM条件并且kDebugMode
是Flutter中定义的常量,因此该方法不起作用。
如何在调试模式下删除/阻止库的导入。