首页 > 解决方案 > Flutter on VS Code 问题:StreamController.Sink.add() 突然需要参数 PUSH

问题描述

大家下午好,我突然遇到了 VS Code 的问题:在几个 Flutter 应用程序中 Streamcontroller.sink.add(); 突然需要参数“push”(在它没有之前)。 居住

不添加 push 参数显然会返回错误

2 required argument(s) expected, but 1 found.dart(not_enough_required_arguments)

有谁知道可能发生了什么?提前感谢您的帮助弗朗切斯科

编辑:通过 f12 定义实际上显示了参数 push

    part of dart.core;

/**
 * A generic destination for data.
 *
 * Multiple data values can be put into a sink, and when no more data is
 * available, the sink should be closed.
 *
 * This is a generic interface that other data receivers can implement.
 */
abstract class Sink<T> {
  /**
   * Adds [data] to the sink.
   *
   * Must not be called after a call to [close].
   */
  void add(T data, Future push);

  /**
   * Closes the sink.
   *
   * The [add] method must not be called after this method.
   *
   * Calling this method more than once is allowed, but does nothing.
   */
  void close();
}

但正如 pskink 提醒的那样,文档没有显示这个要求;我不知道这会如何改变,此时的问题是:

如何恢复正常?

标签: visual-studio-codedartstreamflutterbloc

解决方案


TL;DR 看起来是错误的代码,实际上是损坏的 dart 代码;

我按照Gunter 提供的指示,一切恢复正常。

再次感谢甘特


推荐阅读