似乎不像skipWhile在做什么...还是我理解这个错误?
下面的代码...我希望skipWhile删除两个条目!
Dart版本(来自Flutter Doctor):Dart version 2.9.0 (build 2.9.0-10.0.dev 7706afbcf5)
import 'package:flutter_test/flutter_test.dart';
class Car {
final String name;
final bool active;
final int wheels;
Car({this.name, this.active=true, this.wheels=4});
}
void main() {
test("Check skipWhile", () {
List dataSet = [
Car(name: "Thunder", active: false),
Car(name: "Lightening", active: false),
Car(name: "Dinky", wheels: 3),
Car(name: "Camry"),
Car(name: "Outback"),
];
List activeCars = dataSet.skipWhile((car) => car.active).toList();
expect(activeCars.length, 3);
});
}