将流的最后一个值增加到dart中的新增加的值?

时间:2019-12-28 10:58:56

标签: flutter dart stream

我想在dart中创建一个int的流值,每当一个新值进入流时,它会将最后添加的值递增到新数据中。我该如何实现?

   _cartAdditionController.stream.listen((cartItem) {
      _addProductToCartUseCase.execute(cartItem.product.objectId);
      //whenever a new value is added in itemCount
      // i want to concatenate the last value entered with the new count
      _itemCount.sink.add(cartItem.count);
    });

  final _itemCount = BehaviorSubject<int>.seeded(0);
  final _cartAdditionController = StreamController<CartItem>.broadcast();

0 个答案:

没有答案