【问题标题】:Flutter: "Too many positional arguments: 0 expected, but 1 found"Flutter:“位置参数太多:预期为 0,但找到了 1”
【发布时间】:2021-11-09 22:17:09
【问题描述】:

我正在尝试制作一个照片库应用程序,但是当我等待 _controller.takePicture(path); 时出现此错误“位置参数过多:预期为 0,但找到了 1” 谁能告诉我如何解决这个问题。

void _takePicture() async {
    try {
        await _initializeControllerFuture;

        final tmpDirectory = await getTemporaryDirectory();
        final filePath = '${DateTime.now().millisecondsSinceEpoch}.png';
        final path = join(tmpDirectory.path, filePath);

        await _controller.takePicture(path);

        widget.didProvideImagePath(path);
    } catch (e) {
        print(e);
    }
}

【问题讨论】:

  • 你能展示一下 didProvideImagePath 里面的内容吗?

标签: flutter dart


【解决方案1】:

如果它说它不接受参数,只需按原样调用方法:

widget.didProvideImagePath();

【讨论】:

  • 抱歉不是widget.didProvideImagePath(path);我得到错误。正是上面的那行,我收到了一个错误,即等待 _controller.takePicture(path);。你知道如何解决这个问题吗?
  • 看看该函数接受哪些参数。至少它们不是位置的,所以它可能根本不带参数_controller.takePicture() 或命名参数。但是需要函数定义来检查
猜你喜欢
  • 2021-09-21
  • 2022-07-20
  • 2020-04-20
  • 2019-11-03
  • 2021-05-22
  • 1970-01-01
  • 2021-12-18
  • 2021-07-27
  • 2021-11-10
相关资源
最近更新 更多