我正在尝试在 rxdart 中实现 bloc 模式。我正在尝试构建 app 类型的 todo 应用程序。我实现了显示列表中的所有项目,但我想要的不是在不同部分显示已完成和未完成的项目。但是,我无法根据完成的 rxdart 过滤项目。
import 'package:rxdart/rxdart.dart';
import '../models/ShoppingItem.dart';
class ShoppingItemBloc {
final _shoppingItems = BehaviorSubject<List<ShoppingItem>>
(seedValue: []);
Observable<List<ShoppingItem>> get allShoppingItems =>
_shoppingItems.stream;
//Getter to implement
Observable<List<ShoppingItem>> get completedShoppingItems =>
dispose() {
_shoppingItems.close();
}
}
我想要的是获得完成的 shoppingItems 。ShoppingItem 类有一个布尔属性 completed 。我想在此基础上对其进行过滤。
任何帮助将不胜感激