@TryLoveCatch
2019-09-12T10:58:44.000000Z
字数 833
阅读 1023
flutter
/// 当App运行在Release环境时,为true;
/// 当App运行在Debug和Profile环境时,为false。
static bool isRelease() {
return bool.fromEnvironment('dart.vm.product');
}
在pubspec.yaml里面添加依赖
dependencies:
flutter:
sdk: flutter
dev_dependencies:
# 这里~~~~
test:
flutter_test:
sdk: flutter
添加了test和flutter_test,这里最好也添加flutter_test,要不然后面执行的时候,会比较麻烦
counter_app/
lib/
counter.dart
test/
counter_test.dart
class Counter {
int value = 0;
void increment() => value++;
void decrement() => value--;
}
import 'package:test/test.dart';
import '../lib/counter.dart';
void main() {
test('Counter value should be incremented', () {
final counter = Counter();
counter.increment();
print(counter.value);
expect(counter.value, 1);
});
}